/** * Smart Complexity Analysis Tool * * Analyzes code complexity metrics with intelligent caching * Calculates cyclomatic, cognitive, and Halstead metrics */ import { CacheEngine } from '../../core/cache-engine.js'; import { MetricsCollector } from '../../core/metrics.js'; import { TokenCounter } from '../../core/token-counter.js'; import { type Table } from '../shared/table.js'; export interface SmartComplexityOptions { filePath?: string; fileContent?: string; projectRoot?: string; includeHalstead?: boolean; includeMaintainability?: boolean; threshold?: { cyclomatic?: number; cognitive?: number; }; force?: boolean; maxCacheAge?: number; } export interface ComplexityMetrics { cyclomatic: number; cognitive: number; halstead?: HalsteadMetrics; maintainabilityIndex?: number; linesOfCode: number; logicalLinesOfCode: number; } export interface HalsteadMetrics { distinctOperators: number; distinctOperands: number; totalOperators: number; totalOperands: number; vocabulary: number; length: number; calculatedLength: number; volume: number; difficulty: number; effort: number; time: number; bugs: number; } export interface FunctionComplexity { name: string; location: { line: number; column: number; }; complexity: ComplexityMetrics; aboveThreshold: boolean; } export interface SmartComplexityResult { summary: { file: string; totalComplexity: ComplexityMetrics; averageComplexity: number; maxComplexity: number; functionsAboveThreshold: number; totalFunctions: number; riskLevel: 'low' | 'medium' | 'high' | 'critical'; fromCache: boolean; }; /** * One row per function, field names sent once. * * Decode with `decodeTable(result.functions)` for the * records. They were sent as an array of objects, which repeated all 24 * field names on every element -- about half of the 1639 tokens the block * cost on a 13-function file, to re-label numbers the first element had * already labelled. */ functions: Table; recommendations: string[]; } export declare class SmartComplexityTool { private cache; private metrics; private cacheNamespace; private projectRoot; constructor(cache: CacheEngine, _tokenCounter: TokenCounter, metrics: MetricsCollector, projectRoot?: string); run(options?: SmartComplexityOptions): Promise; private analyzeFunctions; private getFunctionName; private calculateComplexity; private calculateCyclomaticComplexity; private calculateCognitiveComplexity; private calculateHalsteadMetrics; private calculateMaintainabilityIndex; private countLines; private calculateFileMetrics; private generateRecommendations; private calculateRiskLevel; private generateCacheKey; private getCachedResult; private cacheResult; } export declare function getSmartComplexityTool(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector): SmartComplexityTool; export declare function runSmartComplexity(options: SmartComplexityOptions, cache?: CacheEngine, tokenCounter?: TokenCounter, metrics?: MetricsCollector): Promise; export { SMART_COMPLEXITY_TOOL_DEFINITION } from './analysis-tool-definitions.js'; //# sourceMappingURL=smart-complexity.d.ts.map