Suppressing Findings in the IDE
You can suppress individual instances of findings, all instances of a finding type in a file, or all findings in the file from the Findings view.
Right click a violation or multiple selected violations and choose Suppress from the menu.
Enter a reason for suppressing the violation and choose a suppression type when prompted.
- Click OK to complete the suppression.
Suppressing Findings in Source Code
C++test allows you to define suppressions directly in the source code, using the following directives embedded in C or C++ style comments:
- parasoft-suppress <ruleid> [<ruleid> ...] ["<comment>"]: Creates a suppression for the current line only (line with suppression directive)
- parasoft off: Suppresses the reporting of all static analysis violations that occur between this line of code and the end of the file.
- parasoft on: Unsuppresses the reporting of all static analysis violations that occur between this line of code and the end of the file.
- parasoft suppress/unsuppress [line <linewildcard>][class <classnamewildcard>] [file <filenamewildcard>] [item <ruleid>][type <severity>] [reason <comment>]: Creates a suppression with the desired parameters.
line *, line 10, line 50-*
class MyClass, class *
file *example.cpp, file *ex*.cpp
reason "Not relevant to my code."
The above elements (
line, class, file,etc.) can be combined together by separating each entry with a space (for example,
item * class MyClass line 10-*).
<filenamewildcard>must be specified as an absolute path to a file.
/* parasoft suppress item SECURITY-02 */
This suppresses reporting of violation SECURITY-02 for the current file, starting from the line where the suppression is located.
/* parasoft unsuppress item * class MyClass line 10-* */
This unsuppresses all items for class MyClass in the current file starting from line 10.
/* parasoft unsuppress item SECURITY-02 file *example.cpp
This unsuppresses the item SECURITY-02 in any file that is in the current compilation unit and has a file path that matches the *example.cpp file name pattern.
/* parasoft suppress all */
This suppresses all messages in the current file starting from the line where this directive was entered.
void foo(); /* parasoft-suppress SECURITY-02 */
void bar(); // parasoft-suppress SECURITY-03 "Not relevant to my code."
This suppresses item SECURITY-02 on the line with "foo" declaration and item SECURITY-03 on the line with "bar" declaration with the reason "Not relevant to my code."
/* parasoft off */
/* parasoft unsuppress line 30-45 */
This suppresses everything, then unsuppress lines 30 to 45.
- When no
itemis specified, the (un)suppression will be applied to all rules. This is equivalent to specifying
- When no
fileis specified, the (un)suppression will be applied only to the current file.
- When no
lineis specified, the (un)suppression will be applied starting from the line that contains the directive.
- To suppress files with whitespaces in their names, quotes should be used. For example:
parasoft suppress file "*file with whitespace.cpp"
- Putting a suppression with the
file *pattern in a header file makes it valid for all the files that include that header file. When no file is specified, suppression will be applied only to that header.
parasoft-suppressdirective is quite distinct from the other
parasoft on, parasoft off,and
parasoft-suppresssuppresses only the current line (the line with the directive) and uses different syntax than the other directives.