Kotlin / kotlinx-kover

Apache License 2.0
1.35k stars 53 forks source link

Kotlinx Serialization annotation line included in the coverage report #686

Open saurabh-somani-philips opened 3 weeks ago

saurabh-somani-philips commented 3 weeks ago

Describe the bug Recently, I updated the Kover version in my KMM project from 0.8.1 to 0.8.3, and I noticed my data classes annotated with @Serializable were not fully covered. The annotation line looks yellow in the HTML report, stating it is partially covered.

I've tried excluding "*.*serializer*" from coverage report (as mentioned in some previous issue reported 1 or 2 years ago), but it didn't help.

Errors N/A

Expected behavior Data class should be fully covered, ignoring the @Serializable annotation line. I don't want to exclude the whole data class to solve this issue, just the annotation part. Am I doing something wrong or Kover needs to consider updating itself after Kotlin 2.0 update (I'm using v2.0.20)?

Reproducer N/A

Reports This is my data class in the Kover report:

image

This is the coverage summary:

image

Environment

shanshin commented 2 weeks ago

Hi, do you have the option to exclude companions ("*\$Companion") for serializable classes from the report? If so, does it fix your issue?

saurabh-somani-philips commented 2 weeks ago

@shanshin I tried excluding it from the coverage report. The Companion object's coverage disappears, but main data class's 'Branch' and 'Instruction' coverage still has some coverage left. The same is reflected in our SonarQube report, so the ultimate aim is to fix the Sonar report coverage.

image image