This topic explains how to prevent C++test from reporting specific static analysis violations (e.g., when you generally follow a rule, but decide to ignore that rule in an isolated number of exceptional situations). Suppression schemes can be entered in the GUI or defined directly in the source code.
Sections include:
See Suppressions.
To suppress a static analysis task that is shown in the Quality Tasks view:
The task will then be "suppressed" and removed from the Quality Tasks view. A suppression entry will be added to the Suppressions view or directly to the source code (depending on selected mode). If the same static analysis violation is found in subsequent tests of this project, it will be reported in the Suppressions view, but not in the Quality Tasks view.
Team suppressions (as opposed to in-code suppressions) are message-based and not rule-based. Suppressions prevent the reporting of a specific static analysis task (e.g., fix the violation of rule X that occurs in line Y); they do not prevent the reporting of all violations of a rule. |
When suppressions are defined in source code:
There are two ways to define suppressions in source code:
C++test allows you to define suppressions directly in the source code, using the syntax specified below.
<suppression keyword> [<rule category> | <rule category> . <rule id> | <rule category > - <rule severity> | ALL ] <suppression comment> |
//parasoft-suppress CODSTA "suppress all rules in category CODSTA" // parasoft-suppress CODSTA.NEA "suppress rule CODSTA.NEA" // parasoft-suppress CODSTA-1 "suppress all rules in category CODSTA with severity level 1" // parasoft-suppress ALL "suppress all rules" // parasoft-suppress CODSTA FORMAT.MCH JAVADOC-3 "suppress all rules in category CODSTA and rule FORMAT.MCH and all rules in category JAVADOC with severity level 3" |
<begin suppression keyword> [<rule category> | <rule category> . <rule id> | <rule category > - <rule severity> | ALL ] <suppression comment> ..... source code block ..... <end suppression keyword> [<rule category> | <rule category> . <rule id> | <rule category > - <rule severity> | ALL ] <suppression comment> |
// 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" |
The following suppresion directives are deprecated:
|
To view the suppressed messages that were reported in a subsequent test run:
The Suppression Messages view will display the following information:
To sort the Suppressions view contents by one of the column headings, click that column heading.
You can edit a suppression’s message or reason by right-clicking the suppression in the Suppressions view, choosing Edit Message or Edit Reason from the shortcut menu that opens, then modifying the message or reason in the dialog that opens. |
You can restrict which suppressions are shown in the Suppressions view by using the available suppressions filter.
To filter the suppressions shown in the Suppressions view:
To unsuppress a task:
If this same static analysis violation is found in subsequent tests of this project, the task will be reported in the Quality Tasks view.