Number of called functions exceeds threshold
The number of distinct function calls within the body of a function is greater than the defined threshold
Since R2021a
Description
This defect is raised on a function when the number of calls to distinct functions within
its body is greater than the defined checker threshold. For details about how Polyspace
calculates the number of called functions, see Number of Called Functions
.
Polyspace® uses the default threshold 7 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 Called Functions
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 depends on many functions and changes to any one of these functions might result in an unexpected behavior.
The function performs too many tasks.
The module might contain 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.
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:
SC05
|
Default Threshold: 7 |
Version History
Introduced in R2021a