Calculate code metrics (-code-metrics
)
(Removed) Compute and display code complexity metrics
Using Code Prover to compute code metrics is no longer supported. Use Calculate code metrics (-code-metrics)
in Bug Finder instead. For
more information, see Version History.
Description
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.
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:
In Bug Finder, disable checking of defects. See
Find defects (-checkers)
.In Code Prover, run verification up to the
Source Compliance Checking
phase. SeeVerification level (-to)
.
A Code Prover analysis computes the stack usage metrics after the source compliance checking phase. If you stop a Code Prover verification before source compliance checking, the stack usage metrics are not reported.
Command-Line Information
Parameter:
-code-metrics |
Default: Off |
Example (Bug Finder):
polyspace-bug-finder -sources |
Example (Code Prover):
polyspace-code-prover -sources |
Example (Bug Finder Server):
polyspace-bug-finder-server -sources
|
Example (Code Prover Server):
polyspace-code-prover-server -sources |