Repository navigation
Description
Context
ci/lint_cpp_rs/src/lib.rs has grown into a Rust linter monolith: it is currently about 6,924 nonblank lines and contains shared types, CLI parsing, file collection, regex helpers, checker registration, every checker implementation, and tests in one file.
The Python C++ linter already has the maintainable shape we want to mirror: ci/lint_cpp/run_all_checkers.py is the central dispatcher, and individual checkers live in separate ci/lint_cpp/*_checker.py modules. Its dispatcher explicitly documents the important performance property: load each file once, then run all applicable checkers against that cached content.
The Rust linter already has the right high-level fast path:
FileContent::readreads each file into text and lines once.MultiCheckerFileProcessorcaches loaded files and usesrayonover file loading and file processing.run_clicreates all checkers once and passes them into the processor.
The problem is code organization and migration maintainability, not a request to go back to per-checker file reads.
Related history:
- Port C++ linter framework from Python to Rust, launched via 'soldr cargo run' #2488 tracked the original Python-to-Rust C++ linter framework migration.
703d5aa370added the initial Rust-backed C++ linter subset.c84a0f9cbdported the remaining C++ lint checkers to Rust.
Proposal
Split ci/lint_cpp_rs/src/lib.rs into Rust modules that mirror the Python linter structure while preserving the current one-pass file dispatcher.
Suggested module shape:
lib.rs: public crate surface only.cli.rs: argument parsing, output formatting,run_cli.files.rs: file discovery, path normalization, exclusion helpers.processor.rs:FileContent,LintViolation,FileContentChecker,MultiCheckerFileProcessor.registry.rs: supported checker names and checker construction.regexes.rsor targeted helper modules: shared regex caches/helpers.checkers/: one module per checker or tightly-related checker family, using names that line up withci/lint_cpp/*.py.tests/or module-local tests: parity/regression tests kept close enough to remain understandable.
The dispatcher should remain the grand dispatch point: collect files once, determine applicable checkers, read file text at most once per path, then pass the shared FileContent to every checker that needs text.
Acceptance criteria
- No Rust source module under
ci/lint_cpp_rs/src/exceeds 1,000 LOC. - The Rust linter still reads each linted file at most once per run and passes shared
FileContentto all applicable Rust C++ checkers. - Checker registration remains centralized enough that
--list-checkers,--checker, and Python bridge support stay easy to audit. - The split checker modules map clearly back to the existing Python checker files in
ci/lint_cpp/. - Full Rust/Python parity coverage remains intact for migrated checkers.
- Existing invocations continue to work:
soldr cargo run --release --bin fastled-lint --manifest-path ci/lint_cpp_rs/Cargo.toml -- --format json --project-root <repo>uv run python ci/lint_cpp/run_all_checkers.py --rust
- Add or update tests so the module split cannot accidentally regress checker selection, selected-checker filtering, or output shape.
Open questions
- Should related tiny checkers be grouped into family modules, or should the split be strictly one checker per Rust module?
- Should test code count toward the 1,000 LOC limit, or should large test fixtures move under a separate
tests/tree? - Do we want a follow-up lint guard that fails CI when any
ci/lint_cpp_rs/src/**/*.rsmodule exceeds 1,000 LOC?
Related issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
refactor(lint): split Rust C++ linter sources (#3121)