Number of static paths exceeds threshold
The number of static paths in a function is greater than the defined threshold
Since R2021a
Description
This defect is raised on a function when the number of static paths in the function is
greater than the defined checker threshold. For details about how Polyspace calculates the
number of static paths in a function, see Number of Paths
Polyspace® uses the default threshold 80 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 Paths
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 has too many possible execution paths. When there are too many execution paths, it might be difficult to test all paths exhaustively. Such functions are difficult to debug, test and maintain.
Fix
To fix this check, either refactor your code or change the checker threshold. When refactoring your code:
Avoid putting control structures in long sequences.
Split a complex function into multiple functions that are simpler and easy to test.
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:
SC15
|
Default Threshold: 80 |
Version History
Introduced in R2021a