Configure Checkers for Polyspace as You Code at the Command Line
If you use an unsupported IDE, you can check for various types of defects and coding rule violations by using Polyspace® as You Code at the command line. 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 other defects and coding rule violations, configure Polyspace as You Code.
To configure checkers, create a checkers file and then specify the checkers file at the command line. For equivalent workflows in the Polyspace desktop and server, see Prepare Checkers Configuration for Polyspace Bug Finder Analysis (Polyspace Bug Finder).
Configure Checkers and Coding Rules Directly at the Command Line
When running Polyspace as You Code in an unsupported IDE, you can specify a selection of checkers and coding rules by using these analysis options with appropriate values directly at the command line:
Find defects (-checkers)
(Polyspace Bug Finder)Check MISRA C:2004 (-misra2)
(Polyspace Bug Finder)Check MISRA C:2012 (-misra3)
(Polyspace Bug Finder)Check SEI CERT-C (-cert-c)
(Polyspace Bug Finder)Check ISO/IEC TS 17961 (-iso-17961)
(Polyspace Bug Finder)Check MISRA C++:2008 (-misra-cpp)
(Polyspace Bug Finder)Check SEI CERT-C++ (-cert-cpp)
(Polyspace Bug Finder)Check AUTOSAR C++ 14 (-autosar-cpp14)
(Polyspace Bug Finder)Check JSF AV C++ rules (-jsf-coding-rules)
(Polyspace Bug Finder)Check custom rules (-custom-rules)
(Polyspace Bug Finder)Check guidelines (-guidelines)
(Polyspace Bug Finder)Check CWE (-cwe)
(Polyspace Bug Finder)
For instance, to activate the performance checkers and MISRA C:2012 coding rule, in the command line interface, run
polyspace-bug-finder-access -sources <source.c> -checkers performance -misra3 all
polyspace-results-export
(Polyspace Bug Finder).Specifying checkers and coding rule selection enables you to select predefined subsets of checkers and coding rules. To select a customized subset of checkers and coding rules, configure checkers by using a checker file.
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 Rule
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 Configuration. 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 it at the command line. See Step 2: Specify Checker File at the Command Line.
To open the Checkers selection user interface, in the command line, run:
The Checkers Selection interface opens.polyspace-checkers-selection
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 make your 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.
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.
Save the selection as a reusable checkers XML file as
and then Finish. You can later reuseCreatedCheckerFile.xml
as a value toCreatedCheckerFile.xml
Checkers activation file (-checkers-activation-file)
(Polyspace Bug Finder).
Import Checkers Configuration from Desktop Project. If you have a Polyspace desktop Project (*.psprj
) file, you can
import checker selection from it. At the command line,
run
#Linux command polyspace-checkers-selection -checkers-selection-output-file\ -import-options-from-psprj
PathToOutputFile.json
#DOS command polyspace-checkers-selection -checkers-selection-output-file
PathToProject.psprj
^ -import-options-from-psprj
PathToOutputFile.json
PathToProject.psprj
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": "", "analysis-options-file": "
PathToCreatedCheckerFile
" }
CreatedOptionsFile
PathToCreatedCheckerFile
contains the checker configurations in the Polyspace desktop project file. Step 2: Specify Checker File at the Command Line
After you obtain the checkers file, specify its full path as an argument to Checkers activation file
(-checkers-activation-file)
(Polyspace Bug Finder). For instance:
#Linux command polyspace-bug-finder-access -sources <source.c> \-checkers-activation-file
#DOS command polyspace-bug-finder-access -sources <source.c> ^
PathToCreatedCheckerFile
-checkers-activation-file
PathToCreatedCheckerFile
PathToCreatedCheckerFile
is the full path to
the 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:
Use the options in the command line. For instance, to modify the trust boundary of your analysis, in the command line, run:
You can specify multiple behavior modifying options in the command line.#Linux Command polyspace-bug-finder-access -sources <source.c>
-checkers-activation-file
\ -consider-analysis-perimeter-as-trust-boundary #DOS command polyspace-bug-finder-access -sources <source.c>CreatedCheckerFile
-checkers-activation-file
^ -consider-analysis-perimeter-as-trust-boundaryCreatedCheckerFile
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) andEffective 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 existing options file, create an options file containing the necessary options. See Options Files for Polyspace Analysis (Polyspace Bug Finder).
Related Topics
- Polyspace Bug Finder Defects Checkers Enabled by Default (Polyspace Bug Finder)
- Options Files for Polyspace Analysis (Polyspace Bug Finder)
- Checkers Deactivated in Polyspace as You Code Analysis
- Modify Default Behavior of Bug Finder Checkers (Polyspace Bug Finder)
- Run Polyspace as You Code from Command Line and Export Results