Skip to content

refactor(lint): split Rust C++ linter sources - #3121

Merged
zackees merged 1 commit into
masterfrom
feat/3119-lint-cpp-rs-modules
Jun 16, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/3119-lint-cpp-rs-modules

Conversation

@zackees

@zackees zackees commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • split ci/lint_cpp_rs/src/lib.rs into small Rust source files under lint_core/ and checkers/
  • preserve the existing crate-level one-read MultiCheckerFileProcessor dispatch path via include!
  • add regression coverage for the 1,000-line source cap, selected-checker filtering, and JSON violation shape
  • document the Rust checker chunk layout relative to the Python checker prior art

Closes #3119

Tests

  • soldr cargo fmt --manifest-path ci/lint_cpp_rs/Cargo.toml -- --check
  • soldr cargo check --manifest-path ci/lint_cpp_rs/Cargo.toml
  • soldr cargo test --manifest-path ci/lint_cpp_rs/Cargo.toml
  • soldr cargo run --release --bin fastled-lint --manifest-path ci/lint_cpp_rs/Cargo.toml -- --format json --project-root . --checker banned_macros ci/lint_cpp_rs/src/lint_core/tests.rs
  • uv run python ci/lint_cpp/run_all_checkers.py --rust ci/lint_cpp_rs/src/lint_core/tests.rs
  • git diff --check

Summary by CodeRabbit

  • New Features
    • Added comprehensive C++ code linting tool with multiple checker categories for style, runtime, platform, and code structure validation.
    • Implemented CLI with selectable checkers, JSON/text output formats, and customizable linting rules.
    • Added documentation for linter architecture and checker layout.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f939e0ba-6ff9-47e1-8330-ce8baad2819e

📥 Commits

Reviewing files that changed from the base of the PR and between 3e14cd2 and 33a04a3.

📒 Files selected for processing (17)
  • ci/lint_cpp_rs/src/checkers/README.md
  • ci/lint_cpp_rs/src/checkers/basic.rs
  • ci/lint_cpp_rs/src/checkers/platform_policy.rs
  • ci/lint_cpp_rs/src/checkers/platform_trampoline.rs
  • ci/lint_cpp_rs/src/checkers/preprocessor.rs
  • ci/lint_cpp_rs/src/checkers/runtime.rs
  • ci/lint_cpp_rs/src/checkers/style.rs
  • ci/lint_cpp_rs/src/checkers/test_structure.rs
  • ci/lint_cpp_rs/src/checkers/types_and_tests.rs
  • ci/lint_cpp_rs/src/lib.rs
  • ci/lint_cpp_rs/src/lint_core/analysis_helpers.rs
  • ci/lint_cpp_rs/src/lint_core/banned_header_data.rs
  • ci/lint_cpp_rs/src/lint_core/path_helpers.rs
  • ci/lint_cpp_rs/src/lint_core/prelude_constants.rs
  • ci/lint_cpp_rs/src/lint_core/processor_registry_cli.rs
  • ci/lint_cpp_rs/src/lint_core/regexes.rs
  • ci/lint_cpp_rs/src/lint_core/tests.rs

📝 Walkthrough

Walkthrough

This PR splits the monolithic ci/lint_cpp_rs/src/lib.rs Rust C++ linter into separate modules under lint_core/ (infrastructure, helpers, static data, regexes, CLI) and checkers/ (eight policy-area modules implementing ~40 FileContentChecker rules), preserving the single-pass file-loading dispatcher while satisfying a sub-1000 LOC per module constraint.

Changes

Rust C++ Linter Module Split

Layer / File(s) Summary
Public contracts, static data, and regex cache
ci/lint_cpp_rs/src/lint_core/processor_registry_cli.rs, ci/lint_cpp_rs/src/lint_core/prelude_constants.rs, ci/lint_cpp_rs/src/lint_core/banned_header_data.rs, ci/lint_cpp_rs/src/lint_core/regexes.rs
Defines FileContent, FileContentChecker trait, LintViolation, MultiCheckerFileProcessor (parallel caching processor), all 800+ lines of lint configuration constants (extension filters, allow/deny lists, macro mappings), banned header arrays with recommendations and exceptions, and ~130 OnceLock-cached regex factory functions.
CLI orchestration, path helpers, and analysis helpers
ci/lint_cpp_rs/src/lint_core/processor_registry_cli.rs, ci/lint_cpp_rs/src/lint_core/path_helpers.rs, ci/lint_cpp_rs/src/lint_core/analysis_helpers.rs
Implements run_cli (arg parsing, checker selection, file collection, JSON/text output), directory traversal with .cpp_no_lint support and Windows UNC normalization, include-path classification and namespace analysis, noexcept/signature classification, test aggregation validation, naming-style conversion, paren matching, and comment-stripping utilities.
basic, preprocessor, and runtime checkers
ci/lint_cpp_rs/src/checkers/basic.rs, ci/lint_cpp_rs/src/checkers/preprocessor.rs, ci/lint_cpp_rs/src/checkers/runtime.rs
Adds 27 FileContentChecker implementations covering: bare allocations, banned macros (__has_include, static_assert), include path validation, __builtin_memcpy, static-in-header; weak attributes, banned #if patterns, *.cpp.hpp include rules, #pragma once, esp_rom_printf; sleep_for, thread_local, span-from-pointer, Arduino macros, numeric limit macros, and attribute replacements.
style, platform_policy, and platform_trampoline checkers
ci/lint_cpp_rs/src/checkers/style.rs, ci/lint_cpp_rs/src/checkers/platform_policy.rs, ci/lint_cpp_rs/src/checkers/platform_trampoline.rs
Adds 22 FileContentChecker implementations covering: pragma style, noexcept, std:: namespace, using namespace, include-after-namespace ordering; plain enum detection, namespace fl enforcement, IRAM logging restriction; deep platform includes, SIMD intrinsics, .cpp.hpp header pairs, IWYU pragma blocks, and trailing-underscore member naming.
types_and_tests, test_structure checkers, README, and unit tests
ci/lint_cpp_rs/src/checkers/types_and_tests.rs, ci/lint_cpp_rs/src/checkers/test_structure.rs, ci/lint_cpp_rs/src/checkers/README.md, ci/lint_cpp_rs/src/lint_core/tests.rs
Adds 13 FileContentChecker implementations covering: bare using, ctype/stdint type usage, subdirectory namespaces, unit-test macro conventions, header existence validation; test include path validation, test path structure, test aggregation, banned headers (scoped), native platform defines, and FL_NOEXCEPT on special members. Includes the checker module README and unit/integration tests validating CLI behavior, checker filtering, and stable LintViolation JSON shape.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • FastLED/FastLED#2689: Directly introduced the original Rust-backed fastled-lint framework that this PR refactors by splitting into sub-1000 LOC modules.
  • FastLED/FastLED#2692: Added the strip_comments() line-number-preserving logic used by the IRAM logging checker, which this PR ports into LoggingInIramChecker in platform_policy.rs.

Poem

🐇 One giant file? No more, said I,
Split into modules, tidy and spry!
Each checker its own cozy .rs lair,
Regexes cached with OnceLock care.
Sub-1k lines — the linter hops free,
A refactored warren for all to see! 🌿

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3119-lint-cpp-rs-modules

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

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

1 participant