/** * Pass #79: variable-shadowing (CWE-1109, category: reliability) * * Detects when an inner scope declares a variable with the same name as an * outer-scope declaration or function parameter, hiding the outer binding and * making code harder to reason about. * * Detection strategy: * 1. Build a ScopeGraph to identify which defs are true declarations vs * bare reassignments. * 2. For each method, group DFG defs by variable name. * 3. Flag two kinds of shadowing within the same method: * - Param shadow : a `kind='param'` def + a later `kind='local'` def * that is a real declaration (has a decl keyword, or Python which has * no keywords but every local assignment implicitly shadows a param). * - Outer-local shadow : two or more `kind='local'` defs that both have * a declaration keyword (e.g. `let x = 1` then `let x = 2` in a * nested block). * * Note on Python: Python variables have function scope (not block scope), so * two assignments to the same name within a function do NOT shadow each other. * However, a local assignment that shares a name with a parameter DOES shadow * the parameter (from the assignment point onward). The pass flags that case * for Python regardless of `hasDeclKeyword` (since Python has no decl keywords). */ import type { AnalysisPass, PassContext } from '../../graph/analysis-pass.js'; export interface VariableShadowingResult { shadows: Array<{ /** Line of the shadowing (inner) declaration. */ line: number; variable: string; /** Line of the shadowed (outer) declaration or parameter. */ shadowedAt: number; kind: 'param' | 'outer-local'; }>; } export declare class VariableShadowingPass implements AnalysisPass { readonly name = "variable-shadowing"; readonly category: "reliability"; run(ctx: PassContext): VariableShadowingResult; } //# sourceMappingURL=variable-shadowing-pass.d.ts.map