Skip to Main Content Skip to Search
Product Documentation

Viewing Coding Rules Checker Results

Running a Verification with Coding Rules Checking

When you run a verification with the MISRA C, Check MISRA C++ rules or Check JSF C++ rules option selected, the verification checks most of the rules during the compile phase. If there is a violation of a rule with state Error, the verification stops.

To start the verification:

  1. On the Project Manager toolbar, click the Run button .

  2. Code analysis begins.

    • If the coding rules checker detects violations of coding rules set to Error, the verification stops, and the Output Summary tab shows that the verification has detected coding rules violations.

    • If there are no violations of rules set to Error, code verification continues after the completion of rules checking.

  3. When rules checking is complete, the file MISRA-C-report.xml, MISRA-CPP-report.xml, or JSF-report.xml appears in the Project Browser Result folder. This file contains the results from the coding rules checker.

Examining Rule Violations

When code analysis is complete, you can view results in the Results Manager perspective.

To examine coding rule violations:

  1. Double-click MISRA-C-report.xml, MISRA-CPP-report.xml or JSF-report.xml in the Project Browser Result folder.

    The Results Manager perspective opens, displaying results on the Results Explorer tab.

    The software displays coding rule violations as purple checks.

  2. To display a list of checks by color, select the Results Summary tab. By default, the software displays the purple checks at the end of the list.

      Note   If you set the review level to 0, the Results Summary tab displays only violations of coding rules with state Error. See What Are Review Levels?

  3. Click any purple check. In the Check Details pane, you see the location and description of the violated rule. In the Source pane, you see the code containing the violation.

  4. If required, use the Check Review tab to classify, apply comments, or justify the coding rule violation. See Commenting and Justifying Coding Rule Violations .

  5. To open the source file that contains the coding rule violation, in the Source pane, right-click the code with the purple check. From the context menu, select Open Source File. The appropriate file opens in your text editor.

  6. Correct the coding rule violation.

When you have corrected all coding rule violations, run the verification again.

Commenting and Justifying Coding Rule Violations

When reviewing coding rules violations in the Results Manager perspective, you can classify the severity of each violation, mark violations as Justified, and enter comments to describe the results of your review.

After you mark violations as Justified, you can hide them. This helps you track the progress of your review and avoid reviewing the same violation twice.

To review, comment, and justify a violation:

  1. In the Results Manager perspective, from the Results Explorer or Results Summary tab, select the violation you want to review. In the Check Details pane, you see the location and description of the violated rule. In the Source pane, you see the code containing the violation.

  2. Review the violation. Then, on the Check Review tab, select a Classification to describe the severity of the issue:

    • High

    • Medium

    • Low

    • Not a defect

  3. Select a Status to describe how you intend to address the issue:

    • Fix

    • Improve

    • Investigate

    • Justify with annotations

    • No Action Planned

    • Other

    • Restart with different options

    • Undecided

  4. In the comment box, enter additional information about the violation.

  5. Select the Justified check box to indicate that you have justified this check.

Opening Coding Rules Report

You can use the Polyspace Report Generator to generate reports about compliance with coding rules, as well as other reports. For information on using the Polyspace Report Generator, see Generating Reports of Verification Results.

The coding rules report contains all the errors and warnings reported by the coding rules checker. You see the following information in tables:

.

To view the coding rules report:

  1. Navigate to the folder that contains your coding rules report, for example, C:\Polyspace\example_project\Module_1\Result_6\Polyspace-Doc.

  2. Double-click the coding rules report, for example, example_project_CodingRules.rtf. The report opens in your selected editor.

Copying and Pasting Justifications

Instead of typing the full syntax of an annotation comment in your source code, you can copy an annotation template from the Results Manager perspective, paste it into your source code, and modify the template to comment the check.

To copy the justification template to the clipboard:

  1. In the Results Manager perspective, from the Results Summary tab, select any coding rule violation.

  2. From the Source pane, right-click the violation.

  3. From the context menu, select Add Pre-Justification to Clipboard. The software copies the justification string to the clipboard.

  4. Open the source file containing the violation you want to justify.

  5. Navigate to the code you want to comment, and paste the justification template string on the line immediately before the line you want to comment.

  6. Modify the template text to comment the code appropriately.

  7. Save the file.

  


 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS