Skip to content

Commit 3594ebd

Browse files
authored
Excluded from report companion objects with only constants
Fixes #583 PR #603
1 parent e218b3e commit 3594ebd

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22

3-
intellij-coverage = "1.0.748"
3+
intellij-coverage = "1.0.752"
44
junit = "5.9.0"
55
kotlinx-bcv = "0.13.2"
66
kotlinx-dokka = "1.8.10"

kover-features-jvm/src/main/java/kotlinx/kover/features/jvm/impl/Wildcards.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ internal fun ClassFilters.convert(): Filters {
1212
return Filters(
1313
convert(includeClasses),
1414
convert(excludeClasses),
15-
convert(excludeAnnotation)
15+
emptyList(),
16+
convert(excludeAnnotation),
17+
emptyList(),
18+
emptyList()
1619
)
1720
}
1821

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package kotlinx.kover.gradle.plugin.test.functional.cases
6+
7+
import kotlinx.kover.gradle.plugin.test.functional.framework.checker.CheckerContext
8+
import kotlinx.kover.gradle.plugin.test.functional.framework.starter.TemplateTest
9+
10+
internal class ConstantObjectTests {
11+
12+
/**
13+
* All objects that contain only constants should be excluded from the report.
14+
*/
15+
@TemplateTest("counters", ["koverXmlReport"])
16+
fun CheckerContext.testBasicCounterCases() {
17+
xmlReport {
18+
classCounter("org.jetbrains.ConstantHolder").assertAbsent()
19+
classCounter("org.jetbrains.InterfaceWithCompanion${"$"}Companion").assertAbsent()
20+
classCounter("org.jetbrains.InterfaceWithNamedCompanion${"$"}Named").assertAbsent()
21+
}
22+
}
23+
}

kover-gradle-plugin/src/functionalTest/templates/builds/counters/src/main/kotlin/Objects.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,22 @@ object UsedObjectFun {
5656
println("Hello")
5757
}
5858
}
59+
60+
object ConstantHolder {
61+
const val STRING_CONST = "STRING_CONST"
62+
const val INT_CONST = 42
63+
}
64+
65+
interface InterfaceWithCompanion {
66+
companion object {
67+
const val STRING_CONST = "STRING_CONST"
68+
const val INT_CONST = 42
69+
}
70+
}
71+
72+
interface InterfaceWithNamedCompanion {
73+
companion object Named {
74+
const val STRING_CONST = "STRING_CONST"
75+
const val INT_CONST = 42
76+
}
77+
}

kover-gradle-plugin/src/main/kotlin/kotlinx/kover/gradle/plugin/dsl/KoverVersions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public object KoverVersions {
1717
/**
1818
* Kover coverage tool version.
1919
*/
20-
public const val KOVER_TOOL_VERSION = "1.0.748"
20+
public const val KOVER_TOOL_VERSION = "1.0.752"
2121

2222
/**
2323
* JaCoCo coverage tool version used by default.

0 commit comments

Comments
 (0)