UNPKG

static-code-analyzer

Version:

Universal static code analysis tool for calculating API operation costs across multiple frameworks (NestJS, Express, Fastify)

128 lines 3.58 kB
export interface AnalyzerConfig { /** Database operation cost definitions */ operations: Record<string, number>; /** Pattern matching rules for different frameworks */ patterns: { [frameworkName: string]: { pattern: string | RegExp; operations?: Record<string, number>; defaultCost?: number; description?: string; }; }; /** Parallel execution patterns to detect */ parallelExecutionPatterns: string[]; /** Patterns to ignore during analysis */ ignorePatterns: string[]; /** Cost multipliers for different code structures */ costMultipliers: { loop: number; recursion: number; nested: number; conditional: number; }; /** Expected costs for validation (optional) */ methodCosts?: { [methodName: string]: { paths?: Array<{ name: string; conditions?: string[]; expectedCost: number; }>; expectedCost?: number; }; }; } export interface DatabaseOperation { method: string; cost: number; line: number; conditions: string[]; isParallel?: boolean; expression: string; isComposite?: boolean; framework?: string; } export interface ExecutionPath { name: string; conditions: string[]; operations: DatabaseOperation[]; totalCost: number; description: string; parallelGroups: DatabaseOperation[][]; } export interface MethodAnalysis { methodName: string; className?: string; filePath: string; totalPaths: number; paths: ExecutionPath[]; summary: { minCost: number; maxCost: number; avgCost: number; commonPath: ExecutionPath; expectedCosts?: any; }; recommendations: string[]; } export interface FileAnalysis { filePath: string; fileName: string; methods: MethodAnalysis[]; summary: { totalMethods: number; totalPaths: number; costRange: { min: number; max: number; average: number; }; }; } export interface ProjectAnalysis { projectPath: string; files: FileAnalysis[]; summary: { totalFiles: number; totalMethods: number; totalPaths: number; costDistribution: { low: number; medium: number; high: number; }; optimizationOpportunities: OptimizationOpportunity[]; }; generatedAt: string; } export interface OptimizationOpportunity { file: string; method: string; type: 'high_variance' | 'high_cost' | 'parallelization' | 'caching' | 'batching'; description: string; priority: 'low' | 'medium' | 'high'; suggestion?: string; } export interface FrameworkPreset { name: string; description: string; config: Partial<AnalyzerConfig>; } export interface AnalyzerOptions { /** Custom configuration (overrides preset) */ config?: Partial<AnalyzerConfig>; /** Framework preset to use */ preset?: 'nestjs' | 'express' | 'fastify' | 'custom'; /** Output format */ format?: 'text' | 'json' | 'markdown' | 'html'; /** Include optimization suggestions */ includeRecommendations?: boolean; /** Verbose logging */ verbose?: boolean; /** Watch for file changes */ watch?: boolean; } export type ReportFormat = 'text' | 'json' | 'markdown' | 'html'; export type FrameworkType = 'nestjs' | 'express' | 'fastify' | 'custom'; //# sourceMappingURL=types.d.ts.map