in common/qodana.ts [251:295]
export function getCoverageFromSarif(sarifPath: string): Coverage {
if (fs.existsSync(sarifPath)) {
const sarifContents = JSON.parse(
fs.readFileSync(sarifPath, {encoding: 'utf8'})
)
if (sarifContents.runs[0].properties['coverage']) {
return {
totalCoverage:
sarifContents.runs[0].properties['coverage']['totalCoverage'] || 0,
totalLines:
sarifContents.runs[0].properties['coverage']['totalLines'] || 0,
totalCoveredLines:
sarifContents.runs[0].properties['coverage']['totalCoveredLines'] ||
0,
freshCoverage:
sarifContents.runs[0].properties['coverage']['freshCoverage'] || 0,
freshLines:
sarifContents.runs[0].properties['coverage']['freshLines'] || 0,
freshCoveredLines:
sarifContents.runs[0].properties['coverage']['freshCoveredLines'] ||
0,
totalCoverageThreshold:
sarifContents.runs[0].properties['qodanaFailureConditions']?.[
'testCoverageThresholds'
]?.['totalCoverage'] || COVERAGE_THRESHOLD,
freshCoverageThreshold:
sarifContents.runs[0].properties['qodanaFailureConditions']?.[
'testCoverageThresholds'
]?.['freshCoverage'] || COVERAGE_THRESHOLD
}
} else {
return {
totalCoverage: 0,
totalLines: 0,
totalCoveredLines: 0,
freshCoverage: 0,
freshLines: 0,
freshCoveredLines: 0,
totalCoverageThreshold: COVERAGE_THRESHOLD,
freshCoverageThreshold: COVERAGE_THRESHOLD
}
}
}
throw new Error(`SARIF file not found: ${sarifPath}`)
}