Off by behavior for source code lines with kotlin?
79 views
Skip to first unread message
Mirko Friedenhagen
unread,
Jan 25, 2017, 6:32:27 PM1/25/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jac...@googlegroups.com
Hello,
I am playing with Kotlin and tried to do a POC for a SonarQube plugin[0]
While doing this I encountered a strange behavior (at least for me)
SonarQube iterates on iSourceFileCoverage and checks that the number
of lines in iSourceFileCoverage do not exceed the number of lines of
the source code.
I developed a small sample project which should show the behavior[1]
If you look at the output the line count:
lastLine is 18 but only 17 lines are found in the source[2].
The jacoco-maven-plugin is able to render the coverage correctly[3].
Note that kotlin creates a synthetic class AppKt file for methods not
found directly in the class, i.e. the companion object and the outer
method defined in [2].
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jac...@googlegroups.com
Hi Mirko,
first of all: Nice to see you back here :-)
This seems to be an issue with the Kotlin compiler. The compiled
class file AppKt has a reference to line 18 in method outer(). See
decmpiled version below. JaCoCo simply takes this debug line
information from the class file.