/** * Duplicate Code Detector * * Detects code clones using pure static analysis — no LLM calls: * - Type 1 (exact): identical code after whitespace/comment normalization * - Type 2 (structural): same AST structure with renamed variables * - Type 3 (near): high Jaccard similarity on token n-grams (≥ 0.7) * * Requires a CallGraphResult for precise function boundaries (byte ranges). * Complexity: O(n) for Types 1-2, O(n²) for Type 3 (bounded by MAX_NEAR_FUNCTIONS). */ import type { CallGraphResult } from './call-graph.js'; export interface CloneInstance { file: string; functionName: string; className?: string; startLine: number; endLine: number; } /** 'exact' = identical after normalization, 'structural' = same shape renamed, 'near' = high Jaccard */ export type CloneType = 'exact' | 'structural' | 'near'; export interface CloneGroup { type: CloneType; /** 1.0 for exact/structural; Jaccard similarity for near */ similarity: number; instances: CloneInstance[]; /** Number of lines in the smallest instance of the cloned block */ lineCount: number; } export interface DuplicateDetectionResult { cloneGroups: CloneGroup[]; stats: { /** Functions analyzed (above minimum size threshold) */ totalFunctions: number; /** Functions that appear in at least one clone group */ duplicatedFunctions: number; /** duplicatedFunctions / totalFunctions */ duplicationRatio: number; /** Number of distinct clone groups */ cloneGroupCount: number; }; } /** * Detect duplicate functions across the codebase using the call graph's * function nodes (which carry byte-range boundaries) and the original file * contents. */ export declare function detectDuplicates(files: Array<{ path: string; content: string; }>, callGraph: CallGraphResult): DuplicateDetectionResult; //# sourceMappingURL=duplicate-detector.d.ts.map