Main Content

Migrate Code Prover Workflows for Checking Coding Standards and Code Metrics to Bug Finder

In previous releases, Polyspace® Code Prover supported checking of external coding standards and computation of code complexity metrics. For instance, you might be using Code Prover to:

  • Check compliance with external coding standards such as MISRA C:2012 or MISRA C++:2008.

  • Check compliance with naming conventions.

  • Check compliance with code complexity standards.

  • Calculate code metrics.

Support for the preceding capabilities is removed from Code Prover. Polyspace Bug Finder is the recommended tool for performing these tasks. Modify your workflows to migrate from using Code Prover to using Bug Finder.

Changes in Workflow

To migrate from Code Prover to Bug Finder, your workflow might need some changes.

Check for Coding Rule Violations and Compute Code Metrics

Previously, to perform this task, you configured the appropriate options in the Configuration pane, and then clicked Run Code Prover. To migrate to using Bug Finder:

  • In the Polyspace user interface, configure the same options in the Configuration pane, and then click Run Bug Finder.

  • At the command line, replace polyspace-code-prover by polyspace-bug-finder. If you do not want to enable the Bug Finder defects, specify -checkers with the value none. For instance, replace this command:

    polyspace-code-prover -sources file_name -misra3 all -code-metrics 
    with this command:
    polyspace-bug-finder -sources file_name -misra3 all -code-metrics -checkers none

Polyspace Bug Finder checks some coding rules differently compared to Code Prover. After migrating to Bug Finder, you might see some differences in the number and location of coding rule violations.

Compute Code Metrics, Check for Run-Time Errors and Coding Rule Violations

Previously, to perform these tasks, you configured the appropriate options in the Configuration pane, and then clicked Run Code Prover. To migrate to using Bug Finder:

  • In the Polyspace user interface, configure the same options in the Configuration pane. Then, obtain these results by performing two separate Polyspace analyses. Run a Bug Finder analysis to check for coding rule violations and to compute code metrics. Run a separate Code Prover verification to check for run-time errors.

  • At the command line, run separate Bug Finder and Code Prover analyses by using the commands polyspace-bug-finder and polyspace-code-prover with appropriate analysis options. For instance, replace this command:

    polyspace-code-prover -sources file_name -misra3 all -code-metrics
    with this command:
    polyspace-bug-finder -sources file_name -code-metrics -misra3 all -checkers none
    polyspace-code-prover -sources file_name

Compute Code Metrics, Check for Run-Time Errors and Coding Rule Violations in Generated Code

Previously, to perform these tasks, you configured your Polyspace analysis, and then started a Code Prover verification. To migrate to using Bug Finder:

  • On the Simulink® toolstrip, use the same configurations that you used before. Then, run separate Bug Finder and Code Prover analyses.

  • In the MATLAB® Command Window, use separate sets of polyspace.ModelLinkOptions and polyspace.Project objects to perform separate Bug Finder and Code Prover analyses.

 Sample MATLAB Code

Produce a Polyspace Report Containing Run-Time Errors, Coding Rule Violations, and Code Metrics

Previously, you configured a Code Prover verification to produce a single report containing run-time errors, code metrics, coding rule violations, and other results. To migrate to using Bug Finder, configure the same options and run separate Bug Finder and Code Prover analyses. See Compute Code Metrics, Check for Run-Time Errors and Coding Rule Violations.

The Bug Finder and Code Prover results are summarized in separated reports.

To produce a combined report containing Bug Finder and Code Prover results, use polyspace-report-generator. For instance, if your Bug Finder and Code Prover results are saved in the folders BF_results and CP_results, use this command at the command prompt:

polyspace-report-generator ^
-template %template_path% ^
-results-dir "CP_Results","BF_Results"

 Sample Batch Script

Check for Protected and Unprotected Shared Global Variables

Previously, to perform this task, you specified the entry point functions and temporally exclusive functions in your code, and then computed code metrics by using Code Prover. The recommended tool for performing this task is to use the global variable checks in Code Prover instead.

  • In the Polyspace user interface, configure the same options you did before, and then click Run Code Prover. You do not need to check Calculate Code Metrics.

  • At the command line, run a Code Prover verification by using the same analysis options that you used before. Omit -code-metrics.

After the verification completes, in the Results List, the protected shared global variables are flagged by green checks, and the potentially unprotected shared global variables are flagged by orange checks.

See Global Variables.

Calculate Stack Usage

Previously, to calculate stack usage, you configured your Code Prover analysis in the Polyspace UI to compute code metrics or specified the option -code-metrics. The recommended tool for performing this task is to use the analysis option Calculate stack usage (-stack-usage).

  • In the Polyspace user interface, check Calculate stack usage in the Check Behavior pane, and then click Run Code Prover. You do not need to check Calculate Code Metrics.

  • At the command line, run a Code Prover verification by using the same analysis options that you used before. Use -stack-usage instead of -code-metrics.

After the verification completes, in the Results List, the stack usage metrics are listed.

Related Topics