Kotlin / kotlinx-kover

Apache License 2.0
1.37k stars 53 forks source link

annotatedBy doesn't exclude classes from coverage #555

Closed nuhkoca closed 9 months ago

nuhkoca commented 9 months ago

Describe the bug Hello, I created a custom annotation but classes annotated with it are still included in code coverage.

Expected behavior Classes/functions annotated by KoverIgnore should be excluded from coverage.

Reproducer

internal val annotationExclusions = listOf(
    "<project_path>.common.utils.KoverIgnore",
    "androidx.compose.runtime.Composable",
    "androidx.compose.ui.tooling.preview.Preview",
    "<project_path>.snapshot.PreviewTest",
    "*Generated",
)

configure<KoverReportExtension> {
        filters {
            excludes {
                classes(coverageExclusions)
                packages(packageExclusions)
                annotatedBy(annotationExclusions.joinToString())
            }
        }
    }

Reports If applicable, report files or screenshots.

Screenshot 2024-02-29 at 16 00 50

Environment

shanshin commented 9 months ago

Hi, your configuration uses joining all annotations into one String annotationExclusions.joinToString(), however, only one annotation should be written in each string.

you should write like this

annotatedBy("annotation1", "annotation2")

or if you have a list with annotations, like this

annotatedBy(*annotationExclusions.toTypedArray())
nuhkoca commented 9 months ago

Thank you, it's fixed!