A function like the following is failing our minim...
# code-coverage
k
A function like the following is failing our minimum branch coverage tests because JaCoCo thinks the function only has 50% branch coverage:
Copy code
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:
Copy code
if (this is BufferedWriter) this else BufferedWriter(this, bufferSize)
I can work around this by changing the original function to this:
Copy code
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?
a
I believe https://github.com/jacoco/jacoco/issues/654 is the issue tracking inline support on the JaCoCo side