function detectTodoAbuse(ast) {
const todos = ast.comments.filter(c => c.value.includes("TODO"));
if (todos.length > threshold) {
emit("todo-abuse", { count: todos.length });
}
}
function detectCopiedStackOverflow(node) {
const sig = hashSignature(node);
if (knownSnippets.has(sig)) return flag("copied-snippet");
}
const DETECTOR_REGISTRY = {
"empty-catch": emptyCatchDetector,
"god-function": godFunctionDetector,
"magic-number": magicNumberDetector,
"dead-code": deadCodeDetector,
"console-spam": consoleSpamDetector,
};
export async function runPipeline(files) {
const results = [];
for (const file of files) {
const ast = parse(file.content);
for (const [id, detect] of Object.entries(DETECTORS)) {
const findings = detect(ast, file.path);
results.push(...findings);
}
}
return results;
}
function measureComplexity(fn) {
let score = 1;
walk(fn.body, (node) => {
if (isBranch(node)) score++;
});
return score;
}
if (complexity > 15) {
report("high-complexity", {
score: complexity,
threshold: 15,
suggestion: "break this function apart"
});
}
function detectTodoAbuse(ast) {
const todos = ast.comments.filter(c => c.value.includes("TODO"));
if (todos.length > threshold) {
emit("todo-abuse", { count: todos.length });
}
}
function detectCopiedStackOverflow(node) {
const sig = hashSignature(node);
if (knownSnippets.has(sig)) return flag("copied-snippet");
}
const DETECTOR_REGISTRY = {
"empty-catch": emptyCatchDetector,
"god-function": godFunctionDetector,
"magic-number": magicNumberDetector,
"dead-code": deadCodeDetector,
"console-spam": consoleSpamDetector,
};
export async function runPipeline(files) {
const results = [];
for (const file of files) {
const ast = parse(file.content);
for (const [id, detect] of Object.entries(DETECTORS)) {
const findings = detect(ast, file.path);
results.push(...findings);
}
}
return results;
}
function measureComplexity(fn) {
let score = 1;
walk(fn.body, (node) => {
if (isBranch(node)) score++;
});
return score;
}
if (complexity > 15) {
report("high-complexity", {
score: complexity,
threshold: 15,
suggestion: "break this function apart"
});
}