Description / Features
This plugin is used to exclude some violations in a fine-grained way. It allows to define some exclusion patterns to switch off violations:
- By rule
- By file name/path
- By line or range of lines
- By file content (since version 1.2)
Installation
- Install the Switch Off Violations plugin through the Update Center or download it into the SONAR_HOME/extensions/plugins directory
- Restart the Sonar server
Configuration
The configuration of the plugin is done in the Web admin console, where you can specify the exclusion patterns in the textarea (one per line):
- Comments start with #
- Blank lines are allowed
- A line can have the following formats:
- A semi-colon separated string defining 3 parts: resource key pattern, rule key pattern and range of lines.
- A semi-colon separated string defining 2 parts: a first regular expression and a second one, which will be used to determine blocks of code for which violations must be ignored
- A single string defining a regular expression which will be used to determine files that should be ignored if they match this regular expression
Example:
# suppress all violations *;*;* # exclude the Java file com.foo.Bar com.foo.Bar;*;* # exclude a Java package com.foo.*;*;* # exclude a specific rule *;checkstyle:com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck;* # exclude a specific rule on a specific file com.foo.Bar;checkstyle:com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck;* # exclude on specific lines 10, 25 and 90 com.foo.Bar;*;[10,25,90] # exclude on a range of lines com.foo.Bar;*;[10-90] # exclude on many ranges of lines com.foo.Bar;*;[10-90,92,98,120-150] # Since 1.2: exclude code blocks delimited by GEN-FIRST and GEN-LAST (like NetBeans auto-generated code) GEN-FIRST;GEN-LAST # Since 1.2: exclude files containing "@javax.annotation.Generated" @javax\.annotation\.Generated
Changelog
| Release 1.1 (1 issues) | |||||
|---|---|---|---|---|---|
| Type | Key | Summary | Priority | Status | Resolution |
|
|
SONARPLUGINS-1202 | The plugins settings should be moved from the file based configuration to Project Setting page |
|
|
Fixed |
Labels

