It is very important that SonarQube does not provide too much noise. Otherwise development teams would push back the tool.
That's why configuring Exclusions is an important step when setting up a project into SonarQube.
Here are a few use cases you can achieve with exclusions:
- Exclude generated files => Indeed, it is useless to analyze such code as you don't have any way to fix issues that would be raised
- Don't check some rules on specific objects => For example, you may to use hard coded value to define some types of objects, but you still want to forbid the usage of hardcoded value everywhere else
Excluding specific files from being analyzed
Each language plugin offers a way to restrict analysis to files matching a set of extensions.
It is possible to exclude files from being analyzed. Go to Configuration > Settings > Exclusions and set the
- Exclude tests file from being analyzed: go to Configuration > Settings > Exclusions and set the
- Set global exclusions that will apply to all the projects: go to Settings > General Settings > Exclusions and set the
Since version 3.5, it is also possible to:
- Set the files to be analyzed through the
sonar.test.inclusionsproperties. In this case, only these specific files will be analyzed.
- Exclude some files from being checked against duplications. To do so, set the
sonar.cpd.exclusionsproperty (Configuration > Settings > Duplications).
Full documentation is available directly in the SonarQube web interface (Configuration > Settings > Exclusions).
Excluding coding rule checks on specific objects
Excluding specific files to be checked for duplications