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

Kover CLI report generation does not reliably with --excludeAnnotation when using JAR (instead of folder) for --classfiles #709

Open
oliviernotteghem opened this issue Nov 23, 2024 · 3 comments
Assignees
Labels
Bug Bug issue type S: in progress Status: implementing or design in process

Comments

@oliviernotteghem
Copy link

oliviernotteghem commented Nov 23, 2024

We found instances where, when using --classfiles to point to a JAR, --excludeAnnotation does not work completely and some code that should be excluded still appear to be covered.

When the same command line have --classfiles pointing to a folder, when the JAR was unpacked, the filtering works reliably.

Example of command line invocation :
java -jar /Users/oliviern/.devxp/import-cache/4b81c0960d39ddd828f97e31aee273bf0d929d87/3c34899b72c05e31efaa6ed042ad0527573034a1/kover-cli-0.8.2.jar @bazel-bin/libraries/foundation/ui/ui-compose-ambients/test_release-kover_metadata.txt --xml bazel-bin/libraries/foundation/ui/ui-compose-ambients/test_release-kover_report.xml --html /Users/oliviern/Uber/android/bazel-testlogs/libraries/foundation/ui/ui-compose-ambients/test_release/coverage_report

content of bazel-bin/libraries/foundation/ui/ui-compose-ambients/test_release-kover_metadata.txt:

report
bazel-out/xplat-fastbuild/bin/libraries/foundation/ui/ui-compose-ambients/test_release-kover_report.ic
--title
Code-Coverage Analysis: @@//libraries/foundation/ui/ui-compose-ambients:test_release
--src
libraries/foundation/ui/ui-compose-ambients/src/main/kotlin/com/uber/ui/compose/core/ambient
--classfiles
bazel-out/xplat-fastbuild/bin/libraries/foundation/ui/ui-compose-ambients/libsrc_release.jar
--exclude
*Expose

example of code failing to be filtered out:

  @Expose
  fun composeDeps(
      analyticsClient: AnalyticsClient,
  ) =
      object : composeDependencies {
        override fun analyticsClient() = analyticsClient
      }
@oliviernotteghem oliviernotteghem added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Nov 23, 2024
@shanshin shanshin added S: in progress Status: implementing or design in process and removed S: untriaged Status: issue reported but unprocessed labels Nov 25, 2024
@zuevmaxim
Copy link

zuevmaxim commented Nov 27, 2024

@oliviernotteghem Could you please look into the bytecode of the class inside jar, and check that the annotation is present there?
Unpack the jar, and then use javap -v -l -p <path-to-class>.class to see the bytecode. The target method should have the annotation.
While testing, I found out that ProGuard removed RetentionPolicy.CLASS annotation in my case, maybe it is something similar in your case

@oliviernotteghem
Copy link
Author

@zuevmaxim : I forgot to mention that we verified this already. The annotation is not stripped and is present in bytecode.

@shanshin
Copy link
Collaborator

@oliviernotteghem, to reproduce it locally we need reproducer project or a problematic jar file

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

3 participants