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.

  1. Right click a violation or multiple selected violations and choose Suppress from the menu.

  2. Enter a reason for suppressing the violation and choose a suppression type when prompted.

  3. Click OK to complete the suppression.

Suppressing Findings in Source Code

To suppress the reporting of violations from a specific rule or rule category:

  1. Determine the rule ID of the rule that you want to suppress. Rule IDs are listed in the Test Configurations.
  2. Open the source code in an editor.
  3. Enter a comment (in the following format) at the line of code where you want to start the suppressing the violation:
    // parasoft-begin-suppress <RULE_ID>
    To suppress all violations in a category, list only the category part of the Rule ID. For example, use the following comment to suppress all rules in the OOP (Object Oriented Programming) category:
    // parasoft-suppress OOP
    To suppress violations of two or more rules, list both Rule IDs, separated by one or more space characters. For example. use the following comment to suppress the rules OOP.AF and OOP.OPM:
    // parasoft-suppress OOP.AF OOP.OPM
    For complete documentation on the parasoft-suppress command, see “parasoft-suppress Command Details” section below.

  4. Enter the following comment at the line of code where you want to stop suppressing the violation:
    //parasoft-end-suppress <RULE_ID>

  5. Save the modified code.

Example 1:

package examples.suppress;
public class Example {
	public int _field1;
	public int _field2;  // parasoft-suppress OOP.AF reason for suppression ...
	public int _field3;
}

Example 2:

// parasoft-begin-suppress INTER.ITT

package examples.suppress;

public class AllFileSuppress {
	public static void main(String[] args) {
		System.out.println ("line1");
		System.out.println ("line2");
	}
}
//parasoft-end-suppress INTER.ITT

In-line (in-code) suppressions will not be listed in the Suppressions view. Suppressions local to the workspace or shared by Team Server are listed in that view; in-line suppressions are listed along with the source code text.
If you want a suppression to continue through an entire file, you do not need to add a parasoft-end-suppress comment.

parasoft-suppress Command Details

Single Line Suppressions

Command

<suppression keyword> [<rule category> | <rule category> . <rule id> | <rule category > - <rule severity> | ALL ] <suppression comment>

Examples

// 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 with severity level 3"


Group Suppressions

Command

 <begin suppression keyword>  [<rule category> | <rule category> . <rule id> 
| <rule category > - <rule severity> | ALL ]  <suppression comment>
  ..... java code .....
 <end suppression keyword>  [<rule category> | <rule category> . <rule id> |
<rule category > - <rule severity> | ALL ]  <suppression comment>

Examples

// 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 start from this line"  ........
 

 

  • No labels