Open hanrw opened 3 months ago
We will consider adding similar filters in the future.
But could you describe your case in more detail, for what purpose do you have methods with default implementation in interfaces, but it is acceptable for you not to use them?
I discovered the issue after introducing Koin(https://github.com/InsertKoinIO/koin) as the dependency injection framework in my project. and found the interface KoinComponent has a default implementation.
Do I understand correctly that the KoinComponent
interface does not belong to your project and you did not write it?
In this case, you should exclude it from the reports.
The collection of coverage is primarily aimed at finding unused code that the project developer wrote. If any external dependencies are appeared in the report, they should be completely exclude (because the code from external dependencies is not controlled by the developer).
yes. you are right. but i have my own code which extends external code like KoinComponent
for this case is there better solution from your point of view?
let's say for the class AnthropicConfig I had covered call cases but the kover report that there's something that not cover yet.
let's say for the class AnthropicConfig I had covered call cases but the kover report that there's something that not cover yet.
could you provide an XML report, at least part with class AnthropicConfig
coverage?
The report you provided is generated using codecov, we do not control it directly, it may have its own rules for calculating coverage
Here you go build.gradle.kts
kover {
reports {
filters {
excludes {
classes(
"com.tddworks.**.*\$*$*", // Lambda functions like - LemonSqueezyLicenseApi$activeLicense$activationResult$1
"com.tddworks.**.*\$Companion", // Lambda functions like - LemonSqueezyLicenseApi$activeLicense$activationResult$1
"*.*\$\$serializer", // Kotlinx serializer)
)
// inheritedFrom("org.koin.core.component.KoinComponent")
// annotatedBy("kotlinx.serialization.Serializable")
}
includes {
classes("com.tddworks.*")
}
}
verify {
rule {
bound {
minValue = 82
}
}
}
}
}
report xml
<package name="com/tddworks/anthropic/api">
<class name="com/tddworks/anthropic/api/AnthropicConfig" sourcefilename="AnthropicConfig.kt">
<method name="getKoin" desc="()Lorg/koin/core/Koin;">
<counter type="INSTRUCTION" missed="2" covered="0"/>
<counter type="BRANCH" missed="0" covered="0"/>
<counter type="LINE" missed="1" covered="0"/>
</method>
<method name="<init>" desc="(Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;)V">
<counter type="INSTRUCTION" missed="0" covered="24"/>
<counter type="BRANCH" missed="0" covered="0"/>
<counter type="LINE" missed="0" covered="3"/>
</method>
<counter type="INSTRUCTION" missed="2" covered="24"/>
<counter type="BRANCH" missed="0" covered="0"/>
<counter type="LINE" missed="1" covered="3"/>
<counter type="METHOD" missed="1" covered="1"/>
</class>
and you can also found from - app.codecov.io
Thanks.
It's bug in Kover reporter.
Reproducer
interface Parent {
fun getFoo(): String = "foo"
}
data class Child(
val s: () -> String = { "Text" },
) : Parent
report
<class name="org/jetbrains/kover/android/test/Child" sourcefilename="Extensions.kt">
<method name="<init>" desc="(Lkotlin/jvm/functions/Function0;)V">
<counter type="INSTRUCTION" missed="8" covered="0"/>
<counter type="BRANCH" missed="0" covered="0"/>
<counter type="LINE" missed="1" covered="0"/>
</method>
<method name="getFoo" desc="()Ljava/lang/String;">
<counter type="INSTRUCTION" missed="2" covered="0"/>
<counter type="BRANCH" missed="0" covered="0"/>
<counter type="LINE" missed="1" covered="0"/>
</method>
<counter type="INSTRUCTION" missed="10" covered="0"/>
<counter type="BRANCH" missed="0" covered="0"/>
<counter type="LINE" missed="2" covered="0"/>
<counter type="METHOD" missed="2" covered="0"/>
</class>
Kotlin 1.9.23
and 2.0.0
, intellij reporter 1.0.752
thx.
It's nice to have a filter for excluding the interface which has a default implementation E.g
Check here
the cover is not covered unless added a ut like below