Using sonar.test.exclusions with Sonarqube 6.3

I am currently evaluating Sonarqube 6.3 (a big update from my current 5.5 instance) and I am confused trying to work out the functionality of the sonar.test.exclusions parameter .. p>

Here's the question: Sonar Maven Plugin: How can I exclude the test sources source directories? which seems to indicate that it is being used to exclude test files from analysis (which is what I need - I don't want my sonar ruleset to work on my unit tests). The documentation https://docs.sonarqube.org/display/SONAR/Narrowing+the+Focus also indicates that it is used to "exclude unit test files" (maybe this could be extended to make it clearer?)

The thing is, when I add sonar.test.exclusions with the value ** / src / test / ** and then run my analysis, I still get code smells and the like. found for:

  • Foo / src / test / java / foo / bar / BarTest.java
  • Foo / src / test / java / l / LahTest.java

and etc.

When I use sonar.exclusions , they are not displayed. Why is sonar.test.exclusions not doing what I expect?

+3


source to share


1 answer


First of all: if you have a Maven project, you must use a scanner for Maven ( mvn sonar:sonar

). This will simplify your configuration and will automatically register the src / test / java folder as your test directory.

Now, if you want to do a manual setup or understand what's going on under the hood, here's an explanation: the SonarQube scanner works with two sets of files, main and test. The main source files are configured using the property sonar.sources

. Test source files are configured using sonar.tests

.



In addition, you can filter some content using the sonar properties. [test.] exceptions.

In your case, your problem is what Foo/src/test/java/foo/bar/BarTest.java

appears to be the main source file. Therefore sonar.test.exclusions

it has no effect.

+7


source







All Articles