A function like the following is failing our minimum branch coverage tests because JaCoCo thinks the function only has 50% branch coverage:
fun foo(os: OutputStream) {
os.bufferedWriter().use {
...
}
}
There is not a single
if
or other branch in this function, yet JaCoCo says the test has only covered 50% of the branches. This is because
bufferedWriter()
is an inline function that expands to
writer().buffered()
, and in turn
buffered()
is an inline function that expands to this:
if (this is BufferedWriter) this else BufferedWriter(this, bufferSize)
I can work around this by changing the original function to this:
BufferedWriter(os.writer()).use {
...
}
But I don't like changing perfectly good code into something less readable just to satisfy some static analyzer. Is there perhaps an existing issue raised to fix this?