Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to analyze Android Kotlin code-coverage with SonarQube?

I have configured a Jenkins item that, after gradle building and testing, calls the "Execute SonarQube Scanner" with the following specifications:

sonar.projectKey=my_project_key
sonar.projectName=my_Android
sonar.projectVersion=1.0
sonar.sources=app/src
sonar.java.binaries=app/build/intermediates/classes/debug
sonar.coverage.exclusions=app/src/test/**,app/src/androidTest/**,app/src/main/res/**

This successfully runs SonarQube and generates a report to IPaddress:9000 that measures: Bugs, Vulnerabilities, Debt, Code Smells, and Duplications just like it is supposed to. However there is no place in this report that defines the code covered by tests. SonarQube is running the Kotlin plugin successfully and sees the codebase itself, but is not determining coverage. Is this possible to gather this information with SonarQube when using Kotlin Android?

I did try installing Jacoco, but did not see any new data on the SonarQube results.

like image 650
Don Avatar asked Nov 08 '22 12:11

Don


1 Answers

You can install a 3rd-party Sonar plugin here that will measure code quality for Kotlin projects. Unfortunately, as of this posting, SonarQube does not have its own plugin for this.

Once that is set up, take a look here for setting up gradle and sonar-project.properties. The post is a little dated, but contains a link to an updated version and is still a good starting point.

TL;DR for #2: The information SonarQube needs for Kotlin is located in 2 places. One is already identified by the OP. The other is located in app/build/tmp/kotlin-classes.

like image 72
TEK292 Avatar answered Nov 14 '22 22:11

TEK292