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 inheritedFrom causes verify to allways pass #675

Open
friscoMad opened this issue Aug 20, 2024 · 2 comments
Open

Using inheritedFrom causes verify to allways pass #675

friscoMad opened this issue Aug 20, 2024 · 2 comments
Labels
Bug Bug issue type S: confirmed Status: bug is reproduced or present

Comments

@friscoMad
Copy link

Describe the bug
When using filtering by inheritance verification always pass even when the report correctly reports no covarage.

Errors

Expected behavior
Verification should fail if the coverage does not comply with the rule

Reproducer
I have not created a reproducer but we have this configuration:

reports {
                filters {
                    excludes {
                        packages(commonExclusions + exclusions.get())
                        inheritedFrom.add("dagger.internal.Factory")
                    }
                }
                verify {
                    rule {
                        groupBy.set(GroupingEntityType.PACKAGE)
                        bound {
                            coverageUnits.set(CoverageUnit.INSTRUCTION)
                            minValue.set(minimumTestCoverage.get().toPercentageInt())
                        }
                    }
                    rule {
                        groupBy.set(GroupingEntityType.PACKAGE)
                        bound {
                            coverageUnits.set(CoverageUnit.BRANCH)
                            minValue.set(minimumTestCoverage.get().toPercentageInt())
                        }
                    }
                }
            }

With the inheritedFrom line commented the verify fails with it enabled the verify task pass, the code is the same and this happens even when the inherit expression does not match any file in the codebase.

Afaik understand that the bug is present since this filtering was added as the test coverage for that feature only covers reports and not verification.
After some debugging I think that the problem is in this piece of code:
https://github.com/JetBrains/intellij-coverage/blob/e5cd723643bba739cb99cd73a5bfd1e945557701/reporter/src/com/intellij/rt/coverage/aggregate/Aggregator.java#L103

It is creating a copy of the project but only adding the classes to the copy so the rest of the model is empty and that includes the classInstructions that are probably needed by the verify logic down the line.

Reports
If applicable, report files or screenshots.

Environment

  • Kover Gradle Plugin version: 0.8.3
  • Gradle version: 0.8.10
  • Kotlin project type: Kotlin/JVM
  • Coverage Toolset (if customized in build script): Kover
  • Other context important for this bug: [e.g. OS version]
@friscoMad friscoMad added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Aug 20, 2024
@shanshin
Copy link
Collaborator

Hi,
the inheritedFrom filter is taken into account during verification.

To deal with the problem, a reproducer project would be very helpful, with a description of the steps how to reproduce the issue.

@shanshin shanshin added S: waiting for clarification Status: additional information required to proceed and removed S: untriaged Status: issue reported but unprocessed labels Aug 28, 2024
@friscoMad
Copy link
Author

The problem is that enabling that exclusion for some reasons makes all verification to pass even if it shouldn't.
Here is a simple reproducer based on your simple example.
I have only added the inheritance exclusion changed the verify rule to instructions (instead of lines) and bump to 90 (as 50 was passing as expected).
It seems that with lines everything works as expected but branches or instructions are "bypassed" when inheritance exclusion is applied.
single.zip

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type S: confirmed Status: bug is reproduced or present
Projects
None yet
Development

No branches or pull requests

2 participants