bsky
bsky

Reputation: 20242

Excluding files from Sonarqube

I'm trying not to analyse test files with Sonarqube.

I have several Maven subprojects and the test files are under these paths:

subproject1/src/test/, subproject2/src/test/ and so on

I'm passing the following option from Maven:

-Dsonar.exclusion=src/test/**

However, the test files are still analysed.

I also tried:

-Dsonar.exclusions=**/src/test/**,**/test/*,subproject1/src/test/**,**/*Spec.scala

But issues are still raised on test code.

Upvotes: 1

Views: 7607

Answers (1)

G. Ann - SonarSource Team
G. Ann - SonarSource Team

Reputation: 22824

There is no property by the name sonar.exclusion. sonar.exclusions is a valid property, but it applies to source files. You're trying to exclude test files - and yes the scanners do make the distinction, especially for Maven projects.

You should use instead sonar.test.exclusions

If you want to omit only certain rules, you have two options:

  • remove the rule from your profile
  • use Administration > Analysis Scope > Ignore Issues on Multiple Criteria to turn the rule off for only a subset of files.

Upvotes: 3

Related Questions