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 9 Next »

If SonarQube provides developers information with too much noise (Issues on generated code => Indeed, it is useless to analyze such code as you don't have any way to fix issues that would be raised, Issues that are not relevant in the context => For example, you may want to allow the usage of hard coded values for some objects, but you still want to forbid this usage everywhere else, etc.), they'll likely push back the tool. That's why configuring Exclusions / Inclusions is an important step when setting up a project into SonarQube.

Exclusions on Files

Source Directory

Properly set the sonar.sources property to limit source code analysis to what the team can work on (do not analyze third-party tools source code for example).

File Suffixes

Each language plugin offers a way to restrict analysis to files matching a set of extensions. Go to Settings > General Settings > LanguagePlugin and set the sonar.xxx.file.suffixes property:

Excluding Files

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

  • sonar.exclusions property to exclude source code files
  • sonar.tests.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 and set the sonar.global.exclusions and sonar.global.tests.exclusions properties.

Since version 3.5, you can also work the other way around by setting inclusions. Go to Settings > General Settings > Exclusions and set the sonar.inclusions and sonar.test.inclusions properties.

There are two different ways to set those properties:

  • Fully qualified name of the component (see red frames below):

    For Java only, replace '.' package separator by '/' and add '.java' extension.

    Examples



  • Absolute path:

    Examples

Full documentation is available directly in the SonarQube web interface (Configuration > Settings > Exclusions).

Exclusions on Coding Rules

 

 

Exclusions on Duplications

  • Exclude some files from being checked against duplications. To do so, set the sonar.cpd.exclusions property (Configuration > Settings > Duplications).

Exclusions on Code Coverage

  • No labels