kotlinx-kover
kotlinx-kover copied to clipboard
Ignore specific lines, for example `require`
Require method calls that are a safeguard for implementations never will be able to be fully executed if the implementation works fine.

So I would like to mark somehow specific lines to be ignored for the coverage. Is it possible right now?
Hi, at the moment there is no way to exclude a specific line from the report.
Using an annotation filter, you can exclude lambdas, but this will not work in the case of inline functions.
Thanks @shanshin ! So maybe this could be a feature request. Not sure if a comment or something in the line above the partial line could be easily be consumed by the plugin having the source.
And thanks you guys for all the hard work! With 0.6.1, I was able to finally get it working and upload the reports to codecov!
Not sure if a comment or something in the line above the partial line could be easily be consumed by the plugin having the source.
Ignoring the line by comment (or compile-only annotations) is a planned feature, but at this stage its implementation is difficult.
Nevertheless, the overall recommendation is to test every meaningful code path and exclude only really obscure lines (the classic example of which is Java's catch (check exception) when it's statically known that the try` block never throws it)
Yeah, thats the case here. That require for example tests the correctness of the private state. Public constructors and methofs dont allow to violate that contract, so it is not possible to test that branch without mocking or reflectively change stuff. And since those are in the commonTest branch it wont be reasonably possible.
As you said I don't want to test those kind of branches for the reasons you put, but would want to skip them if possible to approach to the 100% coverage without those affecting to it.
Not a super huge deal for me, since I have lot of untested code yet, but will be appreciated if this feature is supported at some point in the future.