Calculate code metrics (-code-metrics)

Compute and display code complexity metrics

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.

To maintain an acceptable level of software complexity during the development cycle, use the software complexity checkers. See .

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.

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:

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 file_name -code-metrics
Example (Code Prover): polyspace-code-prover -sources file_name -code-metrics
Example (Bug Finder Server): polyspace-bug-finder-server -sources file_name -code-metrics
Example (Code Prover Server): polyspace-code-prover-server -sources file_name -code-metrics

See Also

Topics