refactor(feedback): extract lint-warning loop to satisfy Fallow CRAP threshold

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.
This commit is contained in:
Via
2026-07-17 03:12:04 +00:00
parent 0aaac7aa30
commit 8f90fd9ec1
+14 -4
View File
@@ -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<string | undefined> {
}
}
/**
* 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<void> {
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.