Skip to content

Port remaining C++ lint checkers to Rust - #2692

Merged
zackees merged 8 commits into
masterfrom
feat/lint-cpp-rs-followup
Jun 3, 2026
Merged

zackees merged 8 commits into
masterfrom
feat/lint-cpp-rs-followup

Conversation

@zackees

@zackees zackees commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

Closes #2488

Summary:

  • port the remaining unified C++ lint checkers to the Rust fast path, including banned headers and namespace include ordering
  • add the missing native platform define and special-member FL_NOEXCEPT parity coverage from this follow-up batch
  • teach unified Python result conversion to handle namespace include records and honor existing // nolint suppression for that checker
  • bring Rust-supported checker coverage to 60/60 registered checker classes

Validation:

  • soldr cargo fmt --manifest-path ci/lint_cpp_rs/Cargo.toml
  • uv run ruff format ci/lint_cpp/test_rust_parity.py ci/lint_cpp/rust_bridge.py ci/lint_cpp/run_all_checkers.py ci/lint_cpp/check_namespace_includes.py
  • soldr cargo test --manifest-path ci/lint_cpp_rs/Cargo.toml
  • uv run python -m pytest ci/lint_cpp/test_rust_parity.py -q
  • uv run ruff check ci/lint_cpp/test_rust_parity.py ci/lint_cpp/rust_bridge.py ci/lint_cpp/run_all_checkers.py ci/lint_cpp/check_namespace_includes.py
  • uv run python ci/lint_cpp/run_all_checkers.py --rust
  • FL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.py

Summary by CodeRabbit

  • Improvements

    • C++ linting now respects // nolint to skip reported violations.
    • Comment stripping preserves line numbering to improve error location accuracy.
    • Adjusted set of checkers considered supported by the faster Rust path.
  • Tests

    • Expanded Rust-vs-Python parity tests to cover many more checker scenarios and result shapes.
    • Improved normalization of violation results for consistent reporting across tools.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0ee24a63-0cbf-43f7-954d-b90db4daf2ff

📥 Commits

Reviewing files that changed from the base of the PR and between d25c1f6 and 9905790.

📒 Files selected for processing (3)
  • ci/lint_cpp/run_all_checkers.py
  • ci/lint_cpp/test_rust_parity.py
  • ci/lint_cpp_rs/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • ci/lint_cpp/run_all_checkers.py

📝 Walkthrough

Walkthrough

Adds legacy violation normalization, skips include violations when // nolint is present, preserves line numbers when stripping block comments, adjusts the Rust-supported checker set, and substantially expands the Rust/Python parity test matrix.

Changes

C++ Linter Enhancement and Rust Parity

Layer / File(s) Summary
Violation item normalization helpers
ci/lint_cpp/run_all_checkers.py
Adds LegacyViolationLineContent dataclass and _legacy_violation_item_to_line_content() to normalize legacy violation items (tuple or object) into consistent (line_number, message) entries; _convert_violations_to_results now uses this helper.
Checker enhancements: nolint support and line numbering
ci/lint_cpp/check_namespace_includes.py, ci/lint_cpp/logging_in_iram_checker.py
NamespaceIncludesChecker now skips include violations for lines containing // nolint across thorough, fast, and file-content checks. logging_in_iram_checker.strip_comments() replaces multi-line /* ... */ blocks with equivalent newlines to preserve line numbers.
Rust-supported checkers expansion
ci/lint_cpp/rust_bridge.py
Updates RUST_SUPPORTED_CHECKERS set contents used for Rust-supported filtering and parity canonicalization.
Rust/Python parity test harness expansion
ci/lint_cpp/test_rust_parity.py
Broadly expands checker imports, updates _python_records to handle CheckerResults, string violations, and legacy items via the new normalization helper, and adds many new parametrized test cases and monkeypatch configuration for the extended checker set.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • FastLED/FastLED#2689: Introduced initial Rust-backed lint checker wiring that this PR extends by expanding Rust-supported checkers and parity tests.

Poem

🐰 I hopped through code with tiny paws,

Skipped the includes with gentle "nolint" laws.
Comments kept their lines, each newline preserved,
Old violations normalized, now neatly served.
Parity tests bloom — the rabbit cheers, well-deserved!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Port remaining C++ lint checkers to Rust' accurately summarizes the main objective of porting the final set of C++ lint checkers (banned headers and namespace includes) to the Rust fast path.
Linked Issues check ✅ Passed The PR successfully implements key objectives from #2488: ports remaining checkers (banned headers, namespace includes) to Rust, updates Python result conversion for namespace-include records with nolint support, and achieves 60/60 registered checker class coverage.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the PR objectives: namespace/include checker logic, comment-stripping improvements, result normalization for legacy violations, Rust parity configuration, and expanded parity test coverage—all supporting the checker porting effort.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/lint-cpp-rs-followup

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.

@fastled-project-sync fastled-project-sync Bot moved this to In Progress in FastLED Tracker Jun 3, 2026
@zackees
zackees marked this pull request as ready for review June 3, 2026 01:51
@fastled-project-sync fastled-project-sync Bot moved this from In Progress to Triage in FastLED Tracker Jun 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
ci/lint_cpp/test_rust_parity.py (1)

94-114: ⚖️ Poor tradeoff

Duplicated normalization helper diverging from the production version.

This _legacy_violation_item_to_line_content is a near-copy of the one in ci/lint_cpp/run_all_checkers.py (per the relevant snippet), differing only in that this one raises AssertionError while production returns None for unsupported items. Since the parity harness must mirror production normalization exactly to keep the Python oracle trustworthy, consider importing the production helper and adapting the "unsupported" handling at the call site, so the two can't silently drift.

🤖 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/test_rust_parity.py` around lines 94 - 114, The test helper
_legacy_violation_item_to_line_content duplicates production logic but raises
AssertionError instead of returning None for unsupported items; remove this
duplicate and import the canonical helper from ci/lint_cpp/run_all_checkers.py
(the original _legacy_violation_item_to_line_content) and update the call sites
in ci/lint_cpp/test_rust_parity.py that used to expect an exception to instead
handle a None return (i.e., treat None as “unsupported” or skip those items) so
the test harness mirrors production behavior exactly and cannot drift.
🤖 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/run_all_checkers.py`:
- Around line 554-563: The helper _legacy_violation_item_to_line_content should
fail fast and return a structured dataclass rather than silently returning None
or a raw tuple: define a small dataclass (e.g., ViolationLine with fields line:
int and content: str), update _legacy_violation_item_to_line_content to return
ViolationLine, and when an item is neither a tuple of at least two values nor
has include_line/include_snippet raise a descriptive ValueError (including the
item's repr and type) instead of returning None; also update the alternate
branch referenced around lines 594-597 to follow the same dataclass return and
error behavior so callers receive a consistent, typed object and cannot silently
drop invalid shapes.

In `@ci/lint_cpp/rust_bridge.py`:
- Line 37: The parity test matrix is missing four Rust checkers so the Rust
parity suite doesn't cover all entries in RUST_SUPPORTED_CHECKERS; update the
parametrized matrix in test_rust_parity.py to include "HeadersExistChecker",
"TestAggregationChecker", "TestIncludePathsChecker", and
"TestPathStructureChecker" so each checker registered in RUST_SUPPORTED_CHECKERS
has a corresponding test case; locate the test parametrization (the list/tuple
passed to pytest.mark.parametrize in test_rust_parity.py) and add these four
checker names to that collection to ensure full parity coverage.

In `@ci/lint_cpp/test_rust_parity.py`:
- Around line 134-142: Replace the list comprehension that builds the records in
the CheckerResults branch with an explicit for-loop: iterate over
file_violations.violations, construct each record dict using
checker.__class__.__name__, _normalize_path(file_path), violation.line_number
and violation.content, and append each dict to a records list, then return that
list (matching the style used in the legacy branch). Ensure you use the same
variable names (checker, file_path, file_violations, violation) and maintain the
same keys ("checker", "path", "line", "message") so behavior is unchanged.

---

Nitpick comments:
In `@ci/lint_cpp/test_rust_parity.py`:
- Around line 94-114: The test helper _legacy_violation_item_to_line_content
duplicates production logic but raises AssertionError instead of returning None
for unsupported items; remove this duplicate and import the canonical helper
from ci/lint_cpp/run_all_checkers.py (the original
_legacy_violation_item_to_line_content) and update the call sites in
ci/lint_cpp/test_rust_parity.py that used to expect an exception to instead
handle a None return (i.e., treat None as “unsupported” or skip those items) so
the test harness mirrors production behavior exactly and cannot drift.
🪄 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: 1215911d-adb5-4d6a-a17b-a34bf9494287

📥 Commits

Reviewing files that changed from the base of the PR and between dcf1d4e and d25c1f6.

📒 Files selected for processing (6)
  • ci/lint_cpp/check_namespace_includes.py
  • ci/lint_cpp/logging_in_iram_checker.py
  • ci/lint_cpp/run_all_checkers.py
  • ci/lint_cpp/rust_bridge.py
  • ci/lint_cpp/test_rust_parity.py
  • ci/lint_cpp_rs/src/lib.rs

Comment thread ci/lint_cpp/run_all_checkers.py Resolved
Comment thread ci/lint_cpp/rust_bridge.py Resolved
Comment thread ci/lint_cpp/test_rust_parity.py Resolved
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.

Port C++ linter framework from Python to Rust, launched via 'soldr cargo run'

1 participant