SC11 Number of executable lines in function body exceeds threshold
The number of executable lines in the body of a function is greater than the defined threshold
Description
This defect is raised on a function when the number of executable lines within the body of
the function is greater than the defined checker threshold. For details about how Polyspace
calculates the number of executable lines in a function, see Number
of Executable Lines
Polyspace® uses the default threshold 1000 unless you specify a threshold. 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 Executable Lines 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 function is overly long and performs multiple tasks.
The function is likely to develop unexpected issues. The chance of an unexpected error increases with more lines of executable code.
The function might contain unexpected or unplanned development.
These factors make the function 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 is reasonably concise.
Each function performs one specific task.
The functions have minimal side effects on other functions.
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:
SC11
|
| Default Threshold: 1000 |
Version History
Introduced in R2021a