vanniktech / gradle-android-junit-jacoco-plugin

Gradle plugin that generates JaCoCo reports from an Android Gradle Project
http://vanniktech.com
Apache License 2.0
400 stars 76 forks source link

Kotlin lambda: wrong lines count #185

Closed Tumanin closed 3 years ago

Tumanin commented 4 years ago

I use the plugin for an Android project. If in a Kotlin class there is a lambda like:

let{}
filter{}
forEach{}
firstOrNull{}

then the plugin report contains 1 more line for this class and sonarqube returns an error like:

Cannot import coverage information for file 'android-project/project/src/main/java/de/example/android/plugin/myProject/productlist/filter/adapter/FilterGroupAdapter.kt', coverage data is invalid. Error: {}
java.lang.IllegalStateException: Line 83 is out of range in the file android-project/project/src/main/java/de/example/android/plugin/myProject/productlist/filter/adapter/FilterGroupAdapter.kt (lines: 82)
        at org.sonar.api.utils.Preconditions.checkState(Preconditions.java:61)
        at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.validateLine(DefaultCoverage.java:93)
        at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.conditions(DefaultCoverage.java:107)
        at org.sonar.plugins.jacoco.ReportImporter.importCoverage(ReportImporter.java:41)
        at org.sonar.plugins.jacoco.JacocoSensor.importReport(JacocoSensor.java:79)
        at org.sonar.plugins.jacoco.JacocoSensor.importReports(JacocoSensor.java:62)
        at org.sonar.plugins.jacoco.JacocoSensor.execute(JacocoSensor.java:47)

when I remove lambda - the error is gone

vanniktech commented 3 years ago

We're just delegating to JaCoCo. So if there's a problem. Please open an issue there.