Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using an annotation to exclude a class does not exclude the companion object #431

Closed
efenderbosch-atg opened this issue Jul 11, 2023 · 1 comment
Assignees
Labels
Bug Bug issue type S: in progress Status: implementing or design in process

Comments

@efenderbosch-atg
Copy link

efenderbosch-atg commented Jul 11, 2023

Describe the bug

I've got a simple annotation to exclude classes from kover.

@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class KoverIgnore(@Suppress("unused") val reason: String)

It is configured like this in build.gradle.kts:

koverReport {
    filters {
        excludes {
            annotatedBy(
                "org.springframework.context.annotation.Configuration",
                "KoverIgnore"
            )
        }
    }
}

I'm using it on a class like this:

@Service
@KoverIgnore("trivial disabled implementation")
class DisabledEmailVerificationService : EmailVerificationService {
    override suspend fun sendVerificationEmail(lead: Lead): String? {
        LOG.info("email verification is not enabled")
        return null
    }

    companion object {
        private val LOG = KotlinLogging.logger { }
    }
}

The coverage report is still flagging the companion object and private LOG as not covered:

image

If I also put my annotation on the companion object then the private val LOG = KotlinLogging.logger { } line is flagged as not covered.

Errors
None

Expected behavior
Members of a companion object, especially private members, should not be expected to be covered by tests if the containing class has been excluded from coverage.

Reproducer
Code examples above.

Reports
Report screenshot above.

Environment

  • Kover Gradle Plugin version: 0.7.1
  • Gradle version: 8.1.1
  • Kotlin project type: Kotlin/JVM 1.8/17
@efenderbosch-atg efenderbosch-atg added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Jul 11, 2023
@shanshin shanshin added S: in progress Status: implementing or design in process and removed S: untriaged Status: issue reported but unprocessed labels Jul 12, 2023
@shanshin
Copy link
Collaborator

Fixed in 0.7.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type S: in progress Status: implementing or design in process
Projects
None yet
Development

No branches or pull requests

2 participants