Klitos Kyriacou
12/13/2022, 5:04 PMfun 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?Alex Vanyo
12/13/2022, 5:37 PM