Skip to content

Commit 399a8fc

Browse files
committed
Reject an empty --report= even when --no-report is also given
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TrbmayRraf25aTwCCj1iv2
1 parent 47b0567 commit 399a8fc

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎ai-slop-detector.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,10 @@ export function unknownFlags(flagArgs: readonly string[]): string[] {
279279

280280
/** Where to write the JSON report: `--report=<path>`, nowhere with `--no-report`, else ./ai-slop-report.json. */
281281
export function reportPathFrom(flagArgs: readonly string[], rootDir: string): string | undefined {
282-
if (flagArgs.includes('--no-report')) return undefined;
283282
const flag = flagArgs.filter(arg => arg.startsWith('--report=')).at(-1);
284283
const value = flag?.slice('--report='.length);
285284
if (value === '') throw new UsageError('--report needs a file path, e.g. --report=reports/karpeslop.json');
285+
if (flagArgs.includes('--no-report')) return undefined;
286286
return path.resolve(rootDir, value ?? 'ai-slop-report.json');
287287
}
288288

‎tests/ai-slop-detector.behavior.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ test('the report path comes from --report=<path>, and --no-report writes none',
643643
assert.equal(reportPathFrom(['--report=out/k.json'], '/repo'), path.resolve('/repo', 'out/k.json'));
644644
assert.equal(reportPathFrom(['--report=a.json', '--no-report'], '/repo'), undefined);
645645
assert.throws(() => reportPathFrom(['--report='], '/repo'), /--report needs a file path/);
646+
assert.throws(() => reportPathFrom(['--report=', '--no-report'], '/repo'), /--report needs a file path/);
646647
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'karpeslop-report-'));
647648
fs.writeFileSync(path.join(projectDir, 'index.ts'), 'export const a = 1;\n', 'utf-8');
648649
const run = (...flags: string[]) => spawnSync(

0 commit comments

Comments
 (0)