주요 콘텐츠

Create New Checkers Activation File Without Polyspace User Interface

With the Polyspace® desktop products, you can create a checkers activation XML file in the user interface and then use this file for command-line analysis. Provide this XML file with the option Checkers activation file (-checkers-activation-file).

You can reuse the activation xml file with the Polyspace Server products. That is, you can create the checkers activation file using the Polyspace user interface, and then use it when running an analysis using the server products. To see how you can create the activation file using the Polyspace user interface, see Check for and Review Coding Standard Violations.

If the Polyspace user interface is unavailable, you can curate your own checkers selection using two methods. You can create your own coding standard using the Polyspace Query Language. Alternatively, you can edit a template activation XML file in a text editor.

Create Your Own Coding Standard

Once you know which Polyspace Bug Finder™ checkers you want to enable, you can collect these checkers into your own coding standard using polyspace-query-language. You can create your own coding standard following these steps:

  1. In a writable location, initialize a Polyspace Query Language project. In the command line, enter:

    polyspace-query-language init
    This command creates a file main.pql.

  2. Create your coding standard by declaring rule, sections, and finally the catalog that contains all sections.

  3. After constructing the coding standard, package the standard using the package command:

    polyspace-query-language package
    This command creates a .pschk file.

  4. Use the .pschk file in your subsequent analysis:

    polyspace-bug-finder-server -sources ... -checkers-activation-file your_coding_standard.pschk

In this workflow, the checkers you activate are part of a new user-defined coding standard. For more on this workflow, see:

Select Checkers by Editing Checkers Activation Template

If you do not want to create a new coding standard but still want to activate a custom set of coding rules from different standards in the command line, select checkers by editing existing checkers activation xml file in a text editor. This workflow is error prone and not recommended.

Depending on the standard that you want to enable, make a writable copy of one of the files in polyspaceserverroot\polyspace\examples\doc_cxx\checkers_activation_XML and turn off checkers using entries in the XML file (all rules from a standard are enabled in the template). Here, polyspaceserverroot is the root installation folder for the Polyspace Server products, for instance, C:\Program Files\Polyspace Server\R2026a.

For instance, to turn off MISRA C™:2012 rule 8.1, use this entry in a copy of the file misra_c_2012_rules.xml:

<standard name="MISRA C:2012">
  ...
  <section name="8 Declarations and definitions">
      ...
      <check id="8.1" state="off">
      </check>
      ...
  </section>
  ...
</standard>

When using the Guideline checkers, specify their threshold between the threshold tags. For instance, to activates the checker Cyclomatic complexity exceeds threshold and set the threshold for the checker to five, use this entry in a copy of the guidelines.xml:

<check id="SC18" state="on">
        <threshold>5</threshold>
</check>

To use the XML file for a MISRA C:2012 analysis in Bug Finder, enter:

polyspace-bug-finder -sources filename -checkers-activation-file misra_c_2012_rules.xml

For full list of rule id-s and section names, see Coding Standards.

Note

The XML format of the checker configuration file can change in future releases.

See Also

|

Topics