Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
titleTable of Contents

Table of Contents

If SonarQube's results are not aren't relevant, developers will push back on using it. That's why precisely configuring what to analyze for each project is a very important step. Doing so allows you to remove noise, like the issues and duplications marked on generated code, or the issues from rules that are not aren't relevant for certain types of objectobjects.

SonarQube gives you several options for configuring exactly what will be analyzed. You can


Some project modules should not be analyzed and consolidated with global project measures. For instance: sample modules, integration tests modules, etc. To exclude those modules, at the project level, go to Configuration > Settings > Exclusions > Files and set the Module Exclusions property. The format is a comma-separated list of modules: module1_to_exclude,module2_to_exclude. If a module's artifactId differs from its module name (the directory name), it is use the artifactId that should be used instead of the module name

You can also work the other way around with inclusions by setting the Module Inclusions property to a list of only those modules you want analyzed. Be careful: the root project must be added to the list.

Known limitation in .NET: this property does not currently work while the "sonar.dotnet.key.generation.strategy" is set to "safe". See SONARDOTNT-10.

File Suffixes

Most language plugins offer a way to restrict the scope of analysis to files matching a set of extensions. Go to Settings > General Settings > LanguagePlugin and set the File suffixes property:


It is possible to exclude specific files from being analyzedanalysis. At the project level, go to Configuration > Settings > Exclusions > Files and set the:

  • sonar.exclusions property to exclude source code files
  • sonar.teststest.exclusions property to exclude unit test files

Global exclusions that will apply to all projects can also be set. Go to Settings > General Settings > Exclusions > Files and set the and properties.

Since version 3.5, you can also work the other way around by setting inclusions. Go to Settings > General Settings > Exclusions > Files and set the sonar.inclusions and sonar.test.inclusions properties to the list of files that should be analyzed. If you set an inclusion, then only the files or modules listed there will be included in the analysis.

 See the Patterns section for more details on the syntax.

Ignore Issues

You can have SonarQube ignore issues on certain components and against certain coding rules. Go to Configuration > Settings > Exclusions > Issues.

Note that the properties below can only be set through the web interface because they are multi-valued.

Ignore Issues on Files

You can ignore all issues on files that contain a block of code matching a given regular expression.


Restrict Scope of Coding Rules

You can restrict the application of a rule to only certain components, ignoring all others.


  • I only want to check the rule Magic Number on Bean objects and not on anything else =>;**/*
  • I only want to check the rule Prevent GO TO statement from transferring control outside current module on COBOL programs located in the directories bank/creditcard and bank/bankcard => this one requires two criteria to define it:
    • COBOL.GotoTransferControlOutsideCurrentModuleCheck;bank/creditcard/**/*
    • COBOL.GotoTransferControlOutsideCurrentModuleCheck;bank/bankcard/**/*


To do so, go to Settings > General Settings > Exclusions > Duplications and set the Duplication Exclusions property. See the Patterns section for more details on the syntax.


You can prevent some files from being taken into account for code coverage by unit tests and integration tests.

To do so, go to Settings > General Settings > Exclusions > Code Coverage and set the Coverage Exclusions property. See the Patterns section for more details on the syntax.



Paths can be defined either as either relative or absolute. Use relative paths whenever possible.are relative to the project base directory.

The following wildcards can be used in either kind of path:

*zero or more characters
**zero or more directories
?a single character



Relative paths are based on the fully qualified name of the component (like the ones one displayed in the red frames frame below):

Image Removed

Image Added


titleFor versions prior to 4.2
Note that for Java




, the fully qualified name is not exactly the one that is displayed. You have to replace the "." package separator with "/" and add the ".java" extension.



Code Block
# Exclude all classes ending by "Bean"
# Matches org./sonar.api./, org./sonar./util./, org./sonar./util./, etc.

# Exclude all classes in the "org.src/main/java/org/sonar" packagedirectory
# Matches org.sonar.src/main/java/org/sonar/, org.sonar.src/main/java/org/sonar/
# But does not match org.sonar.util.src/main/java/org/sonar/util/

# Exclude all COBOL programs in the "bank" directory and its sub-directories
# Matches bank/ZTR00021.cbl, bank/data/CBR00354.cbl, bank/data/REM012345.cob
# Exclude all COBOL programs in the "bank" directory and its sub-directories whose extension is .cbl
# Matches bank/ZTR00021.cbl, bank/data/CBR00354.cbl

Absolute Path

To define an absolute path, start the pattern with "file:"

Code Block
# Exclude all the *.cs files included in /path_to_my_project/myProject/src/generated and its subdirectories
# Exclude all the java classes contained in a src/generated/java directory and its subdirectories