/** * Refactoring Priority Analyzer * * Combines call graph metrics with requirement mappings to produce a * prioritized list of refactoring candidates. Output is a flat JSON array * suitable for consumption by a coding assistant. * * Metrics per function: * fanIn — number of internal callers * fanOut — number of internal callees * depth — hops from nearest entry point (-1 = unreachable) * sccSize — strongly connected component size (>1 = in a cycle) * requirements — list of requirement names this function implements * * Issues detected: * unreachable — not reachable from any entry point AND no requirements * high_fan_in — fanIn >= HIGH_FAN_IN (likely hub utility) * high_fan_out — fanOut >= HIGH_FAN_OUT (likely god function / orchestrator) * multi_requirement — implements > SRP_MAX requirements (SRP violation) * in_cycle — part of a cyclic dependency (sccSize > 1) * in_clone_group — appears in a duplicate code clone group */ import type { SerializedCallGraph } from './call-graph.js'; import type { DuplicateDetectionResult } from './duplicate-detector.js'; export type RefactorIssue = 'unreachable' | 'high_fan_in' | 'high_fan_out' | 'multi_requirement' | 'in_cycle' | 'in_clone_group' | 'high_complexity'; export interface RefactorEntry { function: string; file: string; className?: string; fanIn: number; fanOut: number; /** Hops from nearest entry point. -1 = unreachable */ depth: number; /** SCC size. 1 = no cycle. >1 = part of a cycle */ sccSize: number; /** Requirement names this function is mapped to */ requirements: string[]; issues: RefactorIssue[]; /** McCabe cyclomatic complexity (undefined if analysis pre-dates this feature) */ cyclomaticComplexity?: number; /** Composite priority score for sorting (higher = more urgent) */ priorityScore: number; } export interface CycleSummary { sccId: number; size: number; participants: Array<{ function: string; file: string; }>; } export interface RefactorReport { generatedAt: string; stats: { totalFunctions: number; withIssues: number; unreachable: number; highFanIn: number; highFanOut: number; srpViolations: number; cycleParticipants: number; cyclesDetected: number; highComplexity: number; }; /** Functions with at least one issue, sorted by priorityScore descending */ priorities: RefactorEntry[]; cycles: CycleSummary[]; } export interface MappingEntry { requirement: string; functions: Array<{ name: string; file: string; }>; } /** * Analyze a call graph for refactoring priorities. * * @param callGraph Serialized call graph from the analyzer * @param mappings Optional: requirement mappings from mapping.json */ export declare function analyzeForRefactoring(callGraph: SerializedCallGraph, mappings?: MappingEntry[], duplicates?: DuplicateDetectionResult): RefactorReport; //# sourceMappingURL=refactor-analyzer.d.ts.map