Analysis of an Android project with Lint and SonarQube

I really have an overflow trying to get these things to work together. I followed the instructions from here: http://docs.sonarqube.org/display/PLUG/Android+Lint+Plugin and finally got the SonarQube 5.1.1 server with the Android 1.1 Lint plugin installed. Then I configured my multi-module Gradle construct to work with the SonarQube plugin: see the code snippet from the root config below.

plugins { id 'org.sonarqube' version '1.0' } sonarqube { properties { property 'sonar.host.url', 'sonarqube-server:9000' property 'sonar.jdbc.url', 'jdbc:mysql://sonarqube-db:3306/sonar?useUnicode=true&characterEncoding=utf8' property 'sonar.jdbc.driverClassName', 'com.mysql.jdbc.Driver' property 'sonar.jdbc.username', 'sonar' property 'sonar.jdbc.password', 'sonar' property 'sonar.sourceEncoding', 'UTF-8' property 'sonar.login', 'admin' property 'sonar.password', 'admin' property 'sonar.profile', 'Android Lint' property 'sonar.import_unknown_files', true property 'sonar.android.lint.report', 'build/outputs/lint-results.xml' } } 

And after that I completed the lint sonarqube task to do the analysis. As a result, I got a lot of Lint errors regarding the retrolambda project ( java.lang.UnsupportedOperationException: Unknown ASTNode child: LambdaExpression ), which is quite normal, and the lint-results.xml files (along with the HTML version) for each module containing descriptions of the problems found . The report says there were 8 errors and 434 warnings were found. But everything went wrong when the sonarqube plugin tried to upload the results to the SonarQube server. The log was filled with the messages "Could not find file" and "Could not find rule." And when the processing was over, then there was no problem for my project on the SonarQube server.

And I wonder what went wrong? I checked the paths and all the files were there. I looked through all the discussions that I could reach, and it seems that my configuration is correct, and I am all right. Does anyone know what I missed and what needs to be checked? Any suggestions or ideas are welcome.

I will also be glad if there is a way to import lint data using the external SonarQube Runner, as this tool looks more predictable and stable than the Gradle plugin.

+50
java android android-gradle gradle sonarqube
Aug 12 '15 at 15:23
source share
2 answers

I have had success with an Android multi-module project. Since complete assembly files take up too much space, I only show the relevant parts.

In the parent build.gradle project, I install:

 buildscript { ... dependencies { classpath 'com.android.tools.build:gradle:1.5.0' ... } plugins { id "org.sonarqube" version "1.1" } 

In the application project (and any other child elements), I installed:

 sonarqube { properties { property "sonar.profile", "Android Lint" property "sonar.sources", "./src/main/java" } } 

This was the minimum setting for the SonarQube plugin to begin analyzing projects.

+6
Nov 24 '15 at 23:45
source share

The gradle settings seem fine if you installed the Android plugin on the SonarQube server.

I do not see this step on your question if I have not received Settings-> System-> Update Center and install the Android plugin.

enter image description here

Once this is installed, you need to restart the SonarQube server and restart the sonar.

+1
Sep 21 '15 at 6:57
source share



All Articles