Checkers activation file (-checkers-activation-file)
Activate custom combination of defects and coding rules for Polyspace Bug Finder analysis
Description
Specify the full path of an activation (.XML) file or a user defined
coding standard (.pschk) file where you define custom combination of
Polyspace®
Bug Finder™ defects and coding standards checkers. Checker activation files
(.XML) and user defined coding standards (.pschk)
are created differently and have different uses. Both are acceptable as input to this
option.
Set Option
User interface (desktop products only): This option is not directly available in the user interface. Enter the command line option -checkers-activation-file in the Other field. See Other.
User interface (Polyspace Platform): In your project configuration, the option is on the Defect and Coding Standards tab.
Command line and options file: Use the option -checkers-activation-file. See Command-Line Information.
Why Use This Option
This option allows you to:
Create a custom selection of Polyspace Bug Finder defects and coding rules in a reusable
.XMLfile.Check for violations of a user defined coding standards defined in a reusable
.pschkfile.
You can reuse the files across multiple projects or share with multiple users to maintain a common set of rules across your group or organization.
Settings
A default Polyspace Bug Finder analysis reports a specific set of defects and does not report any coding rule violations. To activate a custom set of checkers including defects and coding rules, use a checkers activation file or a user defined coding standard.
You can create the checker activation file (.XML) using one of these methods:
Checkers selection window — Create the checkers activation (
.XML) file by saving your checkers selection in the Checkers Selection window. See Create Checkers Activation File Using Checkers Selection Interface.Text editor — Open an existing checkers activation XML file in a text editor and turn on the desired checkers. See Update Checkers Activation File in Text Editor.
To create the user-defined coding standard (.pschk) using
the command polyspace-query-language. See Create User-Defined Coding Standard by Using Polyspace Query Language.
If you have a preexisting file, then use the file as input to this option.
Dependencies
To use this option in the Polyspace Platform user interface, you must set the option Set checkers using file to On (
).
Examples
Create Checkers Activation File Using Checkers Selection Interface
Create a checkers activation file by using the Checkers selection interface. This file is a reusable selection of Bug Finder defects and coding rules that you can use as the input to the option -checkers-activation-file in a Bug Finder analysis.
Open the Checkers selection interface. You can open this interface in one of several ways:
If you use the Polyspace Platform user interface, select
Use custom checkers fileat the Defects and Coding Standards tab. Then, click
. The checkers selection window opens.If you use the Polyspace as You Code™ plugins for IDEs, you can open the Checkers selection interface from your IDE. See Configure Checkers.
If you use a command line workflow, then at the command line, enter:
Alternatively, navigate topolyspace-checkers-selection
and launch the binarypolyspaceroot\polyspace\binpolyspace-checkers-selection. Here,is the root installation folder for the Polyspace products, for instance,polyspacerootC:\Program Files\Polyspace Server\R2026a.
In the Checkers selection interface, select New. Select defect checkers and coding rules that you want enabled. Click Save Changes to save your selection as an XML file, for instance,
checkers.xml.When running a Bug Finder analysis, specify this XML file as the argument for the option
-checkers-activation-file.polyspace-bug-finder-access -sources src.c -checkers-activation-file checkers.xml
Update Checkers Activation File in Text Editor
In some cases, you might not have access to the Checkers Selection UI. For instance, you might be using Polyspace in a headless terminal. In this case, create the checkers activation XML file by using the template files in .polyspaceroot\polyspace\examples\doc_cxx\checkers_activation_XML
To activate Bug Finder defects or checkers from one of the coding standards, make a writable copy of the corresponding templates. Locate the checker by finding the node that has the correct check id attribute. Activate the checker by setting the state attribute to "on".
Alternatively, to make a custom XML that activates various coding standards and Bug Finder defects, copy the relevant entries from the corresponding coding standard and defect templates into the blank.xml template in . A checkers activation XML file that activates the Bug Finder defect polyspaceserverroot\polyspace\examples\doc_cxx\checkers_activation_XMLDATA_RACE and CERT C coding rule
CON01-C resembles this example:
<?xml version="1.0" encoding="UTF-8"?>
<polyspace_checkers_selection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="selection_schema.xsd" revision="2.0">
<standard name="Bug Finder Findings">
<section name="Concurrency">
<check id="DATA_RACE" state="on"/>
</section>
</standard>
<standard name="SEI CERT C">
<section name="Concurrency (CON)">
<check id="CON01-C" state="on"/>
</section>
</standard>
</polyspace_checkers_selection>
For a full list of coding rule check IDs, defect checker short names, and section names, see:
Note
The XML format of the checker configuration file might change in future releases.
Check Violations of User-Defined Cosing Standard
Create a new user defined coding standard and check for violations of its rules:
In a writable folder initiate a new Polyspace Query Language (PQL) project:
This command createspolyspace-query-language init
main.pqlandpql.json.Define a new user-defined coding standard in
main.pql. For example, this code defines a coding standard with a single rule:For details about creating user-defined coding standards using PQL, see Create User-Defined Coding Standard by Using Polyspace Query Language.package main // Main PQL file defines the catalog of your PQL project. // The catalog is a collection of sections. catalog IdentifierIsKeyword = { #[Description("MySection")] section mysection = { #[Description("myRule"), Id(Rule1)] rule myRule = { defect recursiveTypedef = when Cpp.PreprocDef.is(&preproc) and preproc.name(&name) and name.nodeText(&str) and Cpp.Norm.isCpp23Keyword(str) raise "C++23 keyword redefined in macro: \"{str}\"" on name } } }Create the user-defined coding standard file by packaging the PQL code:
This command creates the filepolyspace-query-language package
IdentifierIsKeyword.pschk.When running a Bug Finder analysis, specify the file
IdentifierIsKeyword.pschkas the argument for the option-checkers-activation-file.polyspace-bug-finder-access -sources src.c -checkers-activation-file
IdentifierIsKeyword.pschk
Tips
The option
-checkers-activation-fileis an improved version of a similar optionSet checkers by file (-checkers-selection-file). The improvements are the following:The option
-checkers-activation-fileis sufficient to both specify checkers and enable them. The option-checkers-selection-fileonly specifies a set of checkers for the analysis using a checkers selection file. You have to enable them separately using the valuefrom-filefor one of the coding standards options (such as-misra3or-autosar-cpp14).The option
-checkers-activation-fileenables both defect and coding standard checkers. The option-checkers-selection-filecovers coding standard checkers only. To specify and enable defect checkers, you have to then use the option-checkerswith a comma-separated list of defect checker names.
Both options
-checkers-activation-fileand-checkers-selection-filerequire an XML file with the checker specifications as argument. The XML files have the same format with the only difference coming from the fact that-checkers-activation-fileenables defect checkers in addition to coding standard checkers. The XML file for-checkers-activation-filehas this additional element:<standard name="Bug Finder Findings"> <section name="Numerical"> <check name="INT_ZERO_DIV" state="on"> <check name="INT_CONV_OVFL" state="on"> ... </section> </standard>If you use the XML generated for the option
-checkers-selection-filewith the option-checkers-activation-file, Polyspace converts the provided XML into the correct format and emits a warning.If you use an activation file generated by using a previous version of Polyspace, previously unimplemented checkers might become implemented. Polyspace warns if the file XML file lists an implemented checker as
'notimplemented'.If you use Polyspace as You Code extensions in IDEs, this option is implemented through the IDE extension setting. You do not have to use this option explicitly. If you want to explicitly use this option, enter the option in an analysis options file. See options file.
You can classify the activated checkers into custom subsets by entering specific texts in the Comment column of the Checkers selection interface. During results review, Polyspace displays the text you entered in the Results Details pane and in the Detail column of the Results List (if available). You can then sort the result into the desired subset using the entered text. For instance, say you want to specify certain checkers as
Mandatory. Enter the textMandatoryin the Comment column of the Checkers selection interface. During code review, you can isolate theMandatorycheckers by sorting the result by Comment in the Results List.Note
The custom text that you enter in the Checkers selection interface is omitted in:
Generated reports.
The Polyspace desktop interface when you open results from Polyspace Access™ in the desktop interface. This limitation applies only to Bug Finder checkers.
Command-Line Information
Parameter: -checkers-activation-file |
Value: Path to checkers activation (.XML) file or the user defined coding standard (.pschk) file. You can specify an absolute path or a path relative to the location from which you run the polyspace-bug-finder command. |
| No Default |
Example (Bug Finder):
polyspace-bug-finder -sources |
Example (Bug Finder):
polyspace-bug-finder -sources |
Example (Bug Finder Server):
polyspace-bug-finder-server -sources |
Example (Bug Finder Server):
polyspace-bug-finder-server -sources |
Example (Polyspace
as You Code):
polyspace-bug-finder-access -sources |
Example (Polyspace
as You Code):
polyspace-bug-finder-access -sources |
Version History
Introduced in R2021aSee Also
Find defects (-checkers) | polyspace-catalog-bundler
Topics
- Command Line: Configure Checkers and Coding Rules in Polyspace as You Code (Polyspace as You Code)