Skip to content

Commit 84ce54b

Browse files
claudeandimarek
authored andcommitted
Require missed count increase for coverage regression detection
The coverage gate previously flagged any percentage drop > 0.05% as a regression. This caused false positives when well-covered code was extracted/moved out of a class — the percentage drops due to a ratio shift even though no test coverage was actually lost. Now a regression requires BOTH a percentage drop AND an increase in the absolute number of missed items. This correctly distinguishes real regressions (new uncovered code) from cosmetic ratio changes caused by refactoring. https://claude.ai/code/session_01XVBWUo2VM4B82ssZm1f2mu
1 parent 2c207e6 commit 84ce54b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎.github/workflows/pull_request.yml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,20 @@ jobs:
152152
const classCounters = parsed.classes;
153153
154154
// --- Coverage gate: fail if any class regresses on any metric ---
155+
// A regression requires BOTH a percentage drop AND an increase in the
156+
// absolute number of missed items. This avoids false positives when
157+
// well-covered code is extracted/moved out of a class (which lowers the
158+
// percentage without actually losing any test coverage).
155159
const regressions = [];
156160
for (const [cls, curr] of Object.entries(classCounters)) {
157161
const base = baseClasses[cls] || { line: zeroCov, branch: zeroCov, method: zeroCov };
158162
for (const [metric, key] of [['Line', 'line'], ['Branch', 'branch'], ['Method', 'method']]) {
159163
const currPct = pct(curr[key].covered, curr[key].missed);
160164
const basePct = pct(base[key].covered, base[key].missed);
161-
if (currPct < basePct - 0.05) {
162-
regressions.push(` ${cls} ${metric}: ${currPct.toFixed(1)}% (was ${basePct.toFixed(1)}%, delta ${(currPct - basePct).toFixed(1)}%)`);
165+
const currMissed = curr[key].missed;
166+
const baseMissed = base[key].missed;
167+
if (currPct < basePct - 0.05 && currMissed > baseMissed) {
168+
regressions.push(` ${cls} ${metric}: ${currPct.toFixed(1)}% (was ${basePct.toFixed(1)}%, delta ${(currPct - basePct).toFixed(1)}%, missed: ${currMissed} was ${baseMissed})`);
163169
}
164170
}
165171
}

0 commit comments

Comments
 (0)