/** * Refactoring Suggester Service * * Generates intelligent refactoring suggestions based on detected code smells. * Provides priority scoring, impact analysis, and actionable recommendations. * * Supported Refactoring Patterns: * 1. Extract Method (for God Functions and Long Functions) * 2. Introduce Parameter Object (for Long Parameter Lists) * 3. Remove Dead Code (for Dead Code smells) * 4. Inline Function (for trivial wrappers) * 5. Rename Symbol (for poor naming) * 6. Split Function (for functions doing too much) */ import type { QueryService, CodeEntityInfo } from '../domain/query/queryService.js'; import type { CodeSmell } from './codeSmellDetector.js'; /** * Refactoring pattern types */ export type RefactoringPattern = 'extract-method' | 'introduce-parameter-object' | 'remove-dead-code' | 'inline-function' | 'rename-symbol' | 'split-function'; /** * Priority level for refactoring */ export type RefactoringPriority = 'high' | 'medium' | 'low'; /** * A specific refactoring suggestion */ export interface RefactoringSuggestion { id: string; pattern: RefactoringPattern; priority: RefactoringPriority; targetEntity: CodeEntityInfo; smell?: CodeSmell; title: string; description: string; reasoning: string; benefits: string[]; risks: string[]; score: { benefit: number; risk: number; effort: number; impact: number; overall: number; }; steps: string[]; estimatedTime?: string; affectedFiles?: string[]; } /** * Input for refactoring suggestion */ export interface SuggestRefactoringsInput { projectPath: string; smells?: CodeSmell[]; targetSymbol?: string; maxSuggestions?: number; } /** * Result of refactoring suggestion */ export interface SuggestRefactoringsResult { projectPath: string; suggestions: RefactoringSuggestion[]; summary: { totalSuggestions: number; byPattern: Record; byPriority: Record; }; stats: { analysisTimeMs: number; }; } /** * Service for generating refactoring suggestions */ export declare class RefactoringSuggester { private readonly deps; constructor(deps: { queryService: QueryService; }); /** * Generate refactoring suggestions based on code smells */ suggestRefactorings(input: SuggestRefactoringsInput): Promise; /** * Generate suggestions for a specific code smell */ private generateSuggestionsForSmell; /** * Suggest Extract Method refactoring for God Function */ private suggestExtractMethod; /** * Suggest Split Function for Long Function */ private suggestSplitFunction; /** * Suggest Introduce Parameter Object for Long Parameter List */ private suggestParameterObject; /** * Suggest Remove Dead Code */ private suggestRemoveDeadCode; /** * Group callees by logical concern (heuristic based on naming) */ private groupCalleesByLogic; /** * Calculate priority based on smell severity and metrics */ private calculatePriority; /** * Calculate impact score (number of callers) */ private calculateImpact; /** * Calculate overall score from components */ private calculateOverallScore; /** * Estimate time based on complexity */ private estimateTime; /** * Capitalize first letter */ private capitalize; /** * Generate summary statistics */ private generateSummary; }