Scanner command used when applicable (./gradlew sonar -D…options…)
Languages of the repository: Kotlin
I’m running sonar on android project using gradle.
I’m doing that on Bitrise.
It works well, but there are couple of warnings in the log when running the sonar gradle task.
One of them is related to linting, we do not depend on android linting.
So, we need a way to exclude that lint report from Sonar.
Notice that we don’t rung gradle lint task. That’s why the lint xml report file is not generated.
How can we do that?
The error message:
Unable to import Android Lint report file(s):
- /bitrise/src/app/build/reports/lint-results-debug.xml
The report file(s) can not be found. Check that the property 'sonar.androidLint.reportPaths' is correctly configured.
Also, we got these two warnings:
No merge base found between HEAD and refs/remotes/origin/main
Could not report issue with code highlighting, using plain text instead. Check whether the product is outdated.
Hello @mahmoud, the warning happens because you’re most likely using an old version of SonarLint that doesn’t support the code highlighting feature. It is not an issue, simply the code that raises the issue won’t be highlighted.
@angelo.buono
I didn’t include the SonarLint.
I only use the sonar for gradle with version 4.2.1.3168 which is the latest version.
If the linting task is included in that version, then it must be the most up-to-date version.
Also, I did not include any other dependency for sonar linting.
How can I disable the liniting from sonar for gradle then to remove that warning?
Hello @mahmoud, there is nothing to worry about for this warning. I have created an issue to deal with it and you can check its progress at [SONARKT-365] - Jira.
The warning is raised because we assume that the highlighting feature is always available in the product, but this is not the case for Sonar Cloud. For now, you can simply ignore the warning.
I had the same warning in logs, analyzing an Android project (barely modified from the empty Empty Activity project generated by Android Studio Koala Feature Drop | 2024.1.2).
Looking at Gradle logs (obtained with eg. ./gradlew sonar --console plain), I noticed that I had the scanner’s warning:
> Task :app:lintReportDebug
Wrote HTML report to file:///home/runner/work/PyLMS/PyLMS/android/app/build/reports/lint-results-debug.html
So, I modified the build.gradle.kts of the root project (where I configure the sonar tasks) to create a dependency onto the task generated the report:
// add a dependency of sonar task onto any task lint of any subproject
// use afterEvaluate otherwise the task set is empty
val sonarTask = tasks.getByName("sonar")
subprojects {
afterEvaluate {
project.tasks.filter { it.name == "lint" }.forEach{ sonarTask.dependsOn(it)}
}
}
This removed the warning and added Android Lint issue in SonarQube/SonarCloud.