Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 32 Next »

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

Installation

  1. Install the Switch Off Violations plugin through the Update Center or download it into the SONAR_HOME/extensions/plugins directory
  2. Restart the Sonar server

Configuration

Exclusion patterns can be specified at both global and project levels. Go to Configuration > General Settings > Switch Off Violations (or at project level: Configuration > Settings > Switch Off Violations) and add values to the following properties:

  • File exclusion patterns (sonar.switchoffviolations.allfile) to switch off all the violations on files that contains a block of code that matches a given regular expression.
    • Example: switch off all the violations on files containing @javax\.annotation\.Generated
  • Multi-criteria exclusion patterns (sonar.switchoffviolations.multicriteria) to switch off violations on specific resources, rules and ranges of lines.
    • Examples: 
      • Switch off all the violations (Java projects: structure = packages) => *;*;*
      • Switch off all the violations (non-Java projects: structure = folders) => **/*;*;*
      • Exclude all the violations on the Java file com.foo.Bar => com.foo.Bar;*;*
      • Exclude all the violations on the Java package com.foo => com.foo.*;*;*
      • Exclude all the violations of a specific rule => *;checkstyle:com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck;*
      • Exclude all the violations of a specific rule on a specific file => com.foo.Bar;checkstyle:com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck;*
      • Exclude all the violations on specific lines 10, 25 and 90 => com.foo.Bar;*;[10,25,90]
      • Exclude all the violations on a range of lines => com.foo.Bar;*;[10-90]
      • Exclude all the violations on several ranges of lines => com.foo.Bar;*;[10-90,92,98,120-150]
         
  • Bloc exclusion patterns (sonar.switchoffviolations.block) to switch off violations 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.
    • Example: exclude code blocks delimited by GEN-FIRST and GEN-LAST (like NetBeans auto-generated code):

Versions prior to 1.3

Icon

Set the sonar.switchoffviolations.patterns property:

Examples

Usage

Run a Sonar analysis on your project to take into account your configuration.

Change Log

Loading

Release 1.3 (2 issues)

 

Loading

Release 1.2 (3 issues)

 

Loading

Release 1.1 (1 issues)

  • No labels