kotlinx-kover icon indicating copy to clipboard operation
kotlinx-kover copied to clipboard

Feature: Option for Automatic Exclusion for Data Classes, Interfaces and other constructs

Open alexandersumer opened this issue 4 months ago • 1 comments

Proposed API

Excluding untestable types from coverage should be an automatic configuration option, not a manual burden on the developer.

kover {
    excludeDataClasses = true
    excludeInterfaces = true
}

The Problem

Coverage reports are currently cluttered with structural types that have little to no testable logic:

  • Data classes are mostly compiler-generated bytecode (equals, hashCode, toString, copy)
  • Interfaces are pure contracts without implementation

Why Annotations Aren't the Solution

Using @ExcludeFromCoverage has several drawbacks:

  • Wrong place: Coverage settings belong in the build configuration, not the source code
  • Unscalable: Manually annotating hundreds of DTOs is tedious, error-prone toil
  • Silent decay: New classes degrade coverage metrics by default until a developer remembers to tag them

Feasibility

Since Kover is Kotlin-native, it can detect these types via @kotlin.Metadata or bytecode signatures reliably.

alexandersumer avatar Dec 15 '25 04:12 alexandersumer

We need to analyze the possibility of this when switching to Kotlin Gradle Plugin

shanshin avatar Jan 15 '26 14:01 shanshin