Repository navigation
feat(lint): retire Python C++ checkers; Rust fastled-lint is default (#3288) - #3293
Conversation
…loses #3288) Migrates the C++ lint pipeline to the Rust `fastled-lint` binary as the mandatory default everywhere - `bash lint --cpp`, hooks, and CI. Retires the 60 Python checkers that have parity-verified Rust ports. Key changes: - New ci/lint_cpp/rust_binary_cache.py: native-Python file-mtime fingerprint over Rust sources. Rebuilds the binary only when missing or sources change; otherwise returns the cached path with sub-ms overhead. Removes the per-invocation soldr fingerprint-scan tax (~300-800ms on Windows). Handles both target/release/ and target/<triple>/release/ layouts. - ci/lint_cpp/rust_bridge.py: invokes the cached binary directly instead of rebuilding on every lint call. - pyproject.toml: pins soldr>=0.7.55 for the rare rebuild path. - ci/lint/args_parser.py + ci/lint_cpp/run_all_checkers.py: --rust now defaults to True via BooleanOptionalAction; --no-rust is the escape hatch. - .github/workflows/template_unit_test.yml: adds a bash lint --cpp step exercising the Rust path on every PR. - Deletes 58 Rust-ported Python checker files plus 12 in-package and external test files. Surgically edits banned_headers_checker.py (keeps the BANNED_HEADERS_* data tables) and test_aggregation_checker.py (keeps the cross-file structural pass). - run_all_checkers.py now instantiates only the 6 Python-only checkers without Rust ports plus the cross-file structural checks and AST ratchets (noexcept, decayed array params). Grand-dispatch preservation verified: the Rust MultiCheckerFileProcessor uses a per-path HashMap cache, reads files in parallel via rayon, then iterates files running every interested checker - the read-once + N-checkers contract is preserved (and parallelized) from the Python implementation. A/B parity verified: FL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.py passes against all 60 RUST_SUPPORTED_CHECKERS. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR migrates C++ linting to a Rust-backed binary as the mandatory default. A new ChangesRust C++ Linter as Mandatory Default with Build-on-Change Cache
Sequence Diagram(s)sequenceDiagram
participant CLI as bash lint --cpp
participant ArgParser as args_parser.py
participant RunAll as run_all_checkers.py
participant Bridge as rust_bridge.py
participant Cache as rust_binary_cache
participant Binary as fastled-lint binary
participant Rust as Rust checkers
participant Python as Python checkers
CLI->>ArgParser: parse args (use_rust_cpp_lint=True default)
ArgParser-->>RunAll: LintArgs(use_rust_cpp_lint=True)
RunAll->>Bridge: run_rust_linter(project_root, ...)
Bridge->>Cache: ensure_rust_lint_binary()
Cache->>Cache: enumerate inputs, compute fingerprint
alt binary exists AND fingerprint matches
Cache-->>Bridge: return cached binary path (zero overhead)
else binary missing OR fingerprint mismatch
Cache->>Cache: invoke soldr cargo build --release
Cache->>Cache: persist new fingerprint
Cache-->>Bridge: return rebuilt binary path
end
Bridge->>Binary: subprocess [binary_path, --json, --project-root, ...]
Binary->>Rust: dispatch to per-file checkers
Rust-->>Binary: per-file violations
Binary->>Binary: run structural passes (once per lint)
Binary-->>Bridge: JSON violations output
Bridge-->>RunAll: convert to CheckerResults
RunAll->>Python: run surviving Python checkers
Python-->>RunAll: Python violations
RunAll-->>CLI: merge + exit with lint report
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
ci/lint_cpp/run_all_checkers.py (1)
745-750: ⚡ Quick winDrop the now-unused all-header collection from
main().
create_checkers()explicitly no longer consumesall_headers, butmain()still computes it in both execution paths, adding unnecessary repo-wide traversal cost.Suggested cleanup
- files_by_dir = collect_all_files_by_directory() - all_headers = _collect_all_headers(files_by_dir) - - # Create all checker instances - checkers_by_scope = create_checkers(all_headers=all_headers) + files_by_dir = collect_all_files_by_directory() + checkers_by_scope = create_checkers() @@ - # Extract all headers for cross-file validation - all_headers = _collect_all_headers(files_by_dir) - - # Create all checker instances - checkers_by_scope = create_checkers(all_headers=all_headers) + # Create all checker instances + checkers_by_scope = create_checkers()Also applies to: 804-809
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ci/lint_cpp/run_all_checkers.py` around lines 745 - 750, The `all_headers` variable is being collected via `_collect_all_headers(files_by_dir)` but is no longer used by the `create_checkers()` function. Remove the line that assigns `all_headers = _collect_all_headers(files_by_dir)` and remove the `all_headers=all_headers` parameter from the `create_checkers()` call in the main function. Apply this cleanup to both execution paths in main() where this pattern occurs (around lines 745-750 and 804-809).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ci/lint_cpp/rust_binary_cache.py`:
- Around line 56-62: The binary selection in the target_root iteration is
non-deterministic and doesn't account for host-target compatibility. To fix
this, sort the triple directories from target_root.iterdir() to ensure
deterministic ordering, then identify and prioritize the triple that matches the
current host architecture (using platform information like system and machine)
before iterating through candidates. Apply the same logic to any similar code in
the 65-71 range that also selects binaries based on target triples.
---
Nitpick comments:
In `@ci/lint_cpp/run_all_checkers.py`:
- Around line 745-750: The `all_headers` variable is being collected via
`_collect_all_headers(files_by_dir)` but is no longer used by the
`create_checkers()` function. Remove the line that assigns `all_headers =
_collect_all_headers(files_by_dir)` and remove the `all_headers=all_headers`
parameter from the `create_checkers()` call in the main function. Apply this
cleanup to both execution paths in main() where this pattern occurs (around
lines 745-750 and 804-809).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 64a5d08a-869f-48de-9a3a-a8eb13cbb8a1
📒 Files selected for processing (80)
.github/workflows/template_unit_test.ymlci/lint.pyci/lint/args_parser.pyci/lint_cpp/arduino_macro_usage_checker.pyci/lint_cpp/asm_js_location_checker.pyci/lint_cpp/attribute_checker.pyci/lint_cpp/banned_define_checker.pyci/lint_cpp/banned_headers_checker.pyci/lint_cpp/banned_macros_checker.pyci/lint_cpp/banned_namespace_checker.pyci/lint_cpp/bare_allocation_checker.pyci/lint_cpp/bare_using_checker.pyci/lint_cpp/builtin_memcpy_checker.pyci/lint_cpp/check_namespace_includes.pyci/lint_cpp/check_platform_includes.pyci/lint_cpp/check_platforms_fl_namespace.pyci/lint_cpp/check_using_namespace.pyci/lint_cpp/cpp_hpp_header_pair_checker.pyci/lint_cpp/cpp_hpp_includes_checker.pyci/lint_cpp/cpp_include_checker.pyci/lint_cpp/ctype_global_checker.pyci/lint_cpp/enum_class_checker.pyci/lint_cpp/esp_rom_printf_checker.pyci/lint_cpp/example_serial_checker.pyci/lint_cpp/fastled_header_usage_checker.pyci/lint_cpp/fl_is_defined_checker.pyci/lint_cpp/headers_exist_checker.pyci/lint_cpp/impl_hpp_includes_checker.pyci/lint_cpp/include_after_namespace_checker.pyci/lint_cpp/include_paths_checker.pyci/lint_cpp/is_header_include_checker.pyci/lint_cpp/iwyu_pragma_block_checker.pyci/lint_cpp/logging_in_iram_checker.pyci/lint_cpp/member_style_checker.pyci/lint_cpp/namespace_platforms_checker.pyci/lint_cpp/native_platform_defines_checker.pyci/lint_cpp/net_namespace_checker.pyci/lint_cpp/no_namespace_fl_declaration.pyci/lint_cpp/no_using_namespace_fl_in_headers.pyci/lint_cpp/noexcept_special_members_checker.pyci/lint_cpp/numeric_limit_macros_checker.pyci/lint_cpp/platform_includes_checker.pyci/lint_cpp/platform_pragma_checker.pyci/lint_cpp/pragma_once_checker.pyci/lint_cpp/raw_noexcept_checker.pyci/lint_cpp/raw_pragma_checker.pyci/lint_cpp/reinterpret_cast_checker.pyci/lint_cpp/relative_include_checker.pyci/lint_cpp/run_all_checkers.pyci/lint_cpp/rust_binary_cache.pyci/lint_cpp/rust_bridge.pyci/lint_cpp/serial_printf_checker.pyci/lint_cpp/simd_intrinsics_checker.pyci/lint_cpp/singleton_in_headers_checker.pyci/lint_cpp/sleep_for_checker.pyci/lint_cpp/span_from_pointer_checker.pyci/lint_cpp/static_in_headers_checker.pyci/lint_cpp/std_namespace_checker.pyci/lint_cpp/stdint_type_checker.pyci/lint_cpp/subdir_namespace_checker.pyci/lint_cpp/test_aggregation_checker.pyci/lint_cpp/test_asm_js_location_checker.pyci/lint_cpp/test_banned_macros_checker.pyci/lint_cpp/test_include_paths_checker.pyci/lint_cpp/test_is_header_include_checker.pyci/lint_cpp/test_native_platform_defines_checker.pyci/lint_cpp/test_noexcept_special_members_checker.pyci/lint_cpp/test_optimized_checkers.pyci/lint_cpp/test_path_structure_checker.pyci/lint_cpp/test_raw_noexcept_checker.pyci/lint_cpp/test_rust_parity.pyci/lint_cpp/test_singleton_in_headers_checker.pyci/lint_cpp/thread_local_keyword_checker.pyci/lint_cpp/unit_test_checker.pyci/lint_cpp/using_namespace_fl_in_examples_checker.pyci/lint_cpp/weak_attribute_checker.pyci/tests/test_bare_using_in_headers.pyci/tests/test_example_serial_checker.pyci/tests/test_platform_includes_checker.pypyproject.toml
💤 Files with no reviewable changes (71)
- ci/lint_cpp/test_path_structure_checker.py
- ci/lint_cpp/cpp_hpp_header_pair_checker.py
- ci/lint_cpp/example_serial_checker.py
- ci/lint_cpp/builtin_memcpy_checker.py
- ci/lint_cpp/std_namespace_checker.py
- ci/lint_cpp/banned_namespace_checker.py
- ci/lint_cpp/static_in_headers_checker.py
- ci/lint_cpp/net_namespace_checker.py
- ci/lint_cpp/headers_exist_checker.py
- ci/lint_cpp/relative_include_checker.py
- ci/lint_cpp/thread_local_keyword_checker.py
- ci/lint_cpp/test_include_paths_checker.py
- ci/lint_cpp/pragma_once_checker.py
- ci/lint_cpp/weak_attribute_checker.py
- ci/lint_cpp/check_namespace_includes.py
- ci/lint_cpp/esp_rom_printf_checker.py
- ci/lint_cpp/subdir_namespace_checker.py
- ci/lint_cpp/check_platforms_fl_namespace.py
- ci/tests/test_example_serial_checker.py
- ci/lint_cpp/reinterpret_cast_checker.py
- ci/lint_cpp/no_namespace_fl_declaration.py
- ci/lint_cpp/span_from_pointer_checker.py
- ci/lint_cpp/sleep_for_checker.py
- ci/tests/test_bare_using_in_headers.py
- ci/lint_cpp/include_after_namespace_checker.py
- ci/lint_cpp/banned_define_checker.py
- ci/lint_cpp/banned_macros_checker.py
- ci/lint_cpp/simd_intrinsics_checker.py
- ci/lint_cpp/fl_is_defined_checker.py
- ci/lint_cpp/logging_in_iram_checker.py
- ci/lint_cpp/test_is_header_include_checker.py
- ci/lint_cpp/fastled_header_usage_checker.py
- ci/lint_cpp/test_banned_macros_checker.py
- ci/lint_cpp/namespace_platforms_checker.py
- ci/lint_cpp/raw_pragma_checker.py
- ci/lint_cpp/check_using_namespace.py
- ci/lint_cpp/test_rust_parity.py
- ci/lint_cpp/member_style_checker.py
- ci/lint_cpp/stdint_type_checker.py
- ci/lint_cpp/include_paths_checker.py
- ci/lint_cpp/impl_hpp_includes_checker.py
- ci/lint_cpp/singleton_in_headers_checker.py
- ci/lint_cpp/serial_printf_checker.py
- ci/lint_cpp/test_raw_noexcept_checker.py
- ci/lint_cpp/asm_js_location_checker.py
- ci/lint_cpp/attribute_checker.py
- ci/tests/test_platform_includes_checker.py
- ci/lint_cpp/enum_class_checker.py
- ci/lint_cpp/bare_using_checker.py
- ci/lint_cpp/cpp_include_checker.py
- ci/lint_cpp/platform_pragma_checker.py
- ci/lint_cpp/bare_allocation_checker.py
- ci/lint_cpp/unit_test_checker.py
- ci/lint_cpp/no_using_namespace_fl_in_headers.py
- ci/lint_cpp/check_platform_includes.py
- ci/lint_cpp/raw_noexcept_checker.py
- ci/lint_cpp/platform_includes_checker.py
- ci/lint_cpp/using_namespace_fl_in_examples_checker.py
- ci/lint_cpp/noexcept_special_members_checker.py
- ci/lint_cpp/iwyu_pragma_block_checker.py
- ci/lint_cpp/test_noexcept_special_members_checker.py
- ci/lint_cpp/test_asm_js_location_checker.py
- ci/lint_cpp/test_optimized_checkers.py
- ci/lint_cpp/native_platform_defines_checker.py
- ci/lint_cpp/ctype_global_checker.py
- ci/lint_cpp/test_singleton_in_headers_checker.py
- ci/lint_cpp/arduino_macro_usage_checker.py
- ci/lint_cpp/cpp_hpp_includes_checker.py
- ci/lint_cpp/test_native_platform_defines_checker.py
- ci/lint_cpp/numeric_limit_macros_checker.py
- ci/lint_cpp/is_header_include_checker.py
…3293 Follow-up to the Rust C++ linter migration. Addresses both CodeRabbit findings on PR #3293 and finishes the Python-stub retirement that was deferred for safety in the previous pass. CodeRabbit fixes: - rust_binary_cache._binary_candidate_paths: ordering is now deterministic and host-aware. Prefer CARGO_BUILD_TARGET, then the guessed host triple, then plain target/release/, then any remaining triple dir sorted by name. Dedupes via a seen-set so the host triple is never visited twice. Closes the "wrong-arch binary silently selected on multi-triple checkout" hazard CodeRabbit flagged. - run_all_checkers.main: dropped the all_headers collection in both the single-file and full-tree branches plus the orphan _collect_all_headers helper. create_checkers() stopped consuming that frozenset when the legacy IwyuPragmaBlockChecker (the sole consumer) was retired to Rust. Dead Python stubs deleted: - banned_headers_checker.py: kept as a data-only shell in the previous pass, but its BANNED_HEADERS_* / HeaderException / EXCEPTION_RULES tables have zero remaining Python importers. The Rust crate has its own complete copy in ci/lint_cpp_rs/src/lint_core/banned_header_data.rs. - has_include_checker.py: orphan file with no callers anywhere in the tree. - test_file_wrapper_checker.py: orphan FL_TEST_FILE wrapper checker with no callers (the live FL_TEST_FILE enforcement runs through test_unity_build / test_aggregation paths). Verification: - bash lint --cpp -> all phases green - uv run python ci/lint_cpp/run_all_checkers.py -> pass - FL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.py -> Rust/Python parity holds - rust_binary_cache.py prints the host triple binary path first Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Follow-up to the 5-agent audit pass. Three classes of fix:
1. rust_binary_cache.py:
- Atomic fingerprint write via tmp + os.replace. Closes the Windows
torn-read window where a concurrent Stop hook + manual bash lint
could read a half-written fingerprint and trigger a redundant
rebuild.
- Dropped phantom rust-toolchain.toml from _FINGERPRINT_INPUTS — the
file does not exist in the crate. The docstring previously claimed
it was a tracked input; now matches reality.
2. .github/workflows/template_unit_test.yml:
- Added actions/cache@v4 for ci/lint_cpp_rs/target/ + the binary
fingerprint, keyed on Cargo.lock + every src/**/*.rs + Cargo.toml.
Skips the soldr cargo build (~60-180s) on every CI run when the
crate sources haven't changed. With restore-keys fallback the
partial cache also seeds future builds.
- timeout-minutes: 30 on the unit-test job. Previously inherited
the GitHub default of 360, so a wedged soldr daemon could burn a
runner-hour silently.
3. ci/lint_cpp_rs/src/checkers/platform_trampoline.rs:
- Clarified the IwyuPragmaBlockChecker should_process_file comment.
The audit flagged a scope mismatch vs the Python checker's class
declaration, but that read was misleading — Python's
should_process_file was permissive while the dispatch layer
(checkers_by_scope[\"fl\"] / [\"platforms\"]) pruned files
outside fl/ + platforms/ before they ever reached the checker.
Effective Python scope matches the existing Rust scope; A/B
parity still passes. Comment now documents the dispatch-layer
pruning so future readers don't repeat the audit mistake.
Verification:
- bash lint --cpp -> pass
- uv run python ci/lint_cpp/run_all_checkers.py -> pass
- FL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.py -> Rust/
Python parity holds
- pyright clean
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Cleans up the long tail flagged by the audit on PR #3293. Three buckets: 1. Doc rewrites (the architecture references future contributors hit first): - agents/docs/linter-architecture.md: rewritten end-to-end to describe the two-tier (Rust default + small Python holdover) architecture, the four-step Rust workflow for adding a checker, and the "when to still use Python" cases (AST ratchets + cross-file structural passes + the 6 remaining single-file Python checkers). - .claude/agents/cpp-linter-builder-agent.md: replaced the Python FileContentChecker template with a Rust struct + impl, the unittest template with an inline #[cfg(test)] mod tests, and the registration table with the 3-site Rust + 1-site rust_bridge edit. - .claude/skills/new-cpp-lint/SKILL.md: retargeted phases so the scaffolded artifacts land under ci/lint_cpp_rs/src/checkers/. 2. Dead references in code/config/docs: - ci/debug_attached.py: replaced direct ci/lint_cpp/run_all_checkers.py invocation with `ci/lint.py --cpp` so the Rust path is used and future default flips are picked up automatically. Dropped the follow-on standalone `cpp_lint.py src/` step — RelativeIncludeChecker and FastLEDHeaderUsageChecker ship in the Rust crate now. - cpp_lint.py: deleted. Was the orphan root-level relative-includes + FastLED.h tool with zero callers after debug_attached.py stopped invoking it. - ci/dependencies.json: pruned the dead checker catalog (15 deleted .py filenames) and replaced with the current Rust + Python-only fleet. - ci/fix_has_include_README.md: dropped the section about the deleted ci/lint_cpp/has_include_checker.py CI linter; rewrote "Future Improvements" to point at adding a Rust checker; retargeted "Related Files" + "See Also" at live Rust paths. - ci/lint_cpp_rs/src/checkers/README.md: updated the lead-in to note Python checker retirement and that new checkers go in the Rust crate. - src/fl/stl/compiler_control.h: FL_ALLOW_PLATFORM_PRAGMA escape- hatch comment now names the Rust PlatformPragmaChecker (in ci/lint_cpp_rs/src/checkers/style.rs). - agents/docs/cpp-standards.md: static-in-header rule now cites the Rust StaticInHeaderChecker (ci/lint_cpp_rs/src/checkers/style.rs) instead of the deleted Python test file. 3. 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 - pyright clean on changed Python files - ci/dependencies.json parses as valid JSON - Final grep sweep finds no remaining references to any of the 58 deleted Python checker files anywhere in the tree. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
agents/docs/linter-architecture.md (1)
1-12: 💤 Low valueClarity: Document where the Python orchestrator entry point is now located.
Lines 1–12 mention
bash lint --cppcalls the orchestrator and that "the Python orchestrator is still the entrypoint," but the specific invocation path (uv run python -m ci.lint_cpp.run_all_checkers) is only mentioned on line 16. Consider moving or emphasizing this in the introduction so readers understand the entry point immediately.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@agents/docs/linter-architecture.md` around lines 1 - 12, The introduction section (lines 1-12) states that the Python orchestrator is the entrypoint for `bash lint --cpp` but does not show the actual invocation command. Add or move the specific Python invocation path (the `uv run python -m ci.lint_cpp.run_all_checkers` command) into the introductory Two-Tier Architecture section, ideally near the statement about the Python orchestrator being the entrypoint, so readers immediately understand the concrete entry point without having to read further into the document.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@agents/docs/linter-architecture.md`:
- Around line 40-75: The documentation file linter-architecture.md should be
updated to clarify that helper functions like FileContent, ends_with_any,
is_under_dir, normalize_path, split_line_comment, and strip_string_literals are
private functions accessible only because lib.rs uses include!() to inline all
source files into a single compilation unit. Add an explanation stating that new
checker implementations must be added within the same monolithic crate structure
by creating files in the checkers/ directory and registering them in lib.rs,
rather than attempting to import these helpers from external modules. This
clarification should be added near the example implementation to prevent
misunderstandings about how checkers access internal helper functions.
---
Nitpick comments:
In `@agents/docs/linter-architecture.md`:
- Around line 1-12: The introduction section (lines 1-12) states that the Python
orchestrator is the entrypoint for `bash lint --cpp` but does not show the
actual invocation command. Add or move the specific Python invocation path (the
`uv run python -m ci.lint_cpp.run_all_checkers` command) into the introductory
Two-Tier Architecture section, ideally near the statement about the Python
orchestrator being the entrypoint, so readers immediately understand the
concrete entry point without having to read further into the document.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fbba150b-717e-46a5-b61a-f7ac8b4ba98b
📒 Files selected for processing (10)
.claude/agents/cpp-linter-builder-agent.md.claude/skills/new-cpp-lint/SKILL.mdagents/docs/cpp-standards.mdagents/docs/linter-architecture.mdci/debug_attached.pyci/dependencies.jsonci/fix_has_include_README.mdci/lint_cpp_rs/src/checkers/README.mdcpp_lint.pysrc/fl/stl/compiler_control.h
💤 Files with no reviewable changes (1)
- cpp_lint.py
✅ Files skipped from review due to trivial changes (5)
- src/fl/stl/compiler_control.h
- ci/lint_cpp_rs/src/checkers/README.md
- agents/docs/cpp-standards.md
- .claude/agents/cpp-linter-builder-agent.md
- ci/fix_has_include_README.md
Follow-up to #3288 / PR #3293. Drops 7 Python `.py` files from the cpp lint pipeline by porting their checkers to the Rust `fastled-lint` binary. The build-on-change cache and A/B parity guard from the parent PR carry the verification. Tier 1 — pure-regex single-file ports (5): - BareLibmChecker (was ci/lint_cpp/bare_libm_checker.py) - BareNoInlineChecker (was ci/lint_cpp/bare_noinline_checker.py) - BareSnprintfChecker (was ci/lint_cpp/bare_snprintf_checker.py) - FlNoUnderscoreChecker (was ci/lint_cpp/fl_no_underscore_checker.py) - LegacyLogMacroChecker (was ci/lint_cpp/legacy_log_macro_checker.py) All five land in new ci/lint_cpp_rs/src/checkers/bare_legacy.rs sharing a `python_style_pass_through_line` helper that matches the Python block-comment + `//` line + `// ok <suppress>` semantics exactly. Regex patterns preserve the Python lookbehinds via a small post-match `*_has_qualifier_prefix` predicate (Rust regex crate has no lookbehind). Tier 2 — cross-file load (1): - PublicSettingsPatternChecker (was ci/lint_cpp/public_settings_pattern_checker.py). Lands in ci/lint_cpp_rs/src/checkers/public_settings.rs. Reads `src/FastLED.h` once through a static `OnceLock<String>` keyed off the project root, then reuses the cached content for every header scanned in src/fl/. Preserves the GRANDFATHERED_NAMES + FUNCTION_POINTER_SETTERS allowlists, the per-object setter heuristic (first-param-is-non-const- ptr/ref-to-user-defined-type), and the suggestion message verbatim. Tier 3 — structural pass (1): - PchFileChecker (was ci/lint_cpp/pch_file_checker.py). The per-file dispatcher walks only .cpp/.h/.hpp/.ino/.cpp.hpp, so .pch detection needs its own walk. Adds a new ci/lint_cpp_rs/src/checkers/structural_passes.rs hosting `run_structural_passes()`, invoked from `run_cli` after the per-file pass when no explicit input paths are supplied. The hook is the template that the remaining Tier-3 walkers (iwyu_pragma_check, test_aggregation_checker, test_unity_build) will fill out in follow-up PRs — they are documented as deferred on issue #3297. Verification: - FL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.py -> Rust/Python parity holds for all 67 ported checkers (60 from #3293 + 6 single-file + 1 structural = 67 in RUST_SUPPORTED_CHECKERS now). - bash lint --cpp -> green. - uv run python ci/lint_cpp/rust_binary_cache.py -> rebuilds the binary once after these crate edits, then no-ops. - Verification command from #3297 trims from 11 to 6 unfinished Python files (target is the 3 Tier-4 AST ratchet entries; the 3 remaining Tier-3 walkers are tracked on the same issue). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ci/lint_cpp_rs/src/checkers/public_settings.rs (1)
39-46: 💤 Low valueSilent fallback when
FastLED.his missing may cause noisy false positives.If
src/FastLED.hdoesn't exist or is unreadable,unwrap_or_default()returns an empty string. This causesis_wrapped_in_fastled_hto returnfalsefor every setter, flagging all of them as missing wrappers—potentially dozens of spurious violations.Consider logging a warning or returning early from the checker when the file is missing, to distinguish "wrapper file missing" from "wrapper not found in file."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ci/lint_cpp_rs/src/checkers/public_settings.rs` around lines 39 - 46, The fastled_h_content_for function silently falls back to an empty string when src/FastLED.h is missing or unreadable, causing all setters to be incorrectly flagged as missing wrappers. Instead of using unwrap_or_default(), handle the error case explicitly by logging a warning message when the file cannot be read, so that missing wrapper violations can be distinguished from a missing wrapper file. This will prevent spurious false positive violations from being reported.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@ci/lint_cpp_rs/src/checkers/public_settings.rs`:
- Around line 39-46: The fastled_h_content_for function silently falls back to
an empty string when src/FastLED.h is missing or unreadable, causing all setters
to be incorrectly flagged as missing wrappers. Instead of using
unwrap_or_default(), handle the error case explicitly by logging a warning
message when the file cannot be read, so that missing wrapper violations can be
distinguished from a missing wrapper file. This will prevent spurious false
positive violations from being reported.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f2887a45-17dc-417d-96d3-2fa358b8546f
📒 Files selected for processing (16)
ci/lint_cpp/bare_libm_checker.pyci/lint_cpp/bare_noinline_checker.pyci/lint_cpp/bare_snprintf_checker.pyci/lint_cpp/fl_no_underscore_checker.pyci/lint_cpp/legacy_log_macro_checker.pyci/lint_cpp/pch_file_checker.pyci/lint_cpp/public_settings_pattern_checker.pyci/lint_cpp/run_all_checkers.pyci/lint_cpp/rust_bridge.pyci/lint_cpp/test_public_settings_pattern_checker.pyci/lint_cpp_rs/src/checkers/bare_legacy.rsci/lint_cpp_rs/src/checkers/public_settings.rsci/lint_cpp_rs/src/checkers/structural_passes.rsci/lint_cpp_rs/src/lib.rsci/lint_cpp_rs/src/lint_core/processor_registry_cli.rsci/lint_cpp_rs/src/lint_core/regexes.rs
💤 Files with no reviewable changes (8)
- ci/lint_cpp/pch_file_checker.py
- ci/lint_cpp/fl_no_underscore_checker.py
- ci/lint_cpp/bare_snprintf_checker.py
- ci/lint_cpp/legacy_log_macro_checker.py
- ci/lint_cpp/public_settings_pattern_checker.py
- ci/lint_cpp/test_public_settings_pattern_checker.py
- ci/lint_cpp/bare_libm_checker.py
- ci/lint_cpp/bare_noinline_checker.py
Closes #3297. Migrates the last three Python C++ linters into the Rust fastled-lint binary, leaving only the explicitly-out-of-scope Tier-4 AST ratchet trio (#3288 carve-out). Ports: - IwyuPragmaPrivateChecker (ci/lint_cpp_rs/src/checkers/bare_legacy.rs): per-file check that headers under src/platforms/<subdir>/ carry an IWYU pragma marker. Root-level src/platforms/ files are public by default and remain exempt. Replaces ci/lint_cpp/iwyu_pragma_check.py and its subprocess shim in stage_impls.run_iwyu_pragma_check{, _single_file}(). - TestAggregationChecker structural pass (ci/lint_cpp_rs/src/checkers/structural_passes.rs): whole-project walker over TEST_AGGREGATED_DIRS that emits "Missing aggregator", "orphaned test file", and "should use .hpp" violations in the Python message format. Per-file TestAggregationChecker (already ported in #3293) keeps targeting individual aggregator / hpp files. - UnityBuildChecker (ci/lint_cpp_rs/src/checkers/unity_build.rs): the largest port — 1204 LOC Python distilled into both - whole-project unity_build_pass() with 11 individual 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 build-file content, build- file naming, no orphan .cpp files, library.json srcFilter) - per-file UnityBuildChecker for single-file lint-on-save mode. Wiring: - structural_passes.rs run_structural_passes() now invokes the three cross-file walkers (pch_file, test_aggregation, unity_build) after the per-file dispatch when no explicit input paths are supplied. - rust_bridge.py RUST_SUPPORTED_CHECKERS gains IwyuPragmaPrivateChecker, UnityBuildChecker; the orchestrator's remove_rust_supported_checkers pass and the A/B compare key on these names. - run_all_checkers.py drops the run_unity_build_check(), check_unity_build_single_file(), and check_test_aggregation_single_file() call sites — they're now redundant with the Rust path. - stage_impls.run_iwyu_pragma_check{,_single_file}() become no-op stubs (kept so existing callers don't break during the deprecation window). Deletions: - ci/lint_cpp/iwyu_pragma_check.py - ci/lint_cpp/test_aggregation_checker.py - ci/lint_cpp/test_unity_build.py Verification: - FL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.py -> Rust/Python parity holds for all 70 ported checkers (67 from prior commits + IwyuPragmaPrivateChecker + UnityBuildChecker + structural test_aggregation_pass). - bash lint --cpp -> green. - uv run python ci/lint_cpp/rust_binary_cache.py -> rebuilds the binary on first run, then no-ops. - pyright clean on the changed Python files. - Verification command output trimmed to exactly 3 lines (Tier-4 only): ci/lint_cpp/noexcept_checker.py ci/tools/check_array_params.py ci/tools/check_noexcept.py These remain by design — #3288 explicitly out-of-scopes the clang-query AST ratchets. Migration #3297 is complete within its stated bounds. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…deRabbit CI runs of `bash lint --cpp` on linux/macos failed because the clang-query AST ratchets (FL_NO_EXCEPT + decayed array params) couldn't locate `clang-tool-chain-query`: the CI runners don't have a full LLVM toolchain installed and the `clang-tool-chain` Python wheel doesn't ship the inner binary on those platforms. The ratchets are explicitly out-of-scope per #3288 (Tier-4) and should not gate the lint when the underlying tool is absent. Changes: 1. ci/lint_cpp/run_all_checkers.py: - New `_ast_tool_unavailable()` helper that classifies the NoexceptCheckError / ArrayParamCheckError message as a tool-absence signal vs a real ratchet violation. - run_noexcept_ast_check + run_array_param_ast_check now print a stderr `⚠️ Skipping ...` warning when the AST tool is absent and return an empty CheckerResults, instead of emitting a fake violation that blocks the lint. Tool-absence is detected for both the "clang-query not found ... Install LLVM ..." flavor (raised when _find_clang_query returns empty) and the "Failed to spawn: `clang-tool-chain-query` ... No such file or directory" flavor (raised when uv can resolve uv itself but not the inner entry- point — exactly the case CI hit on linux/macos). 2. agents/docs/linter-architecture.md: - Addresses the CodeRabbit minor finding on this PR by adding a "Crate layout note" callout explaining that the lint_core helpers and the FileContentChecker trait are module-private and only reach checker files via `include!()` from lib.rs. Future contributors should add new files under ci/lint_cpp_rs/src/checkers/, wire them with another `include!()` in lib.rs, and avoid trying to `pub`-qualify or `use crate::...` these symbols. Verification: - bash lint --cpp -> green locally (clang-tool-chain-query IS on PATH on this dev box, so the AST ratchets run; the fallback only kicks in when the tool genuinely isn't available). - uv run pyright ci/lint_cpp/run_all_checkers.py -> 0 errors. The other CodeRabbit major finding on this PR (`rust_binary_cache._binary_candidate_paths` host-aware ordering) was addressed earlier in commit 7bd83d0 — CodeRabbit's "✅ Addressed in commit 7bd83d0" note confirms. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ool_unavailable tightening, cpp_lint cache Rust sources, lint-on-save examples, FL_LINT_AB retirement) Five small lint-infrastructure fixes from issue #3308: 1. PchFileChecker case-sensitivity divergence (HIGH) ci/lint_cpp_rs/src/checkers/structural_passes.rs now uses an exact-case ext match (Some("pch")) instead of eq_ignore_ascii_case so the Rust port matches Python's case-sensitive rglob("*.pch") on Linux/macOS. 2. _ast_tool_unavailable over-broad (HIGH) ci/lint_cpp/run_all_checkers.py: dropped the bare "no such file or directory" branch; now requires the clang-query tool name to co-occur with "not found" or "failed to spawn". 3. cpp_lint_cache.py fingerprint omits Rust sources (MEDIUM) ci/cpp_lint_cache.py: added Cargo.toml, Cargo.lock and src/**/*.rs to both the default glob list and the DependencyManifest path so local edits to Rust checkers force a re-lint. 4. lint-on-save.py skips examples/ C++ files (MEDIUM) ci/hooks/lint-on-save.py: removed the examples/ short-circuit so the Rust path runs on save for examples-scope checkers (UsingNamespaceFlInExamplesChecker, ExampleSerialChecker, etc.); the fingerprint cache keeps per-save cost low. 5. FL_LINT_AB=1 is functionally a no-op (MEDIUM) create_checkers() returns all-empty lists post-#3293, so the A/B compare was trivially empty. Removed run_rust_ab_check, _canonical_results, _print_diff_sample, RUST_SUPPORTED_CHECKERS, and remove_rust_supported_checkers from ci/lint_cpp/rust_bridge.py and stripped the FL_LINT_AB env-var plumbing from ci/lint_cpp/run_all_checkers.py. Drive-by: fixed a pre-existing pyright reportUnknownVariableType warning on parse_rust_json_output() with an explicit cast. Refs #3308 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…3319) * docs: retire stale references to deleted Python C++ checkers (#3308) After #3293 migrated the C++ checker fleet from Python to the Rust crate at ci/lint_cpp_rs/, several docs and configs still pointed at deleted .py files. Update every stale pointer to the live Rust target and prune the stale checker list in ci/dependencies.json. - agents/docs/linter-architecture.md: rewrite "When to still use Python" — only the 3 Tier-4 AST ratchets remain in Python. - agents/docs/cpp-standards.md: point Public Settings allowlist at ci/lint_cpp_rs/src/checkers/public_settings.rs::PUBLIC_SETTINGS_GRANDFATHERED. - .claude/agents/cpp-linter-builder-agent.md: replace deleted unity / aggregation / pch py paths with the Rust analogues. - .claude/agents/architecture-reviewer-agent.md: update PublicSettings pointer to the Rust checker. - .claude/commands/code_review.md: same update. - ci/dependencies.json: prune the tools array to surviving entries (run_all_checkers.py, rust_bridge.py, rust_binary_cache.py, noexcept_checker.py) plus the ci/lint_cpp_rs/ crate. - src/fl/stl/compiler_control.h: redirect FL_NO_INLINE comment to BareNoInlineChecker in ci/lint_cpp_rs/src/checkers/bare_legacy.rs. - ci/fix_has_include_README.md: rewrite the retired-rule paragraph per #3308 acceptance criterion. - ci/fix_has_include.py: add docstring marking it manual-only. Verified: bash lint --cpp passes; ci/dependencies.json parses; sweep grep returns 0 hits outside ci/lint_cpp_rs/ migration comments. Refs #3308. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs: address CodeRabbit — clarify AST ratchet count The clang-query AST tier consists of two distinct ratchets (noexcept and decayed array params) implemented across three Python files (the orchestrator function file + two clang-query backends). Update the sentence so the rule count matches CodeRabbit's reading while still hinting at the file count the #3308 verification command surfaces. Refs #3308. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…tool_unavailable tightening, cpp_lint cache Rust sources, lint-on-save examples, FL_LINT_AB retirement (#3320) Five small lint-infrastructure fixes from issue #3308: 1. PchFileChecker case-sensitivity divergence (HIGH) ci/lint_cpp_rs/src/checkers/structural_passes.rs now uses an exact-case ext match (Some("pch")) instead of eq_ignore_ascii_case so the Rust port matches Python's case-sensitive rglob("*.pch") on Linux/macOS. 2. _ast_tool_unavailable over-broad (HIGH) ci/lint_cpp/run_all_checkers.py: dropped the bare "no such file or directory" branch; now requires the clang-query tool name to co-occur with "not found" or "failed to spawn". 3. cpp_lint_cache.py fingerprint omits Rust sources (MEDIUM) ci/cpp_lint_cache.py: added Cargo.toml, Cargo.lock and src/**/*.rs to both the default glob list and the DependencyManifest path so local edits to Rust checkers force a re-lint. 4. lint-on-save.py skips examples/ C++ files (MEDIUM) ci/hooks/lint-on-save.py: removed the examples/ short-circuit so the Rust path runs on save for examples-scope checkers (UsingNamespaceFlInExamplesChecker, ExampleSerialChecker, etc.); the fingerprint cache keeps per-save cost low. 5. FL_LINT_AB=1 is functionally a no-op (MEDIUM) create_checkers() returns all-empty lists post-#3293, so the A/B compare was trivially empty. Removed run_rust_ab_check, _canonical_results, _print_diff_sample, RUST_SUPPORTED_CHECKERS, and remove_rust_supported_checkers from ci/lint_cpp/rust_bridge.py and stripped the FL_LINT_AB env-var plumbing from ci/lint_cpp/run_all_checkers.py. Drive-by: fixed a pre-existing pyright reportUnknownVariableType warning on parse_rust_json_output() with an explicit cast. Refs #3308 Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Closes #3288 and #3297. Migrates the C++ lint pipeline to the Rust
fastled-lintbinary (ci/lint_cpp_rs/) as the mandatory defaulteverywhere —
bash lint --cpp, hooks, and CI. Retires 70 Pythoncheckers in total.
Headline numbers
*_checker.pyfiles deleted (60 in the initial Mandatory C++ linter migration: Rust-only via build-on-change cache, retire Python checkers #3288migration, 10 in the Finish #3288 migration: retire remaining single-file Python C++ checkers (Tier 1-3) #3297 follow-up).
ci/lint_cpp_rs/src/checkers/(
bare_legacy.rs,public_settings.rs,unity_build.rs,structural_passes.rs, plus the original split).explicitly out-of-scope per Mandatory C++ linter migration: Rust-only via build-on-change cache, retire Python checkers #3288 (libclang Rust binding tracked
separately).
Verification command (acceptance criterion from #3297)
Output as of this PR's HEAD:
3 lines (Tier-4 only) ⇒ migration complete within stated bounds.
What's in here
ci/lint_cpp/rust_binary_cache.pyfingerprints
ci/lint_cpp_rs/src/**/*.rs+Cargo.toml+Cargo.locknatively via
os.stat+ blake2b — ~1ms hot path, no broker IPC.Rebuilds via
soldronly when sources change. Host-aware /deterministic binary-path selection. Atomic fingerprint write
(tmp +
os.replace).--rustis default-on viaargparse.BooleanOptionalAction;--no-rustis the escape hatch..github/workflows/template_unit_test.ymlrunsbash lint --cppon every PR, with
actions/cache@v4forci/lint_cpp_rs/target/keyed on
Cargo.lock + src/**/*.rs, plus atimeout-minutes: 30job cap.
soldr>=0.7.55pinned inpyproject.toml.*_checker.pyfiles deleted plus their tests.Surgical edits where files held shared data tables.
run_all_checkers.pynow instantiates ZERO Python-only checkers.Cross-file structural walks (pch_file, test_aggregation, unity_build,
iwyu_pragma_check) ship as the Rust
run_structural_passes()hookinvoked after the per-file pass.
Grand-dispatch preservation
The Rust
MultiCheckerFileProcessor(
ci/lint_cpp_rs/src/lint_core/processor_registry_cli.rs) uses aper-path
HashMapcache, reads files in parallel via rayon, then runsevery interested checker on each cached
FileContent— read-once +N-checkers preserved (and parallelized) from Python.
A/B parity verified
FL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.pypassesfor all 70 entries in
RUST_SUPPORTED_CHECKERS(zero divergence).Test plan
bash lint --cpp→ all phases green locally (47s)uv run python ci/lint_cpp/run_all_checkers.py→ passFL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.py→parity passes for the full 70-checker set
entries
🤖 Generated with Claude Code