I really got an 'overflow' trying to make these things to work together. I followed instruction from here: http://docs.sonarqube.org/display/PLUG/Android+Lint+Plugin and finally got a SonarQube 5.1.1 server with Android Lint plugin 1.1 installed. Then I configured my multi-module Gradle build to work with SonarQube plugin: see code fragment from 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 ran lint sonarqube
task to execute the analysis. As a result I got a bulk of Lint errors regarding 'retrolambda' project (java.lang.UnsupportedOperationException: Unknown ASTNode child: LambdaExpression
), which is quite normal, and lint-results.xml
(accompanied with HTML version) files per each module containing descriptions of issues discovered. The report said that there were 8 errors and 434 warnings found. But things went wrong when sonarqube plugin tried to upload the results to SonarQube server. The log was full of 'Unable to find file' and 'Unable to find rule' messages. And when the processing was over, then there were no issues reported for my project on SonarQube server.
And I am wondering, what did went wrong? I checked the paths, and all files were there. I looked through all discussions I could reach, and it seems like my config is correct and I do everything right. Does anybody have any clue, what I missed and what needs to be checked? Any suggestions or ideas are welcome.
I will be also happy if there is a way to import lint data using external SonarQube Runner, since this tool seems to be more predictable and stable then a Gradle plugin.
SonarLint catches issues right in your IDE while SonarQube analyzes pull requests and branches. The combination forms a continuous code quality analysis solution that keeps your codebase clean. You'll spend less time reviewing code issues and more time on code logic and solving interesting problems!
Access the running SonarQube instance, in my case, I'm running locally on port 9000, so I can just access it in http://localhost:9000,then login with admin as user and password. This assumes that you have already created an Android Studio project. We need to add the sonar scanner plugin and jacoco for the tests.
In Intellij — Go to File >> Plugins >> Type 'SonarLint' >> Install and Restart IDE. (2) we can choose the SonarQube rules. → To integrate SonarQube(server) and SonarLint in our IDE and run SonarQube code inspection rules per class to give results quickly. Add the sonarQube connection binding.
Android Studio provides a code scanning tool called lint that can help you to identify and correct problems with the structural quality of your code without having to execute the app or write test cases.
I had success with a multimodule android project. Since the complete build files take too much space I show the relevant parts here only.
In the parent project's build.gradle I set:
buildscript { ... dependencies { classpath 'com.android.tools.build:gradle:1.5.0' ... } plugins { id "org.sonarqube" version "1.1" }
In the app project (and any other children) I set:
sonarqube { properties { property "sonar.profile", "Android Lint" property "sonar.sources", "./src/main/java" } }
That was the minimum setup for SonarQube plugin to start analyzing the projects.
Your gradle settings seems fine, have you installed Android plugin on SonarQube server.
I don't see that step on your question, if not goto Settings->System->Update Center and install Android plugin.
Once that is installed you need to restart your SonarQube server and rerun sonar-runner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With