Skip to content

Commit

Permalink
Excluded from report companion objects with only constants
Browse files Browse the repository at this point in the history
Fixes #583
PR #603
  • Loading branch information
shanshin committed May 3, 2024
1 parent e218b3e commit 3594ebd
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]

intellij-coverage = "1.0.748"
intellij-coverage = "1.0.752"
junit = "5.9.0"
kotlinx-bcv = "0.13.2"
kotlinx-dokka = "1.8.10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ internal fun ClassFilters.convert(): Filters {
return Filters(
convert(includeClasses),
convert(excludeClasses),
convert(excludeAnnotation)
emptyList(),
convert(excludeAnnotation),
emptyList(),
emptyList()
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package kotlinx.kover.gradle.plugin.test.functional.cases

import kotlinx.kover.gradle.plugin.test.functional.framework.checker.CheckerContext
import kotlinx.kover.gradle.plugin.test.functional.framework.starter.TemplateTest

internal class ConstantObjectTests {

/**
* All objects that contain only constants should be excluded from the report.
*/
@TemplateTest("counters", ["koverXmlReport"])
fun CheckerContext.testBasicCounterCases() {
xmlReport {
classCounter("org.jetbrains.ConstantHolder").assertAbsent()
classCounter("org.jetbrains.InterfaceWithCompanion${"$"}Companion").assertAbsent()
classCounter("org.jetbrains.InterfaceWithNamedCompanion${"$"}Named").assertAbsent()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,22 @@ object UsedObjectFun {
println("Hello")
}
}

object ConstantHolder {
const val STRING_CONST = "STRING_CONST"
const val INT_CONST = 42
}

interface InterfaceWithCompanion {
companion object {
const val STRING_CONST = "STRING_CONST"
const val INT_CONST = 42
}
}

interface InterfaceWithNamedCompanion {
companion object Named {
const val STRING_CONST = "STRING_CONST"
const val INT_CONST = 42
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public object KoverVersions {
/**
* Kover coverage tool version.
*/
public const val KOVER_TOOL_VERSION = "1.0.748"
public const val KOVER_TOOL_VERSION = "1.0.752"

/**
* JaCoCo coverage tool version used by default.
Expand Down

0 comments on commit 3594ebd

Please sign in to comment.