Number of calling functions exceeds threshold
The number of distinct callers of a function is greater than the defined threshold
Since R2021a
Description
This defect is raised on a function when the number of distinct callers of the function is
greater than the defined checker threshold. For details about how Polyspace calculates the
number of calling functions, see Number of Calling Functions
.
Polyspace® uses the default threshold 5 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 Calling 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:
Issues arising in the flagged function might propagate to have unexpected impact in many places.
The data flow in the file is convoluted and finding the root cause of an issue might be difficult.
The flagged function might be performing multiple tasks.
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:
SC04
|
Default Threshold: 5 |
Version History
Introduced in R2021a