주요 콘텐츠

Check for and Review Coding Standard Violations

Using Polyspace®, you can check your C/C++ code for violations of various external coding standards such as MISRA C™:2023, MISRA C++:2023, and AUTOSAR C++:14. For a list of supported standards, see Coding Standards. Adhering to coding standards can reduce the number of defects and improve the quality of your code.

You can check violations of predefined sets of coding rules from the supported coding standards. Alternatively, you can curate a custom selection of coding rules.

Configure Coding Standards User Interface

To configure checking violation of coding standards in the Polyspace Platform user interface user interface, open the Checkers Selection dialog box:

  1. Double click the Configure node of the Projects pane.

  2. On the Static Analysis tab, select Defects and Coding Standards. Select Use custom checkers file and then click Open () next to the option Checkers activation file.

    A snapshot of the Findings selection window.

  3. In the Checkers Selection dialog box, select coding rules from supported coding standards. Some coding standards, such as MISRA C:2023 or MISRA C++:2023 supports predefined subsets such as Mandatory, Required, Advisory. You can select rules from these predefined subsets by selecting the corresponding checkbox. Alternatively, activate individual coding rules. Find rules that you want to activate by using the Filter.

  4. After activating the coding rules, save your selection as a reusable checkers activation file (.xml).

In addition to activating coding rules, you can use the Checkers Selection dialog box to:

Configure Coding Standards in Command Line

In the command line, you can activate coding rules and defect checkers in two ways:

Review Coding Rule Violations

A snapshot of a typical Polyspace result showing a coding rule violation.

After analysis, you see the coding standard violations on the Results List pane. Select a violation to see further details on the Result Details pane and the source code on the Source Code pane.

Violations of coding standards are indicated in the source code with the icon.

For further steps, see Reviewing and Reporting Results or .

Generate Reports

You can generate reports of coding standard violations using the CodingStandards template, which is explicitly defined for coding standards. This template:

  • Reports only coding standard violations in your analysis results, and omits other types of results such as defects, run-time errors or code metrics.

  • Creates a separate chapter in the report for each coding standard. The chapter provides an overview of all violations of the standard and then lists each violation.

To see how you can generate a report after running an analysis, see Generate Reports of Bug Finder or Code Prover Results.

See Also

Topics