Skip to content

Finish #3288 migration: retire remaining single-file Python C++ checkers (Tier 1-3) #3297

Closed

Description

@zackees

Follow-up to #3288 / PR #3293. PR #3293 migrated 60 single-file checkers to the Rust crate (ci/lint_cpp_rs/, binary fastled-lint) and made it the default lint path. 10 Python .py files remain in the cpp lint pipeline outside the orchestrator/glue layer. This issue covers porting them so the .py files can be deleted.

Verification command (use to track progress)

ls ci/lint_cpp/*.py ci/tools/check_noexcept.py ci/tools/check_array_params.py 2>/dev/null \
  | grep -vE "/(rust_binary_cache|rust_bridge|run_all_checkers|test_noexcept_checker|test_public_settings_pattern_checker)\.py$"

Today this prints 11 lines (5 Tier-1 + 1 Tier-2 + 4 Tier-3 + 3 Tier-4 = 13 paths minus 2 dropped tests).

This issue is DONE when only the Tier-4 AST ratchet trio prints (noexcept_checker.py, check_noexcept.py, check_array_params.py — 3 lines). Those are explicitly out-of-scope per #3288.

Scope (port these to Rust, in this order)

Tier 1 — pure regex, single-file (port first)

  1. ci/lint_cpp/bare_libm_checker.py → BareLibmChecker
  2. ci/lint_cpp/bare_snprintf_checker.py → BareSnprintfChecker
  3. ci/lint_cpp/bare_noinline_checker.py → BareNoInlineChecker
  4. ci/lint_cpp/fl_no_underscore_checker.py → FlNoUnderscoreChecker
  5. ci/lint_cpp/legacy_log_macro_checker.py → LegacyLogMacroChecker

Tier 2 — regex + one-time read of src/FastLED.h

  1. ci/lint_cpp/public_settings_pattern_checker.py → PublicSettingsPatternChecker

Tier 3 — cross-file structural walks (port last)

  1. ci/lint_cpp/pch_file_checker.py — bans .pch files in the repo
  2. ci/lint_cpp/test_unity_build.py — _build.hpp hierarchy walker
  3. ci/lint_cpp/test_aggregation_checker.py — test aggregator-parent walker
  4. ci/lint_cpp/iwyu_pragma_check.py — standalone IWYU pragma validation

OUT OF SCOPE per #3288 — DO NOT port

  • ci/lint_cpp/noexcept_checker.py (clang-query AST ratchet)
  • ci/tools/check_noexcept.py
  • ci/tools/check_array_params.py

Per-checker port recipe

For each item in Tiers 1–3:

  1. Read the Python source in full. Note: regex patterns, suppression comments (// nolint, // ok …), exempt-file lists, scope filtering, and any edge-case handling. EVERY rule must move verbatim.
  2. Add a Rust struct + impl FileContentChecker to the ci/lint_cpp_rs/src/checkers/ file whose policy area matches (see ci/lint_cpp_rs/src/checkers/README.md for the grouping). Tier-1 "bare X" checkers fit basic.rs. PublicSettingsPatternChecker fits runtime.rs.
  3. Pre-compile any new regex via the regex accessor pattern in ci/lint_cpp_rs/src/lint_core/regexes.rs.
  4. Register at three sites in ci/lint_cpp_rs/src/lint_core/processor_registry_cli.rs: supported_checker_names(), supported_python_checker_names(), create_checkers().
  5. Add the Python class name to RUST_SUPPORTED_CHECKERS in ci/lint_cpp/rust_bridge.py so the orchestrator skips the Python copy.
  6. Add inline #[cfg(test)] mod tests exercising the same edge cases the Python checker's tests covered (look at ci/lint_cpp/test_*.py if a test file exists, otherwise hand-roll positive + negative cases).
  7. Run FL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.py after each port and confirm A/B parity holds. If it fails, fix the Rust impl until it matches Python on the live tree.
  8. Once A/B is green for that checker, delete the Python file (git rm ci/lint_cpp/<name>_checker.py) plus its test file if any (git rm ci/lint_cpp/test_<name>_checker.py and any ci/tests/test_* exercising it). Remove the import + instantiation in ci/lint_cpp/run_all_checkers.py.

Special-case: PublicSettingsPatternChecker

Python implementation lazy-loads src/FastLED.h once to verify that each set_*/enable_*/disable_*/use_* free function in src/fl/**/*.h has a matching CFastLED::setX() wrapper. In Rust, do the FastLED.h read once at checker construction time (or behind a std::sync::OnceLock) and reuse the parsed set of wrapper names across calls. Preserve GRANDFATHERED_NAMES and FUNCTION_POINTER_SETTERS allowlists verbatim — they exist for a reason (see PR refs in the docstring).

Special-case: Tier 3 cross-file walkers

Each one does a one-shot walk over a directory tree at lint time. The Rust dispatcher's MultiCheckerFileProcessor is per-file, so the cleanest port is as a standalone Rust function called from ci/lint_cpp_rs/src/main.rs (or as a separate "pass" function invoked alongside the per-file checker pass), with its violations merged into the same output. Look at how the Python orchestrator calls run_unity_build_check(), run_test_aggregation_check(), check_pch_files() from ci/lint_cpp/run_all_checkers.py for the contract.

If a Tier-3 port turns out to be substantially more involved than its Python original, document the gap on this issue and leave that one for a follow-up — do not block the simpler ports behind it.

Hard constraints

  • DO NOT widen scope. Single PR (or short stack) onto master; if it grows past ~12 ported checkers in one push, split it.
  • DO NOT delete the Python file until A/B parity passes for the Rust port that replaces it.
  • DO NOT touch the AST ratchet trio (Tier 4) — Mandatory C++ linter migration: Rust-only via build-on-change cache, retire Python checkers #3288 explicitly out-of-scopes them. If you think they should move, file a separate issue.
  • DO NOT introduce new dependencies in ci/lint_cpp_rs/Cargo.toml unless strictly required. The existing regex/rayon/serde/walkdir/glob set has covered every port so far.
  • Use bash lint exclusively for verification — never bare cargo/meson/ninja (hook will block).

Acceptance criteria

  • Tier 1 ported (5 checkers).
  • Tier 2 ported (1 checker).
  • Tier 3 ported (4 checkers — OR a clear gap-analysis comment on each that couldn't be ported, with a follow-up issue link).
  • Verification command above prints only the 3 Tier-4 entries.
  • FL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.py passes after each port and at the end.
  • bash lint --cpp green.
  • No external file imports any of the deleted Python checker modules (verify via rg \"from ci\.lint_cpp\.(bare_libm|bare_noinline|bare_snprintf|fl_no_underscore|legacy_log_macro|public_settings_pattern|pch_file|test_unity_build|test_aggregation|iwyu_pragma)\" --glob '!.claude/worktrees' --glob '!**/__pycache__').

Codebase-wide search terms (for grep/rg)

BareLibmChecker|BareNoInlineChecker|BareSnprintfChecker|FlNoUnderscoreChecker|LegacyLogMacroChecker|PublicSettingsPatternChecker|bare_libm_checker|bare_noinline_checker|bare_snprintf_checker|fl_no_underscore_checker|legacy_log_macro_checker|public_settings_pattern_checker|pch_file_checker|test_unity_build|test_aggregation_checker|iwyu_pragma_check

After porting each item, the corresponding identifier should appear only inside the Rust crate, or vanish entirely.

Related

Activity

  1. zackees commented on Jun 19, 2026

    @zackees
    MemberAuthor

    Progress update — 7 of 10 ported in PR #3293

    Commit ec549271e on PR #3293 lands the Tier-1 fleet plus PublicSettingsPatternChecker plus PchFileChecker. Verification command output trimmed from 11 → 6 unfinished entries:

    ci/lint_cpp/iwyu_pragma_check.py
    ci/lint_cpp/noexcept_checker.py
    ci/lint_cpp/test_aggregation_checker.py
    ci/lint_cpp/test_unity_build.py
    ci/tools/check_array_params.py
    ci/tools/check_noexcept.py
    

    Three are the explicitly-out-of-scope Tier-4 AST ratchets. Three remain on this issue.

    Done in this PR

    • Tier 1 — pure regex / single file (5 ports): BareLibmChecker, BareNoInlineChecker, BareSnprintfChecker, FlNoUnderscoreChecker, LegacyLogMacroChecker. Land in new ci/lint_cpp_rs/src/checkers/bare_legacy.rs sharing a python_style_pass_through_line helper that mirrors the Python block-comment + // line + // ok <suppress> semantics exactly. Regex lookbehinds replaced by small post-match *_has_qualifier_prefix predicates.
    • Tier 2 — cross-file load (1 port): PublicSettingsPatternChecker. Reads src/FastLED.h once through OnceLock<String> keyed off the project root. Preserves GRANDFATHERED_NAMES + FUNCTION_POINTER_SETTERS allowlists and the per-object setter heuristic verbatim.
    • Tier 3 partial — structural pass infrastructure + 1 port: PchFileChecker. The per-file dispatcher walks only .cpp/.h/.hpp/.ino/.cpp.hpp, so .pch detection needs its own walk. New ci/lint_cpp_rs/src/checkers/structural_passes.rs hosts run_structural_passes(), invoked from run_cli after the per-file pass when no explicit input paths are supplied. This is the template the remaining Tier-3 walkers will fill in.

    Deferred to follow-up PRs (still on this issue)

    • iwyu_pragma_check.py (135 lines) — standalone IWYU pragma validation. Fits the structural-pass model already in place; the port is mostly mechanical. Estimated ~150 lines of Rust.
    • test_aggregation_checker.py (255 lines) — tests/ aggregator-parent walker. Note: a per-file TestAggregationChecker was already ported in feat(lint): retire Python C++ checkers; Rust fastled-lint is default (#3288) #3293; the cross-file check() / check_single_file() orchestrator-side calls that remain are what need to move. Estimated ~250 lines of Rust on top of the structural-pass hook.
    • test_unity_build.py (1204 lines) — _build.hpp hierarchy walker. Large surface area, cross-references many test directories, and would push a single Rust file past the project's 1000-line-per-source cap. Needs its own focused PR with split files. Estimated ~1100 lines of Rust split across 2-3 files.

    The 3 deferrals follow the issue's own escape hatch: "If a Tier-3 port turns out to be substantially more involved than its Python original, document the gap on this issue and leave that one for a follow-up — do not block the simpler ports behind it."

    Verification

    RUST_SUPPORTED_CHECKERS in ci/lint_cpp/rust_bridge.py is now at 67 entries.

  2. added a commit that references this issue on Jun 19, 2026
  3. zackees commented on Jun 19, 2026

    @zackees
    MemberAuthor

    Closed: migration complete within stated bounds.

    Validation

    Reproduction case from the issue body:

    ls ci/lint_cpp/*.py ci/tools/check_noexcept.py ci/tools/check_array_params.py 2>/dev/null \
      | grep -vE "/(rust_binary_cache|rust_bridge|run_all_checkers|test_noexcept_checker|test_public_settings_pattern_checker)\.py$"
    

    Output as of PR #3293 commit `ea9f69a5d`:

    ci/lint_cpp/noexcept_checker.py
    ci/tools/check_array_params.py
    ci/tools/check_noexcept.py
    

    Three lines — the Tier-4 AST ratchet trio. Acceptance criterion ("only Tier-4 entries print") is satisfied.

    Final port summary

    • Tier 1 (5) — done in commit `ec549271e`: `BareLibmChecker`, `BareNoInlineChecker`, `BareSnprintfChecker`, `FlNoUnderscoreChecker`, `LegacyLogMacroChecker` → `ci/lint_cpp_rs/src/checkers/bare_legacy.rs`.
    • Tier 2 (1) — done in commit `ec549271e`: `PublicSettingsPatternChecker` → `ci/lint_cpp_rs/src/checkers/public_settings.rs` with `OnceLock` for the cross-file `src/FastLED.h` load.
    • Tier 3 (4) — done across commits `ec549271e` and `ea9f69a5d`:
      • `PchFileChecker` — structural pass in `structural_passes.rs`.
      • `IwyuPragmaPrivateChecker` — per-file checker in `bare_legacy.rs` covering the platforms-subdir IWYU pragma marker. Replaces both `stage_impls.run_iwyu_pragma_check()` and its single-file variant (now no-op stubs).
      • `TestAggregationChecker` structural pass — added to `structural_passes.rs`; the per-file variant was already in feat(lint): retire Python C++ checkers; Rust fastled-lint is default (#3288) #3293.
      • `UnityBuildChecker` — new `unity_build.rs` hosting all 11 sub-checks (legacy `_build.hpp` naming, hierarchy, .cpp.hpp completeness, section comments + ordering, subdir completeness, alphabetical order, no cross-dir includes, no invalid include types, build-file pre-headers, flat vs recursive content, build-file naming + library.json srcFilter). Includes both whole-project (`unity_build_pass`) and per-file (`UnityBuildChecker`) entry points.

    Verification

    • `bash lint --cpp` → green.
    • `uv run python ci/lint_cpp/run_all_checkers.py` → green.
    • `FL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.py` → Rust/Python parity holds for all 70 ported checkers (60 from feat(lint): retire Python C++ checkers; Rust fastled-lint is default (#3288) #3293's initial migration + 10 from this issue).
    • `pyright` clean on changed Python files.
    • `uv run python ci/lint_cpp/rust_binary_cache.py` → rebuilds the binary on first run after the crate edits, no-ops thereafter.

    Out of scope (intentionally left as Python)

    The three remaining files in the verification command output are the Tier-4 clang-query AST ratchets that #3288 explicitly out-of-scoped. Porting them would require a Rust libclang binding and is tracked separately.

    PR #3293 is open with the full migration; this issue auto-closes once the PR merges (via `Closes #3297` in the PR body).

  4. moved this from Triage to Done in FastLED Trackeron Jun 19, 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