Skip to content

Commit 4c32c97

Browse files
committed
fix(ci): enforce outside-diff CodeRabbit findings
1 parent 2468502 commit 4c32c97

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

‎.github/scripts/pr-quality-state.cjs‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,9 @@ function coderabbitOutsideDiffFindings({ reviews = [], liveHeadSha }) {
296296
* only in its review body (outside the diff range); those are added by the
297297
* `coderabbitOutsideDiffFindings` supplement so they cannot slip through.
298298
* The supplement is subordinate: it never subtracts, only adds unresolved
299-
* counts for the live head while a bot thread is still open. A review body is
300-
* immutable, so the count can never fall to zero on its own once posted; the
301-
* supplement therefore only counts while an unresolved bot thread exists — the
302-
* author resolves that thread to clear the box, matching the checklist wording
303-
* ("I resolved all correct ... findings") without requiring an empty commit.
299+
* counts for the live head. Review-body-only findings must be checked even when
300+
* CodeRabbit did not create a review thread; otherwise those findings would
301+
* have no signal capable of keeping the checklist claim unticked.
304302
*/
305303
function unresolvedFindingsClaim({ threads = [], reviews = [], liveHeadSha }) {
306304
const byBot = {};
@@ -313,13 +311,11 @@ function unresolvedFindingsClaim({ threads = [], reviews = [], liveHeadSha }) {
313311
unresolved += 1;
314312
}
315313
}
316-
if (unresolved > 0) {
317-
const outside = coderabbitOutsideDiffFindings({ reviews, liveHeadSha });
318-
if (outside.code) {
319-
for (const [login, count] of Object.entries(outside.byBot)) {
320-
byBot[login] = (byBot[login] ?? 0) + count;
321-
unresolved += count;
322-
}
314+
const outside = coderabbitOutsideDiffFindings({ reviews, liveHeadSha });
315+
if (outside.code) {
316+
for (const [login, count] of Object.entries(outside.byBot)) {
317+
byBot[login] = (byBot[login] ?? 0) + count;
318+
unresolved += count;
323319
}
324320
}
325321
return unresolved > 0

‎.github/scripts/pr-quality-state.test.cjs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,15 +460,17 @@ describe("coderabbitOutsideDiffFindings", () => {
460460
describe("unresolvedFindingsClaim with outside-diff supplement", () => {
461461
const HEAD = "3f1c0de0a6a4d0a3f9a1b2c3d4e5f60718293a4b";
462462

463-
it("does not count outside-diff when no unresolved bot thread exists", () => {
464-
// The review body is immutable; once the author resolves every thread the
465-
// supplement must not keep the box unticked forever (no empty commit).
463+
it("counts outside-diff findings when no unresolved bot thread exists", () => {
466464
const claim = unresolvedFindingsClaim({
467465
threads: [],
468466
reviews: [{ body: "**Actionable comments posted: 2**", commit_id: HEAD, submitted_at: "2026-08-04T06:24:02Z", user: { login: "coderabbitai[bot]" } }],
469467
liveHeadSha: HEAD,
470468
});
471-
assert.deepEqual(claim, { code: null, unresolved: 0, byBot: {} });
469+
assert.deepEqual(claim, {
470+
code: "review_findings",
471+
unresolved: 2,
472+
byBot: { "coderabbitai[bot]": 2 },
473+
});
472474
});
473475

474476
it("adds the outside-diff count to an unresolved thread count", () => {

0 commit comments

Comments
 (0)