Main Content

Configure Checkers for Polyspace as You Code in Visual Studio Code

You can check for various types of defects and coding rule violations by using Polyspace® as You Code in Visual Studio Code. See Defects (Polyspace Bug Finder) and Coding Standards (Polyspace Bug Finder). The default analysis checks for a subset of defects. See Polyspace Bug Finder Defects Checkers Enabled by Default (Polyspace Bug Finder). To check for nondefault defects and coding rule violations, configure Polyspace as You Code extension in your IDE.

To configure checkers, create a checkers file, and then specify the checkers file in extension settings. For equivalent workflows in the Polyspace desktop and server, see Prepare Checkers Configuration for Polyspace Bug Finder Analysis (Polyspace Bug Finder).

Configure Checkers in Checkers File

To configure checkers, first select checkers in a checkers file. Then specify the checkers file in the Settings pane.

Step 1: Select Checkers and Coding Rules

To enable nondefault defects and coding rules, you might:

  • Create or modify a checkers file.

  • Import a checkers selection from a Polyspace desktop project.

Create or Modify Checkers File.  Create a new selection or modify an existing selection of checkers and coding rules in the Checker selection window. Save the new configuration in a reusable checkers file. To use an existing checkers file without modifying the checkers selection, specify a path to it in the Settings pane. See Step 2:Specify Checkers File in Extension Settings.

  1. To open the Checkers selection user interface, in the command palette, run Polyspace: Configure Checkers.

    Polyspace Checkers selection interface

  2. To create a new selection, in the Checkers Selection window, select the defect and the coding rule checkers that you want to activate. To modify an existing selection, click Browse, navigate to the existing checkers file and then modify the checkers selection.

    You can also activate predefined categories of defect checkers such as All, Default, High, Medium, and Low. See Classification of Defects by Impact (Polyspace Bug Finder). Similarly, you can activate predefined set of coding rules that are defined by their corresponding standards.

    • When selecting Guidelines > Software Complexity checkers, review their thresholds. If the default thresholds are not acceptable, specify a suitable threshold in the Threshold column. See Check guidelines (-guidelines) (Polyspace Bug Finder).

    • When selecting Custom rules, review the Pattern and Convention for the rules. See Check custom rules (-custom-rules) (Polyspace Bug Finder).

    • To create a custom coding standard classification, or to tag Bug Finder or coding rule checkers of interest, enter text in the Comment column of the Checkers selection window. Polyspace displays that text in the Results Details pane and in the Detail column of the Results List (if available) when you review results in the desktop interface, in Polyspace Access™, or in the Polyspace as You Code plugins.


      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.

  3. Save the selection as a reusable checkers XML file by clicking Save Changes. You can later reuse the checkers XML file as an input in the field Checkers file. Click Finish.

Import Checkers Configuration from desktop Project.  If you have a Polyspace desktop project file (*.psprj), you can import checkers configuration from it. In the Visual Studio Code terminal, run:

#Linux command
polyspace-checkers-selection -checkers-selection-output-file PathToOutputFile.json \
-import-options-from-psprj PathToProject.psprj

#DOS command

polyspace-checkers-selection.exe -checkers-selection-output-file PathToOutputFile.json ^
-import-options-from-psprj PathToProject.psprj
where PathToProject.psprj is the full path to the polyspace desktop project file and PathToOutputFile.json is the full path to a JSON file. The JSON file must be in a writable folder. The JSON file contains the location of the produced checkers file in this format:
        "checkers-activation-file": "GeneratedCheckersActivationFile",
        "analysis-options-file": "GeneratedAnalysisOptionFile"
The checkers file in GeneratedCheckersActivationFile contains the imported checker configurations from the Polyspace desktop project file.

Step 2:Specify Checkers File in Extension Settings

After creating the checkers file, specify the path to it in the Settings pane:

  • On the Side bar, click the Extensions button. The Extensions pane opens where your installed extensions are listed.

  • Locate Polyspace as You Code in the Extensions pane. Click Settings and select Extension Settings.

  • In the Settings pane, specify the path to the checkers file in the field Checkers File.

Modify Checkers Behavior

To modify the default behavior of Bug Finder defect checkers and coding rules, use analysis options. For a list of analysis options that modify the default checker behavior, see Modify Default Behavior of Bug Finder Checkers (Polyspace Bug Finder).

To specify analysis options in Polyspace as You Code:

  • Append the analysis options in the options file specified in the field Analysis options file. An options file is a text file with one analysis option for each line. For instance, to add the analysis options -code-behavior-specifications (Polyspace Bug Finder) and Effective boolean types (-boolean-types) (Polyspace Bug Finder), in the options file, append these lines:

    -code-behavior-specifications file1
    -boolean-types boolean1_t,boolean2_t

  • If you do not have an option file, create an option file that contains the necessary options. Specify the path to the new options file in the field Other Analysis Options. See Options Files for Polyspace Analysis (Polyspace Bug Finder).

Related Topics