detekt / sonar-detekt

SonarQube plugin for Kotlin
https://detekt.dev
GNU Lesser General Public License v3.0
493 stars 52 forks source link

SonarQube Not Picking Up Kotlin Coverage #83

Closed ZergHunter3000 closed 5 years ago

ZergHunter3000 commented 6 years ago

I am unable to get code coverage to appear for Kotlin files in SonarQube. The coverage reports are generated by JaCoCo, and are visible in the outputted .html documents, indicating it does recognize that my Kotlin files are covered. Yet, when running mvn sonar:sonar, only the Java coverage makes it through to SonarQube. I also see Kotlin references in the jacoco.xml file.

My properties look as such:

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <kotlin.version>1.3.0</kotlin.version>
        <kotlin.compiler.incremental>true</kotlin.compiler.incremental>

        <sonar.sources>src/main</sonar.sources>
        <sonar.tests>src/test</sonar.tests>

        <sonar.sources>src/main</sonar.sources>
        <sonar.tests>src/test</sonar.tests>
        <sonar.java.binaries>${project.basedir}\target</sonar.java.binaries>
        <sonar.kotlin.binaries>app/build/tmp/kotlin-classes</sonar.kotlin.binaries>
        <!-- Below property indicates the pattern of the test suite -->
        <runSuite>**/*Suite.class</runSuite>
        <!-- Sonar-JaCoCo properties -->
        <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
        <sonar.kotlin.coveragePlugin>jacoco</sonar.kotlin.coveragePlugin>
        <sonar.jacoco.reportPaths>${project.basedir}\target\jacoco.exec</sonar.jacoco.reportPaths>

I also am running versions: JaCoCo v0.8.2 Sonar-Kotlin v0.5.2 SonarQube 7+ (have tried 6 as well)

Any thoughts or ideas on this weird situation?

Christian-Schroeder commented 6 years ago

Hey, having the same problem here, since august there are no coverage reports anymore...

ZergHunter3000 commented 6 years ago

Update; I made it further, it wasn't properly pulling in the plugin for some reason. However, I did end up getting stuck on what seems to be an issue with detekt:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar (default-cli) on project eems-server: The rule 'DetektRuleKey(repositoryKey=detekt-kotlin, ruleKey=ConstructorParameterNaming, active=true, issue=Issue(id='ConstructorParameterNaming', severity=Style, debt=5min))' does not exist. -> [Help 1]

Still rather confusing.

I'm not sure how I progressed but now the error is with ruleKey=LongMethod. I must have something wrong with detekt I'm guessing. This is when I run sonar:sonar.

Jendrekpl commented 6 years ago

Any updates?

arturbosch commented 5 years ago

@ZergHunter3000 do you have more stacktraces for me? Hm ConstructorParameterNaming is a rather new rule (August) but should be inside version 0.5.2. A minimal kotlin project where jacoco is configured would help debugging.

arturbosch commented 5 years ago

This should be fixed in master now. Feel free to reopen if it does not work for you in the next version.

sylhare commented 5 years ago

If you have issues with Kotlin coverage not taken by sonar when having a mixed source project (java and kotlin). It might be just a gradle configuration to do: Sonarqube not picking up both Kotlin and Java Coverage gradle project