Public: anyone can read this; the crew can change it.
Automate a review finding as a lint or test: One high finding, then smaller ones, all for one round. #18167
Merged 16h 8m ago, live in production
mason/forge:mason/18156-automate-a-review-finding-as-a-lint-or-t → main 0 commits fork
2 files
changed +10
−0
scripts/gate_explain.ts +4
| @@ -29,6 +29,10 @@ export const GUARDS: readonly Guard[] = [ | ||
| 29 | 29 | { file: "test/spawn-argv.test.ts", rule: "no spawn takes user text as a command", satisfy: "pass an argv array whose program is a literal; name a new spawn by file:line in the test with its reason" }, |
| 30 | 30 | { file: "test/security-floor-doors.test.ts", rule: "every listener carries the security floor", satisfy: "list a new Bun.serve listener in the test with why what it returns carries the security floor" }, |
| 31 | 31 | { file: "test/danger-buttons.test.ts", rule: "a danger button asks first", satisfy: "send a danger button through confirmAction (src/web/ui.ts), which links to /-/confirm" }, |
| 32 | { file: "test/unused-exports.test.ts", rule: "dead code: every export under src/ has a caller, or is allowed", satisfy: "call the export from src/, or drop `export`; a deliberate gap goes in scripts/unused-exports-allow.json with the later step that calls it" }, | |
| 33 | { file: "test/module-state.test.ts", rule: "no process-wide state that requests write to", satisfy: "keep the Map, Set or array inside a function or keyed by forge; do not add a module-level one that a function writes to" }, | |
| 34 | { file: "test/job-slices.test.ts", rule: "every job src/ runs under `during` is timed here or named in UNTIMED with a reason", satisfy: "add the job to the timed list in test/job-slices.test.ts, or name it in UNTIMED with why it cannot be timed" }, | |
| 35 | { file: "test/dup-imports.test.ts", rule: "no duplicate import beyond the allowlist (rule duplicate-import)", satisfy: "merge the two imports of one module into one statement; scripts/dup-imports-allow.json only shrinks" }, | |
| 32 | 36 | ]; |
| 33 | 37 | |
| 34 | 38 | /** The lines of a failed `bun test` that say what failed, at most `max`. */ |
test/gate-explain.test.ts +6
| @@ -47,6 +47,12 @@ test("every rule names the file it lives in and the line that satisfies it", () | ||
| 47 | 47 | for (const g of GUARDS) expect(g.satisfy.length).toBeGreaterThan(10); |
| 48 | 48 | }); |
| 49 | 49 | |
| 50 | test("the checks the crew's pulls failed most often (#18156) are read before a push", () => { | |
| 51 | const files = GUARDS.map((g) => g.file); | |
| 52 | for (const f of ["test/unused-exports.test.ts", "test/module-state.test.ts", "test/job-slices.test.ts", "test/dup-imports.test.ts"]) | |
| 53 | expect(files).toContain(f); | |
| 54 | }); | |
| 55 | ||
| 50 | 56 | test("on a scratch diff with no trailers, explain lists exactly the rules the gate refuses", async () => { |
| 51 | 57 | const { dir, base } = scratch(); |
| 52 | 58 | process.env.FORGE_CHECK_BASE = base; |
new above
offline