Number of function calls exceeds threshold
The number of function calls in a function is greater than the defined call occurrence threshold of a function
Since R2021a
Description
This defect is raised when the body of a function contains more calls to functions than
the specified call occurrence threshold of a function. For details about how Polyspace® calculates the number of function call occurrences, see Number of Call Occurrences
Polyspace uses the default threshold 50 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 Call Occurrences
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 performs too many tasks.
The function might have high interdependency with multiple other functions.
Changes in some other function might have unexpected impact on the flagged function.
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 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:
SC06
|
Default Threshold: 50 |
Version History
Introduced in R2021a