# Incorrect coverage number reported by codecov

**URL:** <https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110>\
**Category:** Bug Fixes\
**Tags:** java\
**Created:** [March 4, 2020, 7:17pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110 "2020-03-04T19:17:52Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramachandranms](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@ramachandranms](https://community.codecov.com/u/ramachandranms)\
**Post date:** [March 4, 2020, 7:17pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/1 "2020-03-04T19:17:52Z")

</div>

### Description

Incorrect coverage number reported by codecov for [this java class](https://codecov.io/gh/ramachandranms/incubator-hudi/src/master/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieWriteStat.java) generated by jacoco

### Repository

> **[GitHub - ramachandranms/incubator-hudi: Upserts And Incremental Processing on Big Data](https://github.com/ramachandranms/incubator-hudi)**
>
> Upserts And Incremental Processing on Big Data

### Steps to Reproduce

1. Run the travis-ci build, which will publish the report to codecov
2. Observe the code coverage for hudi-common/src/main/java/org/apache/hudi/common/model/HoodieWriteStat.java

**Expected behavior:**

Code coverage to be around 85% as given by a local jacoco report

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/codecov/original/1X/8f8c9ed33589df3dd3c7602023a755e9d7bf24ae.png)

**Actual behavior:**  
Codecov reports only show ~20% as covered

**Flakiness?**

This happens all the time

### Versions

Happens across all OS and browser versions

### Additional Information

---

<div class="post-metadata">

**Author:** ![drazisil](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/drazisil/32/496_2.png) [@drazisil](https://community.codecov.com/u/drazisil)\
**Post date:** [March 5, 2020, 3:25pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/2 "2020-03-05T15:25:08Z")

</div>

Hi @ramachandranms

jacoco reports sometimes have expiry issues, can you share a commit SHA so I can check the logs and see what’s up?

---

<div class="post-metadata">

**Author:** ![ramachandranms](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@ramachandranms](https://community.codecov.com/u/ramachandranms)\
**Post date:** [March 5, 2020, 5:29pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/3 "2020-03-05T17:29:00Z")

</div>

Hi @drazisil. I restarted a build for master in travis. The commit SHA is 2d040145810b8b14c59c5882f9115698351039d1. The build should take about 30 mins to complete.

Thanks for looking into this.

---

<div class="post-metadata">

**Author:** ![drazisil](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/drazisil/32/496_2.png) [@drazisil](https://community.codecov.com/u/drazisil)\
**Post date:** [March 5, 2020, 5:36pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/4 "2020-03-05T17:36:46Z")

</div>

I only have one report from 3 March when you uploaded it before. Do you normally upload a single report?

---

<div class="post-metadata">

**Author:** ![ramachandranms](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@ramachandranms](https://community.codecov.com/u/ramachandranms)\
**Post date:** [March 5, 2020, 5:44pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/5 "2020-03-05T17:44:59Z")

</div>

This is my private fork. if you are interested in frequent updates, you can checkout the apache project. [GitHub - apache/hudi: Upserts, Deletes And Incremental Processing on Big Data.](http://github.com/apache/incubator-hudi)

Sample commit for that file (uploaded less than 3 hours ago)

> **[Code coverage done right.](https://app.codecov.io/gh/apache/incubator-hudi/blob/76133ce9788df7bc57406066811fb5e14d40a17c/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieWriteStat.java)**
>
> Hosted coverage report highly integrated with GitHub, Bitbucket and GitLab. Awesome pull request comments to enhance your QA.

---

<div class="post-metadata">

**Author:** ![ramachandranms](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@ramachandranms](https://community.codecov.com/u/ramachandranms)\
**Post date:** [March 9, 2020, 5:42pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/6 "2020-03-09T17:42:33Z")

</div>

hi @drazisil , did you get a chance to look into this issue ? please let me know if you need any further information to troubleshoot this issue

---

<div class="post-metadata">

**Author:** ![drazisil](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/drazisil/32/496_2.png) [@drazisil](https://community.codecov.com/u/drazisil)\
**Post date:** [March 9, 2020, 5:43pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/7 "2020-03-09T17:43:19Z")

</div>

> [@ramachandranms](#):
>
> 2d040145810b8b14c59c5882f9115698351039d1

I didn’t, looking now…

EDIT: I’m not seeing an issues with `2d040145810b8b14c59c5882f9115698351039d1`, did you have problems, or did it work as expected?

---

<div class="post-metadata">

**Author:** ![ramachandranms](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@ramachandranms](https://community.codecov.com/u/ramachandranms)\
**Post date:** [March 9, 2020, 8:11pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/8 "2020-03-09T20:11:39Z")

</div>

@drazisil

[This is the file](https://codecov.io/gh/ramachandranms/incubator-hudi/src/2d040145810b8b14c59c5882f9115698351039d1/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieWriteStat.java) i am looking at in that SHA.

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/codecov/original/1X/3a26c7c85e3c4f90c1073bd318525638b8e5e5f1.png)

codecov is reporting 20.38% coverage and 293 lines missing coverage. But the file have very good amount of coverage and only about [15 lines](https://codecov.io/gh/ramachandranms/incubator-hudi/src/2d040145810b8b14c59c5882f9115698351039d1/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieWriteStat.java) missing coverage.

The local jacoco report (screenshot below) shows about 85% coverage. The problem is codecov reporting only 20% while jacoco reports 85%.

![image](https://canada1.discourse-cdn.com/flex029/uploads/codecov/original/1X/2b40207f7b9656173a017eb5751d0e72b8189ff6.png)

---

<div class="post-metadata">

**Author:** ![drazisil](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/drazisil/32/496_2.png) [@drazisil](https://community.codecov.com/u/drazisil)\
**Post date:** [March 10, 2020, 2:35pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/9 "2020-03-10T14:35:44Z")

</div>

Hmm. Here’s the uploaded coverage report, will have to look though it to see if the lines are reported covered. [https://codecov.io/codecov/v4/raw/2020-03-03/87AC6CA37FD62FF9A5E96EDF8BC725C6/2d040145810b8b14c59c5882f9115698351039d1/b6f33b40-6aec-43c7-9b1b-733c5672d950.txt](https://codecov.io/codecov/v4/raw/2020-03-03/87AC6CA37FD62FF9A5E96EDF8BC725C6/2d040145810b8b14c59c5882f9115698351039d1/b6f33b40-6aec-43c7-9b1b-733c5672d950.txt)

Do you have an example line that you believe is covered that Codecov says is not that I can look in the report for?

---

<div class="post-metadata">

**Author:** ![ramachandranms](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@ramachandranms](https://community.codecov.com/u/ramachandranms)\
**Post date:** [March 10, 2020, 4:26pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/10 "2020-03-10T16:26:07Z")

</div>

The covered/uncovered seems to be correct visually (if we got by green and red highlighting). It’s just that the counting of lines seem wrong. codecov is including variables declarations in the uncovered count it seems.

---

<div class="post-metadata">

**Author:** ![roniemartinez](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/roniemartinez/32/607_2.png) [@roniemartinez](https://community.codecov.com/u/roniemartinez)\
**Post date:** [March 11, 2020, 9:40am UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/11 "2020-03-11T09:40:33Z")

</div>

Same issue here: [# pragma: no cover is still being covered](https://community.codecov.com/t/pragma-no-cover-is-still-being-covered/1128)

Reporting is incorrect for file with 100% coverage.

---

<div class="post-metadata">

**Author:** ![ramachandranms](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@ramachandranms](https://community.codecov.com/u/ramachandranms)\
**Post date:** [March 11, 2020, 8:16pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/12 "2020-03-11T20:16:16Z")

</div>

@roniemartinez our problem seems slightly different. the stats looks like the following from jacoco report

```
     <counter type="INSTRUCTION" missed="147" covered="182"/>
     <counter type="BRANCH" missed="8" covered="0"/>
     <counter type="LINE" missed="12" covered="74"/>
     <counter type="COMPLEXITY" missed="7" covered="49"/>
     <counter type="METHOD" missed="3" covered="49"/>
     <counter type="CLASS" missed="0" covered="2"/>

```

The problem seems to be on calculating the number of tracked lines, which is not present in the report. ti is calculated as 370+ whereas it should only be around 90 lines. rest are all variable declarations, which should not be part of code coverage.

@drazisil any update on this ?

---

<div class="post-metadata">

**Author:** ![drazisil](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/drazisil/32/496_2.png) [@drazisil](https://community.codecov.com/u/drazisil)\
**Post date:** [March 13, 2020, 3:33pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/13 "2020-03-13T15:33:00Z")

</div>

Let me make sure I understand:

When looking at a file overlay, the coverage lines are correct, but the number is not? From looking at the report, are you able to guess what might be being counted?

I’m trying to determine if this is a backed or frontend issue. You can add `api/` in front of the `gh` part of most any URL on Codecov to view the underlying data passed to the frontend.

If you can give me an example file URL on Codecov we can take a look together.

---

<div class="post-metadata">

**Author:** ![ramachandranms](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@ramachandranms](https://community.codecov.com/u/ramachandranms)\
**Post date:** [March 13, 2020, 7:00pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/14 "2020-03-13T19:00:22Z")

</div>

@drazisil [this is the data](https://codecov.io/api/gh/apache/incubator-hudi/src/master/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieWriteStat.java) for the file i am looking at. I don’t think i understand the internals of codecov to make any assumptions. lmk your thoughts

---

<div class="post-metadata">

**Author:** ![drazisil](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/drazisil/32/496_2.png) [@drazisil](https://community.codecov.com/u/drazisil)\
**Post date:** [March 16, 2020, 1:28pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/15 "2020-03-16T13:28:48Z")

</div>

@ramachandranms

I’m sorry for sending you to that rabbit hole, I remembered the API data being a bit saner then that.

Lets take a look here referencing the reference (which I had to look up, don’t worry, I don’t have this memorized) [https://docs.codecov.io/v4.4.0/reference#totals](https://docs.codecov.io/v4.4.0/reference#totals)

We have `368` lines in total, with `293` hit, calculating at `"20.38043"` percent coverage for the `HoodieWriteStat.java` file.

We are getting a count of `368` files, because that is how many lines the report has coverage for

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/codecov/original/1X/71adc6cf4dc55ab9fc69ca3b126d00e22f801cc4.png)

If any of those lines should not have coverage data, you will need to find a way to tweak your coverage reporter to not include them on the report. When pasing the report, we only have line nukbers and hit counts, like so

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/codecov/original/1X/00a3259288c0b434084c5b114d3c34fee48e589f.png)

We have no way of knowing the contents of those lines.

---

<div class="post-metadata">

**Author:** ![ramachandranms](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@ramachandranms](https://community.codecov.com/u/ramachandranms)\
**Post date:** [March 16, 2020, 5:47pm UTC](https://community.codecov.com/t/incorrect-coverage-number-reported-by-codecov/1110/16 "2020-03-16T17:47:53Z")

</div>

thanks @drazisil seems like the best course of action is to ignore coverage for this file, since it is only a POJO and some generated code. will try that out.
