diff --git a/scan/__tests__/data/some.sarif.json b/scan/__tests__/data/some.sarif.json index 296000c6..35af98ad 100644 --- a/scan/__tests__/data/some.sarif.json +++ b/scan/__tests__/data/some.sarif.json @@ -8261,13 +8261,16 @@ "qodanaFailureConditions": { "testCoverageThresholds": { "totalCoverage": 40, - "freshCoverage": 40 + "freshCoverage": 30 } }, "coverage": { "totalCoverage": 45.0, "totalLines": 124.0, - "totalCoveredLines": 56.0 + "totalCoveredLines": 56.0, + "freshCoverage": 33.0, + "freshLines": 9.0, + "freshCoveredLines": 3.0 } } } diff --git a/scan/__tests__/main.test.ts b/scan/__tests__/main.test.ts index 3605b1d9..a83e9ed8 100644 --- a/scan/__tests__/main.test.ts +++ b/scan/__tests__/main.test.ts @@ -362,6 +362,8 @@ function passedCoverageFixture(): string { @@ Code coverage @@ + 45% total lines covered 124 lines analyzed, 56 lines covered ++ 33% fresh lines covered +9 lines analyzed, 3 lines covered # Calculated according to the filters of your coverage tool \`\`\`` } @@ -371,7 +373,7 @@ function failedCoverageFixture(): string { @@ Code coverage @@ - 0% total lines covered 100 lines analyzed, 0 lines covered -! 0% fresh lines covered +- 0% fresh lines covered 100 lines analyzed, 0 lines covered # Calculated according to the filters of your coverage tool \`\`\`` diff --git a/scan/dist/index.js b/scan/dist/index.js index 3d8f417a..a06b2e94 100644 --- a/scan/dist/index.js +++ b/scan/dist/index.js @@ -137094,24 +137094,28 @@ ${message} \`\`\``; } __name(wrapToDiffBlock, "wrapToDiffBlock"); + function makeConclusion(conclusion, failedByThreshold) { + if (failedByThreshold) { + return `- ${conclusion}`; + } else { + return `+ ${conclusion}`; + } + } + __name(makeConclusion, "makeConclusion"); function getCoverageStats(c) { if (c.totalLines === 0 && c.totalCoveredLines === 0) { return ""; } let stats = ""; if (c.totalLines !== 0) { - let conclusion = `${c.totalCoverage}% total lines covered`; - if (c.totalCoverage < c.totalCoverageThreshold) { - conclusion = `- ${conclusion}`; - } else { - conclusion = `+ ${conclusion}`; - } - stats += `${conclusion} + const conclusion = `${c.totalCoverage}% total lines covered`; + stats += `${makeConclusion(conclusion, c.totalCoverage < c.totalCoverageThreshold)} ${c.totalLines} lines analyzed, ${c.totalCoveredLines} lines covered`; } if (c.freshLines !== 0) { + const conclusion = `${c.freshCoverage}% fresh lines covered`; stats += ` -! ${c.freshCoverage}% fresh lines covered +${makeConclusion(conclusion, c.freshCoverage < c.freshCoverageThreshold)} ${c.freshLines} lines analyzed, ${c.freshCoveredLines} lines covered`; } return wrapToDiffBlock([ diff --git a/scan/src/output.ts b/scan/src/output.ts index 0deebca9..e03e8c54 100644 --- a/scan/src/output.ts +++ b/scan/src/output.ts @@ -90,6 +90,17 @@ ${message} \`\`\`` } +function makeConclusion( + conclusion: string, + failedByThreshold: boolean +): string { + if (failedByThreshold) { + return `- ${conclusion}` + } else { + return `+ ${conclusion}` + } +} + export function getCoverageStats(c: Coverage): string { if (c.totalLines === 0 && c.totalCoveredLines === 0) { return '' @@ -97,19 +108,15 @@ export function getCoverageStats(c: Coverage): string { let stats = '' if (c.totalLines !== 0) { - let conclusion = `${c.totalCoverage}% total lines covered` - if (c.totalCoverage < c.totalCoverageThreshold) { - conclusion = `- ${conclusion}` - } else { - conclusion = `+ ${conclusion}` - } - stats += `${conclusion} + const conclusion = `${c.totalCoverage}% total lines covered` + stats += `${makeConclusion(conclusion, c.totalCoverage < c.totalCoverageThreshold)} ${c.totalLines} lines analyzed, ${c.totalCoveredLines} lines covered` } if (c.freshLines !== 0) { + const conclusion = `${c.freshCoverage}% fresh lines covered` stats += ` -! ${c.freshCoverage}% fresh lines covered +${makeConclusion(conclusion, c.freshCoverage < c.freshCoverageThreshold)} ${c.freshLines} lines analyzed, ${c.freshCoveredLines} lines covered` } diff --git a/vsts/vss-extension.dev.json b/vsts/vss-extension.dev.json index 0c9a2028..c926d6d4 100644 --- a/vsts/vss-extension.dev.json +++ b/vsts/vss-extension.dev.json @@ -2,7 +2,7 @@ "manifestVersion": 1, "id": "qodana-dev", "name": "Qodana (Dev)", - "version": "2024.3.155", + "version": "2024.3.156", "publisher": "JetBrains", "targets": [ {