Codecoverage with Jacoco fails

Hi

I am running into issues using the coverall maven plugin, together with jacoco reports on Kotlin files.

My understanding of what happens is quite limited and based on guess work. From what I understand the class files produced by Kotlin seem to be “not strict enough” in their debug data for jacoco… whatever that means.

Basically jacoco is reporting a source file line number that is greater than the source file, which results in an exception text like this:

[ERROR] Failed to execute goal org.eluder.coveralls:coveralls-maven-plugin:4.1.0:report (default-cli) on project BinaryDataParser: Build error: Line number 91 is greater than the source file bdp-processor/src/main/java/org/ak80/bdp/MappedClass.kt size → [Help 1]

It seems similiar (same?) problems have been experienced with jacoco+coverall+scala, see for example: Line number N is greater than the source file X size · Issue #98 · trautonen/coveralls-maven-plugin · GitHub

I really would like to get code coverage reports… Is there anything I can do to get this working? Is there maybe an issue I can help with?

I really love to work with Kotlin, and this is the first and only mishap I had so far. Would be great to get it sorted out.

Thanks and with regards
Alex

1 Like

Anyone got any idea on how to either start understanding what goes wrong and how it could be fixed or who could help with this please?

The Kotlin compiler uses line numbers beyond the file length to denote inlined functions. It has to do that as java debug information only allows specifying a single source file per class. I haven’t checked it, but I suspect that the compiler also injects a nonstandard section with the additional mapping information. The Kotlin tools then use the combination to revert to a true file:line combination for the code. For a coverage checker you would have to make it aware of the section or at least make it not crash on out of bounds line numbers.

1 Like

Thank you for taking the time to reply. This helps a lot for understanding how to approach this, although I feel this is to big a challenge for me… Anyway, I appreciate your reply and wish a happy new year