Calculate code metrics (-code-metrics
)
Compute and display code complexity metrics
Description
This option applies to Bug Finder only. See Version History.
Specify that Polyspace® must compute and display code complexity metrics for your source code. The metrics include file metrics such as number of lines and function metrics such as cyclomatic complexity and estimated size of local variables.
For more information, see Compute Code Complexity Metrics Using Polyspace.
To maintain an acceptable level of software complexity during the development cycle, use the software complexity checkers. See Reduce Software Complexity by Using Polyspace Checkers.
Set Option
User interface (desktop products only): In your project configuration, the option is on the Coding Standards & Code Metrics node.
User interface (Polyspace Platform, desktop products only): In your project configuration, the option is on the Defects and Coding Standards tab.
Command line and options file: Use the option
-code-metrics
. See Command-Line Information.
Why Use This Option
By default, Polyspace does not calculate code complexity metrics. If you want these metrics in your analysis results, before running analysis, set this option.
High values of code complexity metrics can lead to obscure code and increase chances of coding errors. Additionally, if you run a Code Prover verification on your source code, you might benefit from checking your code complexity metrics first. If a function is too complex, attempts to verify the function can lead to a lot of unproven code. For information on how to cap your code complexity metrics, see Compute Code Complexity Metrics Using Polyspace.
Settings
- On
Polyspace computes and displays code complexity metrics on the Results List pane.
- Off (default)
Polyspace does not compute complexity metrics.
Tips
If you want to compute only the code complexity metrics for your code, disable
checking of defects. See Find defects (-checkers)
.
Command-Line Information
Parameter:
-code-metrics |
Default: Off |
Example (Bug Finder):
polyspace-bug-finder -sources |
Example (Bug Finder Server):
polyspace-bug-finder-server -sources
|