Has anyone succeeded in getting either the SonarQube Community IntelliJ plugin OR the 'official' SonarQube IntelliJ plugin to show results of static code analysis in Android Studio projects?
The second of these requires Maven but the first of these is supposed to be agnostic.
Somehow I managed to run a sonarRunner on my project in the past but I can't manage to do it now. But there's not much point in getting that working again if I can't see my results in the IDE.
Short answer: yes you can using the SonarQube Community IntelliJ plugin
Long answer:
assuming you have a build.gradle like:
apply plugin: "sonar-runner"
sonarRunner {
sonarProperties {
// can be also set on command line like -Dsonar.analysis.mode=incremental
property "sonar.host.url", "http://your.sonar.server:9000"
property "sonar.analysis.mode", "incremental"
property 'sonar.sourceEncoding', 'UTF-8'
property 'sonar.language', 'java'
property 'sonar.profile', 'my_profile'
}
}
subprojects {
sonarRunner {
sonarProperties {
properties["sonar.sources"] += "src/main/java"
}
}
}
....
then you can run local sonar analysis with gradle:
$ ./gradlew sonarRunner
this will produce a sonar-report.json file:
$ cat build/sonar/sonar-report.json
Now you have everything is needed by the plugin:
After the configuration is done you can see new issues by running the SonarQube (new issues) inspection inside Intellij (Android Studio)
I have used this project for an example:
https://github.com/sonar-intellij-plugin/android-studio-example-project
and sonarqube server 4.0 with a squid only based rule set (4.4 failed to analyse a gradle project)
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