Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Introduction

You can prevent C/C++test from test from reporting specific static analysis findings by defining suppressions. Suppressions are useful when you generally follow a rule, but decide to ignore specific occurrences of the reported finding. If you do not want to receive findings for any violations of a specific rule, disable the rule in the test configuration.Suppression schemes can be defined in source code or in a suppression file

Info
iconfalse

If you are using the MISRA Compliance Pack for DTP, see the DTP User Guide to learn more about how suppressions are handled by MISRA compliance reporting on DTP.

Defining Suppressions in Source Code

...

Code Block
// parasoft-begin-suppress CODSTA "begin suppress all rules in category CODSTA"
.....
// parasoft-end-suppress CODSTA "end suppress all rules in category CODSTA"

// parasoft-begin-suppress CODSTA.NEA "begin suppress rule CODSTA.NEA"
.....
// parasoft-end-suppress CODSTA.NEA "end suppress rule CODSTA.NEA"
 
// parasoft-begin-suppress CODSTA-1 "begin suppress all rules in category CODSTA with severity level 1"
......
// parasoft-end-suppress CODSTA-1 "end suppress all rules in category CODSTA with severity level 1"

//parasoft-begin-suppress ALL "begin suppress all rules"
.....
// parasoft-end-suppress ALL "end suppress all rules"

// parasoft-begin-suppress CODSTA FORMAT.MCH "begin suppress all rules in category CODSTA and rule FORMAT.MCH"
.....
// parasoft-end-suppress CODSTA FORMAT.MCH "end suppress all rules in category CODSTA and rule FORMAT.MCH"

// parasoft-begin-suppress CODSTA "begin suppress all rules in category CODSTA"
.....
// parasoft-end-suppress CODSTA-1 "end suppress all rules in category CODSTA with severity level 1; however rules with severity level 2-5 in category CODSTA are still suppressed."
.....
// parasoft-end-suppress CODSTA "end suppress all rules in category CODSTA"
 
// parasoft-begin-suppress ALL "begin suppress all rules"
.....
// parasoft-end-suppress CODSTA FORMAT-1 "end suppress all rules in category CODSTA and all rules in category FORMAT with severity level 1; however, others rules in CODSTA and FORMAT-1 are still suppressed."
.....
// parasoft-end-suppress ALL "end suppress all rules"
 
//parasoft-begin-suppress ALL "begin suppress all rules, since no end suppression comment, all rules will be suppressed starting from this line"

Anchor
In-file Suppressions Format
In-file Suppressions Format
Defining Suppressions in Suppression Files

You can suppress the reporting of selected findings by creating parasoft.suppress files that specify the attributes of findings you want to suppress. A suppression file should be located in the same directory as the source file that contains the findings.

...

  • It is a good practice to specify the reason for suppression.
  • The line attribute should be used with caution as it may invalidate the suppression if the code is moved to another line when the source file is modified.

Anchor
Defining Line Suppressions Based on Regex Patterns
Defining Line Suppressions Based on Regex Patterns
Defining Line Suppressions Based on Regex Patterns

You can configure C/C++test to automatically suppress static rule violations that are detected on lines that match a regular expression pattern. This may be useful when you want to suppress tasks findings that are difficult to suppress using the in-line or in-code suppressions, such as  Qt macros.

...