squid:S00100 applied to test code through SonarLint in Android Studio

Hi,
my IDE (Android Studio 3.1.3) complains about naming conventions for methods (squid:S00100) for unit tests. The violations, however, are not shown (correct!) in SonarQube.
What mechanisms do SonarLint employ to classify code as production code or test code?

My setup:

  • Multi-module Gradle project
  • Android Gradle Plugin 3.1.3
  • SonarQube Gradle plugin 2.6.2
  • I have correctly set the parameter sonar.sources and sonar.tests (looks fine in SonarQube)

Regards
Alix

Hi Alix,

SonarLint will check the project’s structure to figure out if a file is a test or not depending whether it belongs to a content root of type “Source” or “Tests”.
If you check your Project Structure, to which content root does the file in question belongs to?

Hi Duarte,
the test class is correctly classified under “Tests”.

/ Alix

Hi @Alix

Sorry for the delay.

Are you still having this problem?

Hi @Lena
yes, it is still a problem.
I just checked.
Differences in my setup compared to my original post:

  • Android Studio 3.3
  • Android Gradle Plugin 3.2.1

I’m pretty sure that this is still a problem also with the latest versions of everything but I cannot confirm with 100% certainty at this time.

Regards
Alix

@Alix Could you tell the version of SonarLint you are using?
It will be of course better if you experiment with latest version.

Hi @Lena It seems to be working fine now in version: 4.0.2.3009 of SonarLint

My bad. It’s still a problem.

Setup:

  • com.android.tools.build:gradle:3.3.2
  • Android Studio 3.3.2
  • SonarLint 4.0.2.3009

Hello, sorry for the late reply.

I tried to reproduce with the latest versions of everything:

  • com.android.tools.build:gradle:3.5.3
  • Android Studio 3.5.3
  • SonarLint 4.4.0.14142

I did briefly see issues for rule S00100 in test files when initially opening the project, but they disappeared after running command Sync Project With Gradle Files, which correctly put the files under the Tests category.

Please feel free to bump/reopen this topic, or open a new one if you still see this issue with recent versions of SonarLint.