From 8f90fd9ec1aecd20f678ccf0617efea06adfda56 Mon Sep 17 00:00:00 2001 From: Via Date: Fri, 17 Jul 2026 03:11:36 +0000 Subject: [PATCH] refactor(feedback): extract lint-warning loop to satisfy Fallow CRAP threshold MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The added `for...of` loop over `lintFeedbackComment` warnings pushed the `run` function's cyclomatic complexity from 4 to 5, landing the CRAP score at exactly the 30.0 Fallow threshold. Extract the loop into `printFeedbackLintWarnings` so `run` stays a flat driver — the helper carries the incidental complexity. No behavior change; all 29 unit tests + typecheck + oxlint + oxfmt + local `fallow audit --base origin/main` pass clean. --- packages/cli/src/commands/feedback.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/feedback.ts b/packages/cli/src/commands/feedback.ts index fc06b0cd8..e2a1d81e0 100644 --- a/packages/cli/src/commands/feedback.ts +++ b/packages/cli/src/commands/feedback.ts @@ -12,7 +12,7 @@ import { buildIssueUrl, HYPERFRAMES_REPO_URL } from "../utils/feedbackIssue.js"; import { VERSION } from "../version.js"; import { c } from "../ui/colors.js"; import { parseFeedbackRating } from "../utils/feedbackRating.js"; -import { lintFeedbackComment } from "../utils/feedbackLint.js"; +import { lintFeedbackComment, type FeedbackLintInput } from "../utils/feedbackLint.js"; export const examples: Example[] = [ ["Submit render feedback", 'hyperframes feedback --rating 8 --comment "fast but font missing"'], @@ -79,6 +79,18 @@ async function publishRepro(dir: string): Promise { } } +/** + * Print soft-warn feedback-lint messages to stdout. Extracted so the + * command's `run` stays a flat control-flow driver — the warning loop is + * incidental to the command logic and its complexity would otherwise push + * `run` over the Fallow CRAP threshold. + */ +function printFeedbackLintWarnings(input: FeedbackLintInput): void { + for (const warning of lintFeedbackComment(input)) { + console.log(c.warn(`⚠ ${warning.message}`)); + } +} + async function openAndPrintIssue(url: string): Promise { if (process.stdout.isTTY) { try { @@ -160,9 +172,7 @@ export default defineCommand({ // Soft-warn (never blocks) when the comment for a non-clean report is // missing the mandated reproduction-packet markers. Prints before the // submission ack so the reporter sees the nudge while their run is fresh. - for (const warning of lintFeedbackComment({ rating, comment })) { - console.log(c.warn(`⚠ ${warning.message}`)); - } + printFeedbackLintWarnings({ rating, comment }); // The standalone command runs separately from `render`, so it has no real // elapsed time to report. Omit it rather than recording a fake duration.