Main-code-only rule scope not being followed

Using SonarQube via Gradle plugin v2.7.

The “Method names should comply with a naming convention” rule is triggering in my test code even though it is scoped to main sources. In particular a common convention in Kotlin is to use ticks and have method names with spaces in them for tests, which would violate this rule if it were scoped to test files.

This is a multi-module Gradle project and only one module has tests at the moment, but that might change.

Things I’ve tried:

  • Setting the sonar.tests property in the main build.gradle file to be the explicit path to the only test directory, subproject-name/src/test.
  • Setting the sonar.tests property dynamically in a subprojects block to set the property to the subproject’s directory (if it exists).

In the code tab on the SonarCloud website it flags code smells in the test directory. Is there a signifier that would show in the web UI that Sonar recognizes the directory as a test directory? Is there a way to modify my configuration in another way that would reveal how Sonar is treating my various directories?

One other funny thing - manual analysis of the master branch from my computer does not flag these issues - only the automated PR analysis finds them. Perhaps this is just a beta problem?



Which SonarQube version do you use? Could you provide analysis logs?
Check these docs about gradle scanner, may be they will help.