CodeCov false positive - Configuration-as-Code


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:

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

Repository /jenkinsci/configuration-as-code-plugin




CodeCov GitHub Action

Commit SHAs

Codecov YAML

  layout: "header, diff, tree, changes"

Codecov Output

Additional Information


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="">
   <line nr="343" mi="0" ci="5" mb="0" cb="2" />

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.