danger-plugin-istanbul-coverage icon indicating copy to clipboard operation
danger-plugin-istanbul-coverage copied to clipboard

Wrong code coverage report message for with only files that have 0 coverage

Open pc-mwong opened this issue 4 years ago • 3 comments

issue is occurring when using the createdOrModifed config option

If the created or modified list contains only files with 0 code coverage then the wrong message appears

See examples below (2 PRS)

Screen Shot 2020-12-14 at 10 36 49 AM Screen Shot 2020-12-14 at 10 47 12 AM

pc-mwong avatar Dec 14 '20 18:12 pc-mwong

appears to be caused by percentage calculation logic in the combineItems function

is this intended? what is the reason for setting the percentage to 100 if second.covered + first.covered <= 0 ?

const combineItems = (first, second) => {
  const percentage =
    second.covered + first.covered > 0
      ? (100 * (first.covered + second.covered)) / (second.total + first.total)
      : 100;

  return {
    total: first.total + second.total,
    covered: first.covered + second.covered,
    skipped: first.skipped + second.skipped,
    pct: percentage,
  };
};

pc-mwong avatar Dec 14 '20 18:12 pc-mwong

I am experiencing the same issue which brought me here. Displaying 100% instead of 0% in this scenario is incorrect. Can this be corrected please?

singhrasster avatar Jul 16 '23 19:07 singhrasster

@pc-mwong You created this issue over 2.5 years ago, but this issue still exists. Are you still managing with this issue being there? Or found a workaround, because constantly showing 0 for this scenario is misleading?

singhrasster avatar Jul 16 '23 19:07 singhrasster