CodeCov false positive - Configuration-as-Code

Description

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

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

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

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

instead of more normally formatted.

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

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

Repository

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

CI/CD

GitHub

Uploader

CodeCov GitHub Action

Commit SHAs

Codecov YAML

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

1 Like

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

I took a look into this commit, and pulled up one of the raw builds.

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

<?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.