Sonarqube 10.7, scanning of test classes has changed !?

After upgrading from Sonarqube 10.5.1 to Sonarqube 10.7, the scans of some projects suddenly raised a lot of issues with scope test.

While I could not find any differences between 10.5 and 10.7 in the documentation
Narrowing the focus with an analysis scope, the property sonar.test.exclusions must now be set to exclude test classes from the scan.

i.e. with Sonarqube 10.5.1 no issues in src/test/java/com/foo/FoobarTest.java and now it has issues for java:S1130 https://rules.sonarsource.com/java/RSPEC-1130/

Is this expected behaviour or is it a bug ?

TL;DR: As of SonarQube 10.6, and around the same time for SonarCloud, we started applying some of the main rules on to test code. See the announcement for more details.

hey @anon40266202,

Is this expected behaviour or is it a bug ?

Yes, it is the expected behavior. We recently started increasing the scope of some of our rules to run on Java test code. The effort is expected to continue throughout the year, reaching around 60 rules.

In general, these rules should help everyone keep a maintainable test suite.

In particular, S1130 can be particularly useful when you are used to working with IDEs that grey out the throws Exception clause in the method signature when your test changes.

But, please let us know if you have any feedback on these changes.

Cheers,

Dorian

ok, thanks for the clarification.
This should also be noted in the documentation and release notes!
I have not found any reference to this.

2 Likes

Hi,

BTW, this was announced back in July, and initially released in 10.6:

 
HTH,
Ann

1 Like