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

Investigate code coverage discrepancies between Codacy, JaCoCo, and CodeCov #11565

Closed
Tracked by #11230
nathanklick opened this issue Feb 15, 2024 · 2 comments · Fixed by #13073
Closed
Tracked by #11230

Investigate code coverage discrepancies between Codacy, JaCoCo, and CodeCov #11565

nathanklick opened this issue Feb 15, 2024 · 2 comments · Fixed by #13073
Assignees
Labels
P2 Required to be completed in the assigned milestone, but may or may not impact the release schedule.

Comments

@nathanklick
Copy link
Member

nathanklick commented Feb 15, 2024

Description

The code coverage numbers reported by Codacy, CodeCov, and JaCoCo appear to all report different coverage figures which possibly indicates one or more configuration issues.

Additionally, there is a concern some code coverage is not being properly picked up or reported at all.

@nathanklick nathanklick added the P2 Required to be completed in the assigned milestone, but may or may not impact the release schedule. label Feb 19, 2024
@jjohannes
Copy link
Collaborator

State after some investigation:

  • Codecov upload broken right now Error: Codecov token not found.
  • Both 'Codecov' and 'Codacy' use the JaCoCo XML reports as base. These are right now created per-project. Which only gives a "partial view" on the overall coverage. Code that is covered by tests (e.g. in API only projects of services like hedera-smart-contract-service) is counted as uncovered, because there are not tests directly in the API project covering them. I think it would be better to let Gradle aggregate a full report (one XML file) and then pass that to both 'Codecov' and 'Codacy'. Then we have the same input for both and can also generate a corresponding HTML report with JaCoCo/Gradle only locally. WiP PR: build: use 'jacoco-report-aggregation' Gradle plugin for a unified setup #13073

@jjohannes
Copy link
Collaborator

Investigation results

  • With build: use 'jacoco-report-aggregation' Gradle plugin for a unified setup #13073, we make sure the same data is uploaded to both both Codecov and Codacy (as a single aggregated XML file)
  • With build: use 'jacoco-report-aggregation' Gradle plugin for a unified setup #13073, there is also an aggregated report to view locally after running :reports:testCodeCoverageReport
  • The numbers in the reports are different because:
    • The local report takes generated code (protobuf and dagger) into account. Therfore it sees more sources and the coverage percentage is lower.
    • IIUC, Codecov and Codacy take the code directly from the Git repository. So they cannot see the generated code. As a result the coverage percentage is higher. I experimented with excluding generated classes from the report aggregation in general and then the number in the local report and Codecov align.
    • The number in Codacy is always slightly higher. I am not totally sure why that is, but I assume the calculation, while based on the same data, works a bit different. What I suspect is that Codecov counts every line touched as "fully covered" (like here - 100% covered), while Codacy also takes "partial coverage" in case of "if-else" branching into account (liker here - same file, but 99.07% covered).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Required to be completed in the assigned milestone, but may or may not impact the release schedule.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants