Contenu principal

Configure Coding Rule Checks and Code Metrics

Activate MISRA™, AUTOSAR, CERT®, and JSF® coding rule sets, custom coding rules, and code metrics

You can check for violation of coding standards and calculate coding metrics using Polyspace® Bug Finder™.

To check for coding rule violations, activate a set of coding rules and defects by using the Checkers Selection window. Save the activated set of checkers in a checkers activation file (.xml) and then use the activation file in your subsequent analyses. See Checkers activation file (-checkers-activation-file).

Alternatively, you can activate preselected sets of rules from a specific coding standard. For instance, activate the mandatory rules from MISRA C™:2023 by using the option Check MISRA C:2023 (-misra-c-2023) with the value mandatory.

You can also calculate function-level, file-level, and project-level code metrics by specifying the option Calculate code metrics (-code-metrics). This option calculates a set of code metrics such as cyclomatic complexity, comment density, or number of recursions in your project.

Polyspace Options

expand all

Use custom checkers fileSpecify that checkers must be specified using a checkers activation XML file. (Since R2023b)
Checkers activation file (-checkers-activation-file)Activate custom combination of defects and coding rules for Polyspace Bug Finder analysis
Check MISRA C:2012 (-misra3)Check for violations of MISRA C:2012 rules and directives
Use generated code requirements (-misra3-agc-mode)Check for violations of MISRA C:2012 rules and directives that apply to generated code
Check MISRA C:2023 (-misra-c-2023)Check for violations of MISRA C:2023 rules and directives (Since R2024a)
Use generated code requirements (-misra-c-2023-agc-mode)Check for violations of MISRA C:2023 rules and directives that apply to generated code (Since R2024a)
Effective boolean types (-boolean-types)Specify data types that coding rule checker must treat as effectively Boolean
Check SEI CERT-C (-cert-c)Check for violations of CERT C rules and recommendations
Check ISO/IEC TS 17961 (-iso-17961)Check for violations of ISO/IEC TS 17961 rules
Check MISRA C++:2023 (-misra-cpp-2023)Check for violations of MISRA C++:2023 rules and directives (Since R2024b)
Check MISRA C++:2008 (-misra-cpp)Check for violations of MISRA C++:2008 rules
Check JSF AV C++ (-jsf-coding-rules)Check for violations of JSF C++ rules
Check AUTOSAR C++14 (-autosar-cpp14)Check for violations of AUTOSAR C++ 14 rules
Check SEI CERT-C++ (-cert-cpp)Check for violations of CERT C++ rules
Set checkers by file (-checkers-selection-file)Define a custom set of coding standards checks for your analysis
Check CWE (-cwe)Check for weaknesses in your code that are enumerated in CWE (Since R2023a)
Check custom rules (-custom-rules)Follow naming conventions for identifiers
Check Guidelines (-guidelines)Check for violations of Guidelines
Allowed pragmas (-allowed-pragmas)Specify pragma directives that are documented
Generate results for sources and (-generate-results-for)Specify files on which you want analysis results
Do not generate results for (-do-not-generate-results-for)Specify files on which you do not want analysis results
Use fast analysis mode for Bug Finder (-fast-analysis)Run analysis using faster local mode
-create-checkersCreate new checkers for Polyspace Bug Finder analysis (Since R2023b)
Calculate code metrics (-code-metrics)Compute and display code complexity metrics
-start-level-from-oneStart counting the call level or nesting level from one.
-consider-switch-as-single-decisionCompute cyclomatic complexity assuming a switch-case statement to be a single decision point

System Commands

polyspace-catalog-bundler(System Command) Create user-defined Polyspace coding standards at the DOS or UNIX command line

Topics

Configure Checkers

MISRA Rules

CWE

User-Defined Coding Standards

Code Complexity Metrics

Polyspace Guidelines

Polyspace Custom Rules