Number of direct recursions exceeds threshold
Number of instances of a function calling itself directly is greater than the defined threshold
Since R2024a
Description
A direct recursion occurs when a function calls itself directly. Polyspace® reports a violation of this rule when the number of such direct recursions
exceed a specified threshold. For details about how Polyspace calculates the number of direct recursions, see Number of Direct Recursions
.
Polyspace uses the default threshold 0, following recommendation from the Hersteller
Initiative Software (HIS) standard. 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 Direct Recursions
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
Direct recursion can lead to issues that are difficult to diagnose such as stack overflow. Recursive code is difficult to read and maintain, which could lead to miscalculating the amount of stack required to avoid stack overflow.
Fix
To fix this check, refactor your code to avoid recursion. In many cases, recursive algorithms can be replaced by loops.
Examples
Check Information
Group: Software Complexity |
Language: C | C++ |
Acronym:
SC19
|
Default Threshold: 0 |
Version History
Introduced in R2024a