https://kotlinlang.org logo
#code-coverage
Title
# code-coverage
k

Klitos Kyriacou

03/13/2022, 7:57 PM
Wherever I call bufferedWriter(), JaCoCo complains that one of two branches is missed. I presume this is because it's an inline function that calls
writer().buffered()
which are both also inline, and the call boils down to something similar to this:
Copy code
val x = OutputStreamWriter(this)
return if (x is BufferedWriter) x else BufferedWriter(x)
Now we know that the
if
true branch will never be called in this case, so there is nothing we can do in our own code to test this branch. Is there a way to silence JaCoCo from outputing this false positive?
I thought I might try reporting this as a bug to SonarQube (which I'm using in conjunction with JaCoCo). However, since SonarQube is a product that reports bugs, any Google search for a way to report a SonarQube bug results in how to get SonarQube to generate a bug report 🤦‍♂️
m

Matthew Gast

03/13/2022, 9:07 PM
You can report here - https://community.sonarsource.com/c/bug/5 Although if there is an issue with JaCoCo there might not be much they can do. I wonder if Kover is able to handle this.
k

Klitos Kyriacou

03/13/2022, 9:55 PM
Thanks. Although it's not Sonar's fault because it's JaCoCo that's reporting the issue, I think there's nothing JaCoCo can do because it only looks at the bytecode and not the source, whereas Sonar does look at the source and matches it up with the bytecode. However, it may seem unreasonable to ask Sonar to do something about an issue that's caused by other products.
I might be wrong in thinking there's nothing JaCoCo can do about it. Looking at https://github.com/jacoco/jacoco/issues/763 , shouldn't this issue in JaCoCo have been fixed already?
8 Views