Disabling android lint check

Hello!

Is it possible to disable the lint results check during the execution of the sonar task? My logs are filled with errors about missing lint results, but I don’t need them, as I’m using sonar only for coverage.

No issues information will be saved as the report file '/bitrise/src/{{redacted}}/build/reports/lint-results-debug.xml' can't be read.

java.io.FileNotFoundException: /bitrise/src/{{redacted}}/build/reports/lint-results-debug.xml (No such file or directory)

I’m using the sonar gradle plugin (v 4.2.1.3168).

Hi,

Analysis doesn’t look for lint reports by default. It sounds like your analysis configuration includes parameters for reports that don’t exist. You should take a look at properties with sonar.* names.

 
HTH,
Ann

The only sonar properties I’m using are:

        property("sonar.projectKey", "NAME")
        property("sonar.host.url", "URL")
        property("sonar.token", "TOKEN")
        property("sonar.core.codeCoveragePlugin", "jacoco")
        property(
            "sonar.coverage.jacoco.xmlReportPaths",
            "${project.buildDir}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"
        )
        property(
            "sonar.coverage.exclusions",
            coverageExcludeFiles.joinToString(separator = ",")
        )

Hi,

What plugins is your server running? It looks like this might be the default report path for the Sonar Android plugin. If none of your projects are passing in these reports, your best option is to just remove the plugin. If some are using it and you want to remove the log lines from the other projects’ analyses, I suppose you could try passing in an empty report…?

 
HTH,
Ann

I’m using a docker image from the documentation:
https://docs.sonarqube.org/latest/try-out-sonarqube/

Hi,

I’m not sure what to tell you. That really looks like it’s coming from the Sonar Android plugin. As I said, while you can import linter reports into your analysis, we don’t look for them by default. On the other hand, it’s fairly common for plugins to look for their reports by default.

 
Ann

I can provide a sample repo where the same issue occurs:

on sonarqube instance from: https://docs.sonarqube.org/latest/try-out-sonarqube/

Hi,

I don’t have a Gradle background. I was unable to get started with this project.

* Where:
Build file '/home/anncampbell/testProjects/java/sonarissues/buildSrc/build.gradle.kts' line: 2

* What went wrong:
Plugin [id: 'org.gradle.kotlin.kotlin-dsl', version: '2.1.6'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:2.1.6')
  Searched in the following repositories:
    Gradle Central Plugin Repository

I tired looking at the project files, but they don’t seem to match up to what’s in the SonarQube docs about analyzing with Gradle.

 
Ann

It is the same repo used at:

I didn’t have any trouble running that on different machines. Maybe @Margarita_Nedzelska can help with that, as she seems to be able to run the sample?

Can I ask once again to verify how I can disable the lint check? I’ve migrated from SonarQube to SonarCloud, and errors are still visible.

Hi,

It seems that lint-results-debug.xml has something to do with AndroidLint? We don’t import that (or look for reports) by default. There seems to be a sonar.androidLint.reportPaths property specified somewhere.

I suggest you start by adding sonar.scanner.dumpToFile=[path to file] to see the full list of analysis parameters passed in to the Scanner. From there you can sort out where on your side this one is coming from.

 
Ann

It seems that SonarScanner for Gradle plugin is adding those paths.

2 Likes

Hi,

Thanks for digging that up. Clearly, I was wrong.

I’m going to flag this for other eyes.

 
Ann

Hello @Jakub_Mosakowski,

As far as I can see from the code here this property is added only if you have an AndroidLintTask and XML report output file is present.

I’m not an Android expert, so I think I need a bit more input here about your case:

Is it that you don’t use AndroidLint and that’s why you don’t have reports, but for some reason, the task is there and the property is automatically set or you’re actually using AndroidLint but you execute a sonar task before the AndroidLint report is generated and that’s why you get an error.

Looking forward to your answer.

Regards,
Margarita

The problem is that (I think) all Android projects have a lint task present, however not everyone is running it.

Running lint is not obligatory, however, the plugin always sets the directory as the lint task is always present (which does not mean it has ever been run).

2 Likes

Hello @Jakub_Mosakowski,

We’re currently working on improving the Gradle UX for Android projects. At the moment you need to skip this task with ./gradlew sonar -x lint

Let me know if this doesn’t help.

Regards,
Margarita

2 Likes

I have the same issue.
I want to remove the lint error when running sonar gradle task.
That’s clear that it’s handled in the sonar cloud task.

I think the solution is to skip the linting work by default, and enable it if user enable it by applying a sonar config/property.

however, I tried using ./gradlew sonar -x lint , but that does not work for me.

@Jakub_Mosakowski Did you manage to make it work?

2 Likes

Same here. I am getting “Unable to import 1 Android Lint report file(s).” warning and would like to get rid of it. However ./gradlew sonar -x lint does not work and warning is still present.

1 Like

Me too

1 Like

Hello, is does this issue get escalated to next release ? since i’m getting this problem too and it increases the scan time 300% compared to previous version. It’ll be great if we have the option to turn off lint scans.