# Codecov/patch strange behavior

**URL:** <https://community.codecov.com/t/codecov-patch-strange-behavior/4348>\
**Category:** Support\
**Tags:** github\
**Created:** [June 1, 2023, 2:27pm UTC](https://community.codecov.com/t/codecov-patch-strange-behavior/4348 "2023-06-01T14:27:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fewwy](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@Fewwy](https://community.codecov.com/u/Fewwy)\
**Post date:** [June 1, 2023, 2:27pm UTC](https://community.codecov.com/t/codecov-patch-strange-behavior/4348/1 "2023-06-01T14:27:06Z")

</div>

## Before submitting a topic, please confirm the following

I have searched for similar issues before creating this topic.  
 I have verified that my repository is using the [Codecov GitHub app](https://github.com/apps/codecov), if using GitHub  
 I have [validated](https://docs.codecov.com/docs/codecov-yaml#validate-your-repository-yaml) my `codecov.yaml` configuration file.  
 I have filled out the below sections to the best of my ability.  
 I understand that the community boards are a free, best-effort tool. While we hope to have someone on the Codecov team resolve your problem quickly, this is not always possible.

### Description

Description of the issue  
In a PR codecov/patch tells that I have a reduction in amount of tests even after I added a test.  
This is link to the PR

> <https://github.com/RedHatInsights/insights-advisor-frontend/pull/1130>
>
> \# Description
> First part of the 3715 jira ticket
> 
> Associated Jira ticket: # (…issue)
> https://issues.redhat.com/browse/ESSNTL-3715
> 
> Please include a summary of the change, what this fixes/creates/improves.
> 
> 
> \# How to test the PR
> Check if the Group column is present in the systems table
> Turn off the https://insights-stage.unleash.devshift.net/projects/default/features/hbi.ui.inventory-groups
> restart a page 1 or 2 times to make sure that the feature flag is turned off
> Group column should be missing
> Please include steps to test your PR.
> 
> \# Before the change
> 
> 
> \# After the change
> 
> 
> \# Dependent work link
> 
> 
> \# Checklist:
> 
> \- \[\] The commit message has the Jira ticket linked
> \- \[\] PR has a short description
> \- \[\] Screenshots before and after the change are added
> \- \[\] Tests for the changes have been added
> \- \[\] README.md is updated if necessary
> \- \[\] Needs additional dependent work

### CI/CD URL

Please provide a link to the CI/CD run.

> <https://github.com/RedHatInsights/insights-advisor-frontend/pull/1130/checks>
>
> \# Description
> First part of the 3715 jira ticket
> 
> Associated Jira ticket: # (…issue)
> https://issues.redhat.com/browse/ESSNTL-3715
> 
> Please include a summary of the change, what this fixes/creates/improves.
> 
> 
> \# How to test the PR
> Check if the Group column is present in the systems table
> Turn off the https://insights-stage.unleash.devshift.net/projects/default/features/hbi.ui.inventory-groups
> restart a page 1 or 2 times to make sure that the feature flag is turned off
> Group column should be missing
> Please include steps to test your PR.
> 
> \# Before the change
> 
> 
> \# After the change
> 
> 
> \# Dependent work link
> 
> 
> \# Checklist:
> 
> \- \[\] The commit message has the Jira ticket linked
> \- \[\] PR has a short description
> \- \[\] Screenshots before and after the change are added
> \- \[\] Tests for the changes have been added
> \- \[\] README.md is updated if necessary
> \- \[\] Needs additional dependent work

### Codecov Output

Please provide the full output of running the uploader on your CI/CD. This will typically have the Codecov logo as ASCII.

```auto

```

### Expected Results

Please provide what you expect to have happened (e.g. a file that has missing coverage on a particular line).  
Increase in the % of coverage

### Actual Results

Please provide what actually happened.  
Reduction in the % of coverage

### Additional Information

Please provide applicable commit SHAs or file names that are extraneous or missing. Any additional information, configuration, or data that might be necessary to reproduce the issue.

---

<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 1, 2023, 2:41pm UTC](https://community.codecov.com/t/codecov-patch-strange-behavior/4348/2 "2023-06-01T14:41:36Z")

</div>

@Fewwy, to be clear, [patch](https://docs.codecov.com/docs/commit-status#patch-status) coverage

> **only** measures lines adjusted in the pull request or single commit, if the commit is not in a pull request. This status provides an indication on how well the pull request is tested.

In other words, it measures the coverage of newly added code.

If you go back to the [PR](https://github.com/RedHatInsights/insights-advisor-frontend/pull/1130/files), you’ll notice where Codecov sees new lines of code, but no corresponding tests has been added. Take lines 1-5 and 7-9 below.

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/codecov/original/2X/6/660975dfa9930bc6434d3bfde34e768436c06b36.jpeg)

* * *

If you are talking about `project` coverage which measures the coverage over the entire codebase, you can see that you have added new lines of code that are not covered by tests.

Compare your [BASE](https://app.codecov.io/gh/RedHatInsights/insights-advisor-frontend/commit/483469117374dac3c4f7c04118331c71a9f04488/tree) commit which shows

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

`146 lines covered/2179 total lines`  
versus your [HEAD](https://app.codecov.io/gh/RedHatInsights/insights-advisor-frontend/pull/1130/tree) commit

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/codecov/original/2X/2/225952490296774da752a34f9a7cfc7d74f0e0b2.png)  
`146 lines covered/2187 total lines`

This is why `project` coverage drops.

* * *

You mentioned you wrote tests. I would make sure that the test is running and coverage is being collected for them since Codecov is not getting results for it.

---

<div class="post-metadata">

**Author:** ![Fewwy](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@Fewwy](https://community.codecov.com/u/Fewwy)\
**Post date:** [June 2, 2023, 12:15pm UTC](https://community.codecov.com/t/codecov-patch-strange-behavior/4348/3 "2023-06-02T12:15:46Z")

</div>

Thanks for your reply Tom,  
It seems that it’s either our upload script broke or we have issues with the config.

Could you take a look at our config maybe you would see errors in it?

```auto
coverage:
  status:
    patch:
      default:
        # basic
        target: auto
        threshold: 0%
        base: auto
        # advanced
        branches:
          - master
        if_ci_failed: error #set the status to success only if the CI is successful
        only_pulls: false #Only post a status to pull requests
        flags:
          - "unit"
    project:
      default:
        # basic
        target: 0%
        threshold: 10%
        patch: false
        flags:
          - unit
       # advanced settings
        branches:
          - master
        if_ci_failed: error #success, failure, error, ignore
        informational: false
        only_pulls: false

```

---

<div class="post-metadata">

**Author:** ![Fewwy](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@Fewwy](https://community.codecov.com/u/Fewwy)\
**Post date:** [June 7, 2023, 1:25pm UTC](https://community.codecov.com/t/codecov-patch-strange-behavior/4348/4 "2023-06-07T13:25:26Z")

</div>

@tom Hello Tom! If you have some spare time - please check the config I linked, because I want to fix issues with our repo

---

<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 7, 2023, 1:41pm UTC](https://community.codecov.com/t/codecov-patch-strange-behavior/4348/5 "2023-06-07T13:41:50Z")

</div>

@Fewwy hmm, I would suggest not making `target: auto` for `patch`. That means that every commit should have equal or greater `patch` coverage which doesn’t always make sense. I would set that to a real number.

To your initial point, your PR has a passing check now.
