Skip to content

Commit cbae02a

Browse files
committed
fix(test): reduce makeCase assert() complexity for Fallow Code Quality gate
The sequentialSteps branch pushed makeCase's assert() over the cyclomatic/CRAP complexity thresholds (CI: Fallow Code Quality). Extract the optional per-case checks (strictFinalOutput, allowOnlyLocalCliHelpCommands, sequentialSteps) into a small data-driven runOptionalCaseAssertions loop instead of sequential ifs. Verified with `npx fallow audit --base origin/main` locally (clean) and re-ran the six synthetic finalOutput dry-run checks against the ios-system-ui-springboard-widget-add case; behavior unchanged.
1 parent b8366d2 commit cbae02a

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

test/skillgym/suites/agent-device-smoke-suite.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,12 @@ function assertSequentialCommandSteps(
488488
}
489489
}
490490

491+
function runOptionalCaseAssertions(checks: ReadonlyArray<{ active: boolean; run: () => void }>) {
492+
for (const check of checks) {
493+
if (check.active) check.run();
494+
}
495+
}
496+
491497
function makeCase(options: {
492498
id: string;
493499
contract: string[];
@@ -516,15 +522,21 @@ function makeCase(options: {
516522
});
517523
assertExpectedOutput(report, ctx, options.outputs);
518524
assertNoOutputs(ctx.finalOutput(), options.forbiddenOutputs ?? []);
519-
if (options.strictFinalOutput) {
520-
assertFinalOutputAgentDeviceCommandsOnly(ctx.finalOutput());
521-
}
522-
if (options.allowOnlyLocalCliHelpCommands) {
523-
assertOnlyLocalCliHelpCommands(report);
524-
}
525-
if (options.sequentialSteps) {
526-
assertSequentialCommandSteps(ctx.finalOutput(), options.sequentialSteps, options.id);
527-
}
525+
runOptionalCaseAssertions([
526+
{
527+
active: options.strictFinalOutput === true,
528+
run: () => assertFinalOutputAgentDeviceCommandsOnly(ctx.finalOutput()),
529+
},
530+
{
531+
active: options.allowOnlyLocalCliHelpCommands === true,
532+
run: () => assertOnlyLocalCliHelpCommands(report),
533+
},
534+
{
535+
active: options.sequentialSteps !== undefined,
536+
run: () =>
537+
assertSequentialCommandSteps(ctx.finalOutput(), options.sequentialSteps!, options.id),
538+
},
539+
]);
528540
},
529541
};
530542
}

0 commit comments

Comments
 (0)