/** * Pass #82: unused-variable (CWE-561, category: reliability) * * Detects local variables that are declared but whose value is never read. * This includes variables whose value is overwritten before any read * (the initial assignment is "dead" from a data-flow perspective). * * Detection strategy: * 1. For each `kind='local'` DFG def: * - Skip intentional throwaway names (`_`, `err`, `e`, loop variables…). * - Skip variables in `catch` blocks (common pattern to capture but ignore * exceptions: `catch (err) { ... }`). * - Call `graph.usesOfDef(def.id)` — returns uses with `def_id === defId`. * - If the result is empty, no code ever reads the value stored by this * definition → flag as unused. * * Notes: * - Test files are excluded to reduce noise (test helpers often define * variables for side-effect checks). * - Parameters (`kind='param'`) are excluded — unused parameters are common * in callbacks and overriding methods and produce too many false positives. * - Fields (`kind='field'`) are excluded — class fields are often read via * `this.x` in ways the DFG may not track precisely. */ import type { AnalysisPass, PassContext } from '../../graph/analysis-pass.js'; export interface UnusedVariableResult { unusedVars: Array<{ line: number; variable: string; }>; } export declare class UnusedVariablePass implements AnalysisPass { readonly name = "unused-variable"; readonly category: "reliability"; run(ctx: PassContext): UnusedVariableResult; } //# sourceMappingURL=unused-variable-pass.d.ts.map