chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -26,8 +26,12 @@ type ToolRunOptions = {
};
function resolveNodeRunner(): NodeRunner {
if (hasBinary("pnpm")) return { cmd: "pnpm", args: ["dlx"] };
if (hasBinary("npx")) return { cmd: "npx", args: ["-y"] };
if (hasBinary("pnpm")) {
return { cmd: "pnpm", args: ["dlx"] };
}
if (hasBinary("npx")) {
return { cmd: "npx", args: ["-y"] };
}
throw new Error("Missing pnpm or npx; install a Node package runner.");
}
@@ -52,15 +56,21 @@ async function runTool(tool: string, toolArgs: string[], options: ToolRunOptions
function extractLine(lines: string[], prefix: string): string | undefined {
const line = lines.find((value) => value.startsWith(prefix));
if (!line) return undefined;
if (!line) {
return undefined;
}
return line.slice(prefix.length).trim();
}
function normalizeSnippet(raw: string | undefined, fallback: string): string {
const base = raw && raw.trim().length > 0 ? raw : fallback;
const cleaned = base.replace(/\s+/g, " ").trim();
if (!cleaned) return "";
if (cleaned.length <= DEFAULT_SNIPPET_MAX) return cleaned;
if (!cleaned) {
return "";
}
if (cleaned.length <= DEFAULT_SNIPPET_MAX) {
return cleaned;
}
return `${cleaned.slice(0, DEFAULT_SNIPPET_MAX - 3)}...`;
}
@@ -84,7 +94,9 @@ function parseSearchOutput(raw: string): DocResult[] {
const lines = block.split("\n");
const title = extractLine(lines, "Title:");
const link = extractLine(lines, "Link:");
if (!title || !link) continue;
if (!title || !link) {
continue;
}
const content = extractLine(lines, "Content:");
const contentIndex = lines.findIndex((line) => line.startsWith("Content:"));
const body =