linthis 0.22.1

A fast, cross-platform multi-language linter and formatter
Documentation
# Tasks: Ruff Integration for Python Linting & Formatting

## Feature Overview

Replace `flake8` (linter) and `black` (formatter) with `ruff` for Python file processing in linthis, providing 10-100x speed improvements.

## Status: COMPLETED

All tasks have been implemented.

## User Stories

| ID | Priority | Story | Status |
|----|----------|-------|--------|
| US1 | P1 | As a developer, I want Python linting to use ruff instead of flake8 so that lint checks are faster | Done |
| US2 | P1 | As a developer, I want Python formatting to use ruff instead of black so that formatting is faster | Done |
| US3 | P2 | As a developer, I want ruff configuration generated by --init-configs so that I can customize rules | Done |
| US4 | P3 | As a developer, I want to benchmark ruff vs flake8+black so that I can see the speed improvement | Done |

---

## Phase 1: Setup

- [x] T001 Verify ruff is installed and accessible via `ruff --version`
- [x] T002 Review existing Python checker implementation in `src/checkers/python.rs`
- [x] T003 Review existing Python formatter implementation in `src/formatters/python.rs`

---

## Phase 2: Foundational - Data Types for Ruff JSON Parsing

- [x] T004 [P] Add RuffIssue struct for JSON deserialization in `src/checkers/python.rs`
- [x] T005 [P] Add RuffLocation struct for JSON deserialization in `src/checkers/python.rs`
- [x] T006 [P] Add RuffFix and RuffEdit structs for JSON deserialization in `src/checkers/python.rs`

---

## Phase 3: User Story 1 - Python Linting with Ruff

**Goal**: Replace flake8 with ruff check for Python linting

**Test Criteria**: `cargo test` passes, linthis correctly detects Python lint issues using ruff

### Tasks

- [x] T007 [US1] Update `name()` method to return "ruff" in `src/checkers/python.rs`
- [x] T008 [US1] Update `is_available()` to check for ruff binary in `src/checkers/python.rs`
- [x] T009 [US1] Implement `parse_ruff_json_output()` method to parse ruff JSON output in `src/checkers/python.rs`
- [x] T010 [US1] Implement severity mapping from ruff codes (E/F->Error, W/N/B/S/A->Warning, others->Info) in `src/checkers/python.rs`
- [x] T011 [US1] Update `check()` method to run `ruff check --output-format json` in `src/checkers/python.rs`
- [x] T012 [US1] Remove old `parse_flake8_output()` and `parse_flake8_line()` methods in `src/checkers/python.rs`
- [x] T013 [US1] Update module docstring from "pylint/flake8" to "ruff" in `src/checkers/python.rs`
- [x] T014 [US1] Manual test: run `cargo run -- --check-only --lang python` on Python files with issues

---

## Phase 4: User Story 2 - Python Formatting with Ruff

**Goal**: Replace black with ruff format for Python formatting

**Test Criteria**: `cargo test` passes, linthis correctly formats Python files using ruff

### Tasks

- [x] T015 [US2] Update `name()` method to return "ruff" in `src/formatters/python.rs`
- [x] T016 [US2] Update `is_available()` to check for ruff binary in `src/formatters/python.rs`
- [x] T017 [US2] Update `format()` method to run `ruff format` in `src/formatters/python.rs`
- [x] T018 [US2] Update `check()` method to run `ruff format --check` in `src/formatters/python.rs`
- [x] T019 [US2] Remove hard-coded `--line-length 120` argument (use ruff config instead) in `src/formatters/python.rs`
- [x] T020 [US2] Update module docstring from "black" to "ruff" in `src/formatters/python.rs`
- [x] T021 [US2] Manual test: run `cargo run -- --format-only --lang python` on unformatted Python files

---

## Phase 5: User Story 3 - Configuration Updates

**Goal**: Update default config and --init-configs for ruff

**Test Criteria**: `linthis --init-configs` generates valid ruff configuration

### Tasks

- [x] T022 [US3] Add [python] section with ruff settings in `defaults/config.toml`
- [x] T023 [US3] Update `generate_tool_configs()` to create ruff.toml instead of .flake8 in `src/main.rs`
- [x] T024 [US3] Update `generate_tool_configs()` to update pyproject.toml [tool.ruff] section in `src/main.rs`
- [x] T025 [US3] Remove .flake8 generation from `generate_tool_configs()` in `src/main.rs`
- [x] T026 [US3] Manual test: run `cargo run -- --init-configs` and verify ruff.toml is created

---

## Phase 6: User Story 4 - Benchmark Mode

**Goal**: Add --benchmark flag to compare ruff vs flake8+black performance

**Test Criteria**: `linthis --benchmark --lang python` outputs comparison table

### Tasks

- [x] T027 [US4] Add `--benchmark` CLI flag in `src/main.rs`
- [x] T028 [US4] Create `src/benchmark.rs` module for benchmark logic
- [x] T029 [US4] Implement `run_flake8_benchmark()` to time flake8 execution in `src/benchmark.rs`
- [x] T030 [US4] Implement `run_black_benchmark()` to time black execution in `src/benchmark.rs`
- [x] T031 [US4] Implement `run_ruff_check_benchmark()` to time ruff check execution in `src/benchmark.rs`
- [x] T032 [US4] Implement `run_ruff_format_benchmark()` to time ruff format execution in `src/benchmark.rs`
- [x] T033 [US4] Implement `format_benchmark_table()` to output ASCII table comparison in `src/benchmark.rs`
- [x] T034 [US4] Add benchmark module to `src/lib.rs`
- [x] T035 [US4] Wire --benchmark flag to benchmark execution in `src/main.rs`
- [x] T036 [US4] Manual test: run `cargo run -- --benchmark --lang python` on a Python project

---

## Phase 7: Polish & Documentation

- [x] T037 Update README.md to document ruff as the Python linter/formatter
- [x] T038 Add migration notes for users switching from flake8+black to ruff in README.md
- [x] T039 Run `cargo clippy` and fix any warnings
- [x] T040 Run `cargo test` to verify all tests pass
- [x] T041 Final manual test: run full linthis workflow on a Python project

---

## Summary

| Metric | Count | Status |
|--------|-------|--------|
| Total Tasks | 41 | Completed |
| Phase 1 (Setup) | 3 | Completed |
| Phase 2 (Foundational) | 3 | Completed |
| Phase 3 (US1 - Linting) | 8 | Completed |
| Phase 4 (US2 - Formatting) | 7 | Completed |
| Phase 5 (US3 - Config) | 5 | Completed |
| Phase 6 (US4 - Benchmark) | 10 | Completed |
| Phase 7 (Polish) | 5 | Completed |

## Files Modified

1. `src/checkers/python.rs` - Replaced flake8 with ruff check
2. `src/formatters/python.rs` - Replaced black with ruff format
3. `src/benchmark.rs` - New module for benchmark comparison
4. `src/lib.rs` - Added benchmark module
5. `src/main.rs` - Added --benchmark flag and ruff config generation
6. `defaults/config.toml` - Added Python/ruff configuration
7. `README.md` - Updated documentation
8. `src/utils/walker.rs` - Fixed clippy warning