export function getCoverageStats()

in common/output.ts [152:177]


export function getCoverageStats(c: Coverage, useDiffBlock: boolean): string {
  if (c.totalLines === 0 && c.totalCoveredLines === 0) {
    return ''
  }

  let stats = ''
  if (c.totalLines !== 0) {
    const conclusion = `${c.totalCoverage}% total lines covered`
    stats += `${makeConclusion(conclusion, c.totalCoverage < c.totalCoverageThreshold, useDiffBlock)}
${c.totalLines} lines analyzed, ${c.totalCoveredLines} lines covered`
  }

  if (c.freshLines !== 0) {
    const conclusion = `${c.freshCoverage}% fresh lines covered`
    stats += `
${makeConclusion(conclusion, c.freshCoverage < c.freshCoverageThreshold, useDiffBlock)}
${c.freshLines} lines analyzed, ${c.freshCoveredLines} lines covered`
  }

  const coverageBlock =  [
    `@@ Code coverage @@`,
    `${stats}`,
    `# Calculated according to the filters of your coverage tool`
  ].join('\n')
  return useDiffBlock ? wrapToDiffBlock(coverageBlock) : coverageBlock
}