Vladimir Voitekhovski
Vladimir Voitekhovski

Reputation: 1602

Sonar Android Lint no matching issues found

I have got the following trouble: I have installed SonarQube and Android Plugin with "Android Lint" Quality Profile. When I execute my build.gradle script with "Android Lint" profile, sonar-runner plugin works good, but in SonarQube I can see no matching issues found, just zero.

Nevertheless, when I include another profile –not "Android Lint"– I can see a lot of issues. Also in my android SDK when apply it's own lint I can see 157 issues. What it can be?

sonar - version 3.7.4;
android plugin - version 0.1

Upvotes: 5

Views: 2164

Answers (3)

Amal p
Amal p

Reputation: 3052

change your sonar properties like this:

apply plugin: "org.sonarqube"

sonarqube {

properties {

    property "sonar.projectName", "appa"

    property "sonar.projectKey", "appa_app"

    property "sonar.projectVersion", "1.0"

    property "sonar.analysis.mode", "publish"

    property "sonar.language", "java"

    property 'sonar.sourceEncoding', "UTF-8"

    property "sonar.sources", "./src/main"

    //property "sonar.exclusions", "**/*Entity.java"

  //  property "sonar.exclusions", "src/main/java/com/apparkb/model/**, **/*Entity.java"

    property "sonar.host.url", "http://192.168.21.33:9000"

    property "sonar.login", "admin"

    property "sonar.profile", "testlint"//use your quality profile instead

    property 'sonar.import_unknown_files', true

    property "sonar.android.lint.report", "./build/outputs/lint-results-debug.xml"

    property "sonar.password", "admin"

    property "sonar.java.binaries", "build/"



}
}

For creating lint-results-debug.xml you will have to run the below command on studio terminal:

./gradlew lint

It will generate the missing XML report. Be carful, it can generate a report for each build variant (Debug by default will generate build/outputs/lint-results-debug.xml). So you can call lintDebug, lintRelease... dependings on your build variant.

And change the lint properties to:

lintOptions { // set to true to turn off analysis progress reporting by lint

    quiet true

    // if true, stop the gradle build if errors are found

    abortOnError false

    // do not ignore warnings

    warningsAsErrors true
}

now if you run

./gradlew sonarqube

you will get the results shown its actually the local file report that's actually getting hosted upon the serverenter image description here

Upvotes: 1

Eric Miles
Eric Miles

Reputation: 141

Unfortunately if you merely point sonar.sources to src/main, you're going to get issues with all your source because you most likely don't mave minSdkVersion and targetSdkVersion set (it comes from gradle). I've tried setting my source to be some thing like:

build/intermediates/bundles/release,src/main/java

But I still get an inordinate amount of (invalid) errors due to API levels.

Upvotes: 0

Artur Stepniewski
Artur Stepniewski

Reputation: 1491

Your sonar.sources property should point to the root of AndroidManifest.xml file. E.g. if your AndroidManifest.xml file is located in src/main then your build.gradle file should contain:

sonarRunner {
    sonarProperties {
        ...
        property "sonar.sources", "src/main"
        property "sonar.profile", "Android Lint"
        ...
    }
}

If you need more paths in sonar.sources you can put them as a comma-separated list.

You can find how Sonar Android Plugin determines whether to run the analysis in its source code.

Upvotes: 3

Related Questions