Versions Compared

Key

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

...

This plugin is used to exclude some violations issues in a fine-grained way. It allows to define some exclusion patterns to switch off violationsissues:

  • By rule
  • By file name/path
  • By line or range of lines
  • By file content

...

  • File exclusion patterns (sonar.switchoffviolations.allfile) to switch off all the violations issues on files that contains a block of code that matches a given regular expression.
    • Example: switch off all the violations issues on files containing @javax\.annotation\.Generated
  • Bloc exclusion patterns (sonar.switchoffviolations.block) to switch off violations issues on specific blocks of code. Note: if the first regular expression is found but not the second one, then the plugin considers that the end of the code block is the end of the file.

...

  • Multi-criteria exclusion patterns (sonar.switchoffviolations.multicriteria) to switch off violations issues on specific resources, rules and ranges of lines.
    • Examples: 
      • Switch off all the violations issues (Java projects: structure = packages) => *;*;*
      • Switch off all the violations issues (non-Java projects: structure = folders) => **/*;*;*
      • Exclude all the violations issues on the Java file com.foo.Bar => com.foo.Bar;*;*
      • Exclude all the violations issues on the Java package com.foo => com.foo.*;*;*
      • Exclude all the violations issues of a specific rule => *;checkstyle:com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck;*
      • Exclude all the violations issues of a specific rule on a specific file => com.foo.Bar;checkstyle:com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck;*
      • Exclude all the violations issues on specific lines 10, 25 and 90 => com.foo.Bar;*;[10,25,90]
      • Exclude all the violations issues on a range of lines => com.foo.Bar;*;[10-90]
      • Exclude all the violations issues on several ranges of lines => com.foo.Bar;*;[10-90,92,98,120-150]
         
Info
titleVersions prior to 1.3

Set the sonar.switchoffviolations.patterns property:

Code Block
titleExamples
languagenone
# Switch off all violationsissues (Java projects: structure = packages)
*;*;*

# Exclude a specific rule
*;checkstyle:com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck;*

# Exclude on several ranges of lines
com.foo.Bar;*;[10-90,92,98,120-150]
 
# Exclude code blocks delimited by GEN-FIRST and GEN-LAST (like NetBeans auto-generated code)
GEN-FIRST;GEN-LAST
 
# Exclude files containing "@javax.annotation.Generated"
@javax\.annotation\.Generated

Usage

...