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

Kotlinx Serialization annotation line included in the coverage report #686

Open
saurabh-somani-philips opened this issue Sep 13, 2024 · 9 comments
Assignees
Labels
Bug Bug issue type Check In JaCoCo S: confirmed Status: bug is reproduced or present

Comments

@saurabh-somani-philips
Copy link

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

  • Kover Gradle Plugin version: 0.8.3
  • Gradle version: 8.7
  • Kotlin project type: Kotlin/Multiplatform
  • Coverage Toolset (if customized in build script): Kover
  • Other context important for this bug: Kotlin version - 2.0.20
@saurabh-somani-philips saurabh-somani-philips added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Sep 13, 2024
@saurabh-somani-philips saurabh-somani-philips changed the title Kotlinx Serialization annotation line considered in the coverage report Kotlinx Serialization annotation line included in the coverage report Sep 13, 2024
@shanshin
Copy link
Collaborator

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

@shanshin shanshin added S: waiting for clarification Status: additional information required to proceed and removed S: untriaged Status: issue reported but unprocessed labels Sep 17, 2024
@saurabh-somani-philips
Copy link
Author

saurabh-somani-philips commented Sep 18, 2024

@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

@shanshin shanshin added S: confirmed Status: bug is reproduced or present and removed S: waiting for clarification Status: additional information required to proceed labels Sep 22, 2024
@johngray1965
Copy link

Similiar issue with android's @parcelize
image

@mgroth0
Copy link

mgroth0 commented Oct 24, 2024

Confirming I have this issue too with @Serializable

@kszorin
Copy link

kszorin commented Dec 11, 2024

@shanshin , we have this problem too! This is very disturbing.
We left with Jacoco to Kotlin, because it has the same problem, but Kover also had the same problem after Kotlin update to 2.0

When is it planned to be fixed?

@JKuliska-pcty
Copy link

@shanshin we're facing this issue too and as we heavily use @Parcelable it's skewing the coverage result not in our favor.
Is there an estimate when this could be fixed?

Thank you so much.

@shanshin
Copy link
Collaborator

@JKuliska-pcty, we are gradually switching to using the JaCoCo agent (#720), and as a result, our reports will be rewritten. At the same time, we will try to take into account the problems with synthetic, but not marked as synthetic methods.

We try to fix the existing report for @Serializable, but fixes for @Parcelable are not in the short-term plans.

@JKuliska-pcty
Copy link

JKuliska-pcty commented Feb 11, 2025

@JKuliska-pcty, we are gradually switching to using the JaCoCo agent (#720), and as a result, our reports will be rewritten. At the same time, we will try to take into account the problems with synthetic, but not marked as synthetic methods.

We try to fix the existing report for @Serializable, but fixes for @Parcelable are not in the short-term plans.

Thank you for your answer. It's a pity that the @Parcelable is not on the near timeline. Do you have some recommendations on how to globally ignore that? Is that possible with some exclusion rule? I tried but couldn't find a way.

The only thing I managed was to write a test that makes the Parcelable interface part covered by wrapping and unwrapping the class as a Parcelable but that is firstly not testing the implementation of our code but of a 3rd party dependency and also the annotation I couldn't get marked as green (tested)

cc: @shanshin

@shanshin
Copy link
Collaborator

@JKuliska-pcty, I will study this issue next week to see if it is possible to exclude synthetic @Parcelable declarations using filters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type Check In JaCoCo S: confirmed Status: bug is reproduced or present
Projects
None yet
Development

No branches or pull requests

6 participants