/** * Ruff lens for Python linting * * Ruff is an extremely fast Python linter written in Rust. * Output format: JSON array of diagnostic messages * * @see https://docs.astral.sh/ruff/ */ import { BaseLens } from '../base/BaseLens.js'; import { LensResult, ExecuteResult } from '../../types/index.js'; /** * Ruff location format (1-indexed) */ interface RuffLocation { row: number; column: number; } /** * Ruff edit for auto-fix */ interface RuffEdit { content: string; location: RuffLocation; end_location: RuffLocation; } /** * Ruff fix information */ interface RuffFix { /** Fix reliability: "safe", "unsafe", or "display_only" */ applicability: 'safe' | 'unsafe' | 'display_only'; /** Description of the fix */ message: string; /** Code edits to apply */ edits: RuffEdit[]; } /** * Ruff diagnostic message format */ interface RuffMessage { /** Rule code (e.g., "F401", "E501") */ code: string | null; /** Documentation URL for the rule */ url: string | null; /** Human-readable error description */ message: string; /** Optional fix information */ fix: RuffFix | null; /** Notebook cell index (1-based, for Jupyter) */ cell: number | null; /** Start position */ location: RuffLocation; /** End position */ end_location: RuffLocation; /** Source file path */ filename: string; /** Line for noqa comment placement */ noqa_row: number | null; } /** * Ruff JSON output is an array of messages */ type RuffOutput = RuffMessage[]; /** * Lens for Ruff Python linter */ export declare class RuffLens extends BaseLens { readonly name = "ruff"; readonly description = "Fast Python linter (Rust-based)"; readonly languages: string[]; readonly supportedTools: string[]; readonly requirements: import("../..").LensRequirements; private pathMapper?; /** * Calculate quality score (0-100) from Ruff results * * Scoring algorithm: * - Start at 100 * - Subtract penalty based on issues per file analyzed * - Errors (E prefix): 10 points per error per file * - Warnings (W prefix): 3 points per warning per file * - Other (F, I, etc.): 5 points per issue per file * - Floor at 0 */ static calculateQualityScore(result: LensResult): number; /** * Parse Ruff JSON output */ parse(output: ExecuteResult): RuffOutput; /** * Format Ruff results to standard format */ format(parsed: RuffOutput): LensResult; /** * Map Ruff rule code to severity * * Ruff uses prefixes from various tools: * - E: pycodestyle errors * - W: pycodestyle warnings * - F: Pyflakes * - I: isort * - N: pep8-naming * - D: pydocstyle * - UP: pyupgrade * - B: flake8-bugbear * - A: flake8-builtins * - C4: flake8-comprehensions * - S: flake8-bandit (security) * - etc. */ private mapRuffSeverity; /** * Categorize Ruff rules */ private categorizeRule; /** * Get or create path mapper */ private getPathMapper; /** * Override execute to ensure JSON format */ execute(): Promise; } export {}; //# sourceMappingURL=RuffLens.d.ts.map