javaandroidsonarqubesonarqube5.6

SonarQube 5.6 Android Gradle


I have this buildsystem

My sonarqube.properties look like this:

 property "sonar.host.url", "http://myserver"
 property "sonar.login", "mylogin"
 property "sonar.sourceEncoding", "UTF-8"
 property "sonar.projectVersion", project.ext.sonarVersion
 property "sonar.java.source", "1.7"
 property "sonar.java.target", "1.7"
 property "sonar.sources", "src/main/java"
 property "sonar.exclusions", "src/generated/**"

 if (file("$projectDir/src/test/java").exists()) {
   property "sonar.tests", "$projectDir/src/test/java"
 }
 if (file("$projectDir/build/intermediates/classes/debug/").exists()) {
   property "sonar.java.binaries", "$projectDir/build/intermediates/classes/debug/"
   property "sonar.binaries", "$projectDir/build/intermediates/classes/debug/"
 }
 if (file("$projectDir/build/test-results/debug/").exists()) {
   property "sonar.junit.reportsPath", "$projectDir/build/test-results/debug/"
 }
 def sonarLibraries = configurations.compile.join(",")
 property 'sonar.libraries', sonarLibraries
 property 'sonar.java.libraries', sonarLibraries

 property 'import_unknown_files', true

./gradlew sonarqube -Dsonar.password=xxx runs.

But I see issues that are not issues, like "unused private constructor". This has not been an issue before I upgraded to 5.6.1 and the sonarqube plugin. It appears as if the .class files won't be inspected. Does anybody has the same issues with Gradle/SonarQube and Android?


Solution

  • This has nothing to do with your scanning method. It's about the version of the Java plugin in use. I'm willing to bet that when you upgraded SonarQube you also - advertently or inadvertently - upgraded the Java plugin too.

    Each new version of a language plugin introduces new rules and, typically, improves the underlying detection methods. Or at least that's the intent. It does happen that in taking two steps forward, they sometimes take one step back.

    If you feel you're seeing false positives (as you note in your comment) you should raise them at the SonarQube Google Group.