Call tree complexity exceeds threshold
The call tree complexity of a file is greater than the defined threshold
Since R2021a
Description
The call tree complexity of a file represents the complexity between different levels of its function call tree. Polyspace® calculates the call tree complexity of a file as:
Call tree Complexity = number of call occurrences – number of function definitions + 1 | (1) |
Estimated Function Coupling
Polyspace uses the default threshold 20 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 Estimated Function Coupling
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 interdependency of the functions in the file is unacceptably high.
Changes in one function in the file might introduce bugs or unexpected behavior in other functions in the file.
Reusing a single function of the file might be difficult because of interdependencies with other functions.
These factors make the file difficult to maintain, test, 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:
SC03
|
Default Threshold: 20 |
Version History
Introduced in R2021a