Skip to content

refactor(lint): split Rust C++ linters into sub-1k LOC modules #3119

Closed

Description

@zackees

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::read reads each file into text and lines once.
  • MultiCheckerFileProcessor caches loaded files and uses rayon over file loading and file processing.
  • run_cli creates 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:

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.rs or targeted helper modules: shared regex caches/helpers.
  • checkers/: one module per checker or tightly-related checker family, using names that line up with ci/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 FileContent to 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/**/*.rs module exceeds 1,000 LOC?

Related issues

Activity

  1. added a commit that references this issue on Jun 16, 2026
    ebfda30
  2. moved this from Triage to Done in FastLED Trackeron Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions