Repository navigation
Port remaining C++ lint checkers to Rust - #2692
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds legacy violation normalization, skips include violations when ChangesC++ Linter Enhancement and Rust Parity
🎯 3 (Moderate) | ⏱️ ~25 minutes 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 docstrings
🧪 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: 3
🧹 Nitpick comments (1)
ci/lint_cpp/test_rust_parity.py (1)
94-114: ⚖️ Poor tradeoffDuplicated normalization helper diverging from the production version.
This
_legacy_violation_item_to_line_contentis a near-copy of the one inci/lint_cpp/run_all_checkers.py(per the relevant snippet), differing only in that this one raisesAssertionErrorwhile production returnsNonefor 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
📒 Files selected for processing (6)
ci/lint_cpp/check_namespace_includes.pyci/lint_cpp/logging_in_iram_checker.pyci/lint_cpp/run_all_checkers.pyci/lint_cpp/rust_bridge.pyci/lint_cpp/test_rust_parity.pyci/lint_cpp_rs/src/lib.rs
Closes #2488
Summary:
// nolintsuppression for that checkerValidation:
soldr cargo fmt --manifest-path ci/lint_cpp_rs/Cargo.tomluv 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.pysoldr cargo test --manifest-path ci/lint_cpp_rs/Cargo.tomluv run python -m pytest ci/lint_cpp/test_rust_parity.py -quv 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.pyuv run python ci/lint_cpp/run_all_checkers.py --rustFL_LINT_AB=1 uv run python ci/lint_cpp/run_all_checkers.pySummary by CodeRabbit
Improvements
// nolintto skip reported violations.Tests