/** * Pass #30: redundant-loop-computation (CWE-1050, category: performance) * * Detects loop-invariant expressions that are recomputed on every iteration. * The most common and highest-signal patterns: * - `.length` / `.size()` / `.count()` on a variable not modified in the loop * - `Object.keys(x)` / `Object.values(x)` / `Object.entries(x)` on invariant `x` * - Pure math: `Math.sqrt(x)`, `Math.pow(x, n)`, `Math.abs(x)` on invariant args * * Detection strategy: * 1. Identify loop bodies via `graph.loopBodies()` (CFG back-edge derived). * 2. Build `modifiedVars`: DFG defs whose line falls inside the loop range. * 3. Scan source lines for the invariant patterns. * 4. If the receiver/argument variable is NOT in `modifiedVars`, emit a finding. * * Languages: JavaScript/TypeScript, Java, Python, Rust. Bash — skipped. */ import type { AnalysisPass, PassContext } from '../../graph/analysis-pass.js'; export interface RedundantLoopResult { invariants: Array<{ line: number; expression: string; variable: string; }>; } export declare class RedundantLoopPass implements AnalysisPass { readonly name = "redundant-loop-computation"; readonly category: "performance"; run(ctx: PassContext): RedundantLoopResult; } //# sourceMappingURL=redundant-loop-pass.d.ts.map