Number of statements exceeds threshold
The number of statements in a function is greater than the defined threshold
Since R2021a
Description
This defect is raised on a function when the number of statements in the function is
greater than the defined threshold of the checker. For details about how Polyspace calculates
the number of statements in a function, see Number of Instructions
.
Polyspace® uses the default threshold 50 unless you specify a threshold for the checker. To
specify a selection file where you can set the threshold, use the option Set checkers by file (-checkers-selection-file)
or Checkers activation file
(-checkers-activation-file)
.
When you import comments from previous analyses by using polyspace-comments-import
, Polyspace copies any review information on the code metric Number of Instructions
in the previous result to
this checker in the current result. If the current result contains the same code metric, the
review information is copied to the code metric as well.
Risk
Violation of this checker might indicate that:
The purpose of the function is unclear.
The function performs multiple tasks.
The function has high interdependency with other modules.
The function contains unexpected or unplanned development.
These factors make the module difficult to maintain and debug.
Fix
To fix this check, either refactor your code or change the checker threshold. When refactoring the code, design the functions in your code so that:
Each function performs one specific task.
The functions have minimal side effects on other functions.
Independent data and code are properly isolated and encapsulated.
A best practice is to check the complexity of a module early in development to avoid costly post-development refactoring.
Examples
Check Information
Group: Software Complexity |
Language: C | C++ |
Acronym:
SC12
|
Default Threshold: 50 |
Version History
Introduced in R2021a