feat: merge review suggestions from both clang tools#358
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #358 +/- ##
==========================================
- Coverage 92.81% 92.35% -0.46%
==========================================
Files 23 23
Lines 3450 3597 +147
==========================================
+ Hits 3202 3322 +120
- Misses 248 275 +27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
b5e7407 to
e48fbfc
Compare
This is a culmination of - #354 - #347 It it the last step needed before providing a patch that consumers can push to auto-fix lints. # Intended flow of data 1. run clang-tidy before running clang-format 2. after running clang-tidy save the patched file to cache 3. after running clang-format: - check for clang-tidy patch in cache. - if cached patch is present, run clang-format on the clang-tidy patch. This step includes formatting lines that clang-tidy changed and lines that clang-format changed. - if cached patch is not present (clang-tidy was not run on the file), then cache the clang-format fixes instead. - `--lines-changed-only` is respected, but this may need tweaking in the future. 4. when creating a PR review, only add hunks that are not present in the review comments. I added a parameter to also calculate (and display) how many review comments were reused in previous PR reviews. If PR review is a summary only, then the patch will include all fixes that would have been posted in the diff. Adjusted tests accordingly.
dd4c541 to
9254f94
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR refactors the clang tool pipeline to consolidate cached patched-file ownership into a new ChangesUnified patched_path & ReviewComments refactor
Docs dependency bump
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
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
🤖 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 `@cpp-linter/src/clang_tools/clang_format.rs`:
- Around line 154-185: The joint_ranges are built using hunk.before which
contains original-file line coordinates, but the code is formatting the cached
tidy-patched file where line numbers have shifted due to tidy
insertions/deletions. Replace hunk.before with hunk.after in the map function
that builds joint_ranges to use the correct patched-file coordinates.
Additionally, translate any non-overlapping original ranges from the ranges
parameter before adding them to joint_ranges, since they also refer to
original-file coordinates and must be converted to patched-file coordinates
before being passed as --lines arguments to clang-format.
In `@cpp-linter/src/common_fs.rs`:
- Around line 261-263: The UnifiedDiffPrinter's display_hunk() method requires
that display_header() be called first to emit the hunk header line (the @@ -a,b
+c,d @@ syntax). Locate where display_hunk() is being called on the
BasicLineDiffPrinter instance and ensure that display_header() is invoked on the
printer before any display_hunk() calls to generate valid unified diff output
that can be applied as a patch.
In `@cpp-linter/src/rest_client.rs`:
- Around line 218-233: In summary-only mode, clang-tidy diagnostics without
fixes are not being added to review_comments before the decision logic runs,
causing review_comments.tool_total to be zero and allowing invalid PR approvals.
Before the block that determines options.action and options.summary (which uses
has_changes derived from review_comments.tool_total), ensure that no-fix
clang-tidy diagnostics are included in the review_comments concern count in
summary-only mode. This likely requires modifying make_suggestions_from_patch or
the code that populates review_comments to include no-fix diagnostics in the
tool_total count even when summary_only is true, so the action and summary
decisions reflect all tidy warnings.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 94621f1a-8c9c-4e79-9abb-b55f70c74f3d
📒 Files selected for processing (10)
cpp-linter/src/clang_tools/clang_format.rscpp-linter/src/clang_tools/clang_tidy.rscpp-linter/src/clang_tools/mod.rscpp-linter/src/cli/structs.rscpp-linter/src/common_fs.rscpp-linter/src/error.rscpp-linter/src/rest_client.rscpp-linter/src/run.rscpp-linter/tests/reviews.rsdocs/pyproject.toml
and some other review changes
This is a culmination of
As this builds on the plan discussed in cpp-linter/cpp-linter#82, it it the last step needed before providing a patch that consumers can push to auto-fix lints.
Intended flow of data
--lines-changed-onlyis respected, but this may need tweaking in the future.CPP_LINTER_PR_REVIEW_SUMMARY_ONLY = 1. If PR review is a summary only, then the patch will include all fixes that would have been posted in the diff.Adjusted tests accordingly.
Summary by CodeRabbit
Bug Fixes
Tests
Chores