# Set option to calculate coverage as (h + p) / (h + p + m)

**URL:** <https://community.codecov.com/t/set-option-to-calculate-coverage-as-h-p-h-p-m/1424>\
**Category:** Feature Requests\
**Tags:** cpp\
**Created:** [May 17, 2020, 1:15am UTC](https://community.codecov.com/t/set-option-to-calculate-coverage-as-h-p-h-p-m/1424 "2020-05-17T01:15:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![madisetti](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/madisetti/32/768_2.png) [@madisetti](https://community.codecov.com/u/madisetti)\
**Post date:** [May 17, 2020, 1:15am UTC](https://community.codecov.com/t/set-option-to-calculate-coverage-as-h-p-h-p-m/1424/1 "2020-05-17T01:15:54Z")

</div>

### Language C++

### Description

I have a project that uses macros that show up as partial hits on execution. I like the idea of including branching information, but it creates a -10% coverage difference. Ideally, I’d like to refer to my branch information, but don’t want to take the coverage hit.

Could you add a flag that lets us calculate coverage as (h + p) / (h + p + m) instead of h / (h + p + m)?

Thanks

---

<div class="post-metadata">

**Author:** ![jerrod](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/jerrod/32/41_2.png) [@jerrod](https://community.codecov.com/u/jerrod)\
**Post date:** [May 22, 2020, 5:27pm UTC](https://community.codecov.com/t/set-option-to-calculate-coverage-as-h-p-h-p-m/1424/2 "2020-05-22T17:27:53Z")

</div>

Hey @madisetti,

We have this feature out of the box for our Javascript parser. We also have the option to enable branches (e.g., partials) on our GCOV parser:

```
 gcov:
    branch_detection:
      conditional: yes
      loop: yes
      method: no
      macro: no 

```

Would this help you in your C++ code coverage generation?

> **[codecov.yml Reference](https://docs.codecov.com/docs/codecovyml-reference)**
>
> Top-level sections used in codecov.yml codecov codecov.token The repository upload token Type: StringDefault: N/A codecov.bot The username you want to use for Codecov operations Type: StringDefault: N/AMore Info: https://docs.codecov.io/docs/team-bot...

Jerrod

---

<div class="post-metadata">

**Author:** ![madisetti](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/madisetti/32/768_2.png) [@madisetti](https://community.codecov.com/u/madisetti)\
**Post date:** [May 26, 2020, 6:20pm UTC](https://community.codecov.com/t/set-option-to-calculate-coverage-as-h-p-h-p-m/1424/3 "2020-05-26T18:20:56Z")

</div>

Thanks Jerrod,

I’m using lcov- and it would seem that these flags don’t apply. Here’s an example of a block I would expect to be totally green:

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

I don’t mind the branching highlights since they are useful for `if` statements etc… but the current calculation is the difference from me reporting ~90% test coverage to high 60s.

Proposed feature is more of a catch all for various reports, but I understand if it’s a `wont-fix`

---

<div class="post-metadata">

**Author:** ![tom](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/tom/32/8_2.png) [@tom](https://community.codecov.com/u/tom)\
**Post date:** [June 19, 2020, 12:47am UTC](https://community.codecov.com/t/set-option-to-calculate-coverage-as-h-p-h-p-m/1424/4 "2020-06-19T00:47:50Z")

</div>

Hi @madisetti, totally understand and sorry that this slipped past getting a timely response. Unfortunately, we don’t expect to make this fix in the near future, but our product team is aware that this has been requested from you. We’ll keep this in mind for the future.

Let me know if there’s anything else we can do to help you!
