# CodeCov false positive - Configuration-as-Code

**URL:** <https://community.codecov.com/t/codecov-false-positive-configuration-as-code/1484>\
**Category:** Support\
**Created:** [May 31, 2020, 12:09am UTC](https://community.codecov.com/t/codecov-false-positive-configuration-as-code/1484 "2020-05-31T00:09:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casz](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/casz/32/465_2.png) [@casz](https://community.codecov.com/u/casz)\
**Post date:** [May 31, 2020, 12:09am UTC](https://community.codecov.com/t/codecov-false-positive-configuration-as-code/1484/1 "2020-05-31T00:09:12Z")

</div>

### Description

We were seeing some false positive in a Java code base.

You can see the false positive in the comment change history.

> <https://github.com/jenkinsci/configuration-as-code-plugin/pull/1398#issuecomment-631329899>
>
> \# \[Codecov\](https://codecov.io/gh/jenkinsci/configuration-as-code-plugin/pull/13…98?src=pr&el=h1) Report
> \> Merging \[#1398\](https://codecov.io/gh/jenkinsci/configuration-as-code-plugin/pull/1398?src=pr&el=desc) into \[master\](https://codecov.io/gh/jenkinsci/configuration-as-code-plugin/commit/28622da82672b0006621a2370e1ecd403f61629d&el=desc) will \*\*increase\*\* coverage by \`1.01%\`.
> \> The diff coverage is \`100.00%\`.
> 
> 
> \`\`\`diff
> @@ Coverage Diff @@
> \## master #1398 +/- ##
> ============================================
> + Coverage 79.52% 80.54% +1.01%     
> \- Complexity 806 811 +5     
> ============================================
> Files 66 66              
> Lines 2344 2333 -11     
> Branches 326 329 +3     
> ============================================
> + Hits 1864 1879 +15     
> + Misses 380 355 -25     
> + Partials 100 99 -1     
> \`\`\`
> 
> | \[Impacted Files\](https://codecov.io/gh/jenkinsci/configuration-as-code-plugin/pull/1398?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
> |---|---|---|---|
> | \[...a/io/jenkins/plugins/casc/ConfigurationAsCode.java\](https://codecov.io/gh/jenkinsci/configuration-as-code-plugin/pull/1398/diff?src=pr&el=tree#diff-cGx1Z2luL3NyYy9tYWluL2phdmEvaW8vamVua2lucy9wbHVnaW5zL2Nhc2MvQ29uZmlndXJhdGlvbkFzQ29kZS5qYXZh) | \`79.94% \<ø\> (+4.40%)\` | \`103.00 \<0.00\> (+2.00)\` | |
> | \[...kins/plugins/casc/yaml/StreamReaderWithSource.java\](https://codecov.io/gh/jenkinsci/configuration-as-code-plugin/pull/1398/diff?src=pr&el=tree#diff-cGx1Z2luL3NyYy9tYWluL2phdmEvaW8vamVua2lucy9wbHVnaW5zL2Nhc2MveWFtbC9TdHJlYW1SZWFkZXJXaXRoU291cmNlLmphdmE=) | \`85.71% \<100.00%\> (ø)\` | \`1.00 \<1.00\> (ø)\` | |
> | \[.../java/io/jenkins/plugins/casc/yaml/YamlSource.java\](https://codecov.io/gh/jenkinsci/configuration-as-code-plugin/pull/1398/diff?src=pr&el=tree#diff-cGx1Z2luL3NyYy9tYWluL2phdmEvaW8vamVua2lucy9wbHVnaW5zL2Nhc2MveWFtbC9ZYW1sU291cmNlLmphdmE=) | \`100.00% \<100.00%\> (+29.16%)\` | \`8.00 \<8.00\> (-3.00)\` | :arrow\_up: |
> | \[...n/java/io/jenkins/plugins/casc/yaml/YamlUtils.java\](https://codecov.io/gh/jenkinsci/configuration-as-code-plugin/pull/1398/diff?src=pr&el=tree#diff-cGx1Z2luL3NyYy9tYWluL2phdmEvaW8vamVua2lucy9wbHVnaW5zL2Nhc2MveWFtbC9ZYW1sVXRpbHMuamF2YQ==) | \`79.45% \<100.00%\> (+3.64%)\` | \`20.00 \<5.00\> (+5.00)\` | |
> | \[...main/java/io/jenkins/plugins/casc/model/CNode.java\](https://codecov.io/gh/jenkinsci/configuration-as-code-plugin/pull/1398/diff?src=pr&el=tree#diff-cGx1Z2luL3NyYy9tYWluL2phdmEvaW8vamVua2lucy9wbHVnaW5zL2Nhc2MvbW9kZWwvQ05vZGUuamF2YQ==) | \`40.00% \<0.00%\> (+20.00%)\` | \`1.00% \<0.00%\> (+1.00%)\` | |

I think one of the false positive comes when you have line splits:

```java
Object value =
    dryrun ?
        configurator.check(o, context):
        configurator.configure(o, context);

```

instead of more normally formatted.

```java
Object value = dryrun
    ? configurator.check(o, context)
    : configurator.configure(o, context);

```

Saw some similair false positive with codecov before this commit in a recent PR: [SecretResolver support file and base64 variable expansion by jetersen · Pull Request #1408 · jenkinsci/configuration-as-code-plugin · GitHub](https://github.com/jenkinsci/configuration-as-code-plugin/pull/1408/commits/355c5b0a89f7c54d4e5ff97ac99afad0b8369a7a)

The `private static final StringSubstitutor SUBSTITUTOR = new StringSubstitutor` was missing coverage inside the `ImmutableMap.of` prior to the commit.

> **[Code coverage done right.](https://app.codecov.io/gh/jenkinsci/configuration-as-code-plugin/compare/1408)**
>
> Hosted coverage report highly integrated with GitHub, Bitbucket and GitLab. Awesome pull request comments to enhance your QA.

### Repository

`https://github.com /jenkinsci/configuration-as-code-plugin`

### CI/CD

GitHub

### Uploader

CodeCov GitHub Action

### Commit SHAs

> <https://github.com/jenkinsci/configuration-as-code-plugin/commit/f8c5f5af91da94f9f74f56d241371c3483a4f06a>

### Codecov YAML

```auto
comment:
  layout: "header, diff, tree, changes"

```

### Codecov Output

`https://github.com/jenkinsci/configuration-as-code-plugin/actions?page=2`

### Additional Information

`https://twitter.com/jetersen/status/1264558738951856144`

@tom

---

<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, 2020, 10:28pm UTC](https://community.codecov.com/t/codecov-false-positive-configuration-as-code/1484/2 "2020-06-01T22:28:57Z")

</div>

Hi @casz, I’m not totally sure this is a false positive.

I took a look into this [commit](https://codecov.io/gh/jenkinsci/configuration-as-code-plugin/commit/f8c5f5af91da94f9f74f56d241371c3483a4f06a), and pulled up one of the raw [builds](https://codecov.io/codecov/v4/raw/2020-05-22/1CC4E15573ED6DB0C1A1C8690C178072/f8c5f5af91da94f9f74f56d241371c3483a4f06a/d7aefb75-fc37-4d10-9d31-3e8c04abd42b.txt).

You’ll notice a section (after formatting for human-readability):

```auto
<?xml version="1.0" encoding="UTF-8"?>
<sourcefile name="BaseConfigurator.java">
   ...
   <line nr="343" mi="0" ci="5" mb="0" cb="2" />
   ...
</sourcefile>

```

Branch calculation is done by `cb/(mb+cb)` I believe, and anything below 1 is considered a partial. This, however, calculates to 1 meaning it’s a hit.

Let me know if you think this isn’t accurate.
