/** * Auto-Fix Capabilities for Common Patterns * * Provides automatic fix suggestions and applications for common * code quality issues detected during certification. * * @module certification/autofix */ import { Finding } from "./types.js"; /** * A fix pattern that can be automatically applied */ export interface FixPattern { /** Pattern ID matching finding category or ID pattern */ patternId: string; /** Human-readable name */ name: string; /** Description of what the fix does */ description: string; /** Regex pattern to match in code */ matchPattern: RegExp; /** Replacement string or function */ replacement: string | ((match: string, ...groups: string[]) => string); /** Whether this fix can be safely auto-applied */ safeToAutoApply: boolean; /** Risk level of the fix */ risk: "low" | "medium" | "high"; } /** * Result of attempting to apply a fix */ export interface FixResult { findingId: string; file: string; applied: boolean; error?: string; diff?: { before: string; after: string; lineNumber?: number; }; } /** * Fix preview without applying */ export interface FixPreview { findingId: string; canAutoFix: boolean; pattern?: string; fixDescription?: string; preview?: { before: string; after: string; file: string; lineStart: number; lineEnd: number; }; risk: "low" | "medium" | "high"; requiresReview: boolean; } /** * Built-in fix patterns for common issues */ export declare const FIX_PATTERNS: FixPattern[]; /** * Find the fix pattern for a given finding */ export declare function findFixPattern(finding: Finding): FixPattern | undefined; /** * Generate a preview of the fix without applying it */ export declare function previewFix(projectPath: string, finding: Finding): Promise; /** * Apply a fix to a file */ export declare function applyFix(projectPath: string, finding: Finding, dryRun?: boolean): Promise; /** * Get all available fix patterns with their metadata */ export declare function listFixPatterns(): Array<{ id: string; name: string; description: string; risk: string; safeToAutoApply: boolean; }>; /** * Add a custom fix pattern at runtime */ export declare function registerFixPattern(pattern: FixPattern): void; /** * Result of batch applying fixes */ export interface BatchFixResult { totalFindings: number; safeFixesAvailable: number; applied: number; skipped: number; failed: number; results: FixResult[]; summary: { byPattern: Record; byFile: Record; }; } /** * Apply all safe fixes to a list of findings * Only applies fixes marked as safeToAutoApply: true */ export declare function batchApplySafeFixes(projectPath: string, findings: Finding[], options?: { dryRun?: boolean; includeUnsafe?: boolean; }): Promise; /** * Get safe fix patterns only */ export declare function getSafeFixPatterns(): Array<{ id: string; name: string; description: string; }>; //# sourceMappingURL=autofix.d.ts.map