Skip to content

feat: get clang-tidy fixes regardless of tidy-review value#354

Merged
2bndy5 merged 3 commits into
mainfrom
tidy-fixes-always
Jun 12, 2026
Merged

feat: get clang-tidy fixes regardless of tidy-review value#354
2bndy5 merged 3 commits into
mainfrom
tidy-fixes-always

Conversation

@2bndy5

@2bndy5 2bndy5 commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

This is another step toward presenting auto-fixed patches for consumers to commit/push.

This basically does what --tidy-review conditionally did before. But now it is done every time clang-tidy is invoked.

Even if not using the PR review feature, this allows us to boast if a clang-tidy note/warning can be auto-fixed. For example, the new thread comment may contain the following for something that can be auto-fixed:

  • src/demo/demo.cpp:10:3 note: [readability]
    ⚡ auto-fix available

    {rationale}

    {concerned code snippet if any}

Summary by CodeRabbit

  • New Features

    • Auto-fix availability indicator added to clang-tidy suggestions in review comments.
  • Bug Fixes

    • More reliable caching and restoration of patched files to improve suggestion accuracy and stability.
    • Suggestion generation now consistently reads cached patched content.
  • Tests

    • Tests updated to use isolated temporary workspaces and cover the new patch/restore behavior.
  • Documentation

    • Spellcheck allowlist updated to include RAII.

This is another step toward presenting auto-fixed patches for consumers to commit/push.

This basically does what `--tidy-review` conditionally did before. But now it is done every time clang-tidy is invoked.

Even if not using the PR review feature, this allows us to boast if a clang-tidy note/warning can be auto-fixed. For example, the new thread comment may contain the following for something that can be auto-fixed:

- **src/demo/demo.cpp:10:3** note: [readability]
   :zap: auto-fix available
   > <rationale>

   {concerned code snippet if any}
@2bndy5 2bndy5 added the enhancement New feature or request label Jun 12, 2026
@2bndy5 2bndy5 changed the title feat: always get clang-tidy fixes feat: get clang-tidy fixes regardless of tidy-review value Jun 12, 2026
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.31373% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.83%. Comparing base (793c310) to head (7079384).

Files with missing lines Patch % Lines
cpp-linter/src/clang_tools/clang_tidy.rs 76.81% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #354      +/-   ##
==========================================
+ Coverage   92.74%   92.83%   +0.09%     
==========================================
  Files          22       23       +1     
  Lines        3403     3461      +58     
==========================================
+ Hits         3156     3213      +57     
- Misses        247      248       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@2bndy5 2bndy5 marked this pull request as ready for review June 12, 2026 04:23
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@2bndy5, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 35 minutes and 54 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 172982af-7170-4489-9502-69f156d653df

📥 Commits

Reviewing files that changed from the base of the PR and between d7902c3 and 7079384.

📒 Files selected for processing (4)
  • cpp-linter/src/clang_tools/clang_tidy.rs
  • cpp-linter/src/lib.rs
  • cpp-linter/src/rest_client.rs
  • cpp-linter/src/run.rs

Walkthrough

TidyAdvice.patched is now a PathBuf to a cached .tidy file. parse_tidy_output returns a Vec. run_clang_tidy always runs clang-tidy --fix-errors, caches patched files under CACHE_DIR, restores repo files via a RestoreOnDrop guard, and downstream code reads patched content from disk; UI shows auto-fix markers.

Changes

TidyAdvice File-Caching Refactor

Layer / File(s) Summary
TidyAdvice contract and parse refactor
cpp-linter/src/clang_tools/clang_tidy.rs
TidyAdvice.patched changes from Option<Vec<u8>> to PathBuf. Module imports updated. parse_tidy_output now returns Result<Vec<TidyNotification>, ClangCaptureError> and tests updated to inspect the returned Vec.
File caching and restoration in run_clang_tidy
cpp-linter/src/clang_tools/clang_tidy.rs
Always adds --fix-errors, reads original file into RestoreOnDrop, runs clang-tidy to patch in-place, writes patched output to CACHE_DIR with .tidy extension, restores original repo file, disarms the guard, and sets file.tidy_advice with the cached path. Tests added/updated for stdout parsing and RestoreOnDrop behavior.
Patched content reading in make_suggestions_from_patch
cpp-linter/src/common_fs.rs
Now loads patched content via fs::read_to_string(&advice.patched) (cached PathBuf) and passes it to make_patch for suggestions.
Auto-fix display and test data alignment
cpp-linter/src/rest_client.rs
make_tidy_comment appends an auto-fix zap indicator when a note's line is in fixed_lines. Test data updated to set TidyNotification.patched to PathBuf::new() instead of None.
Test harness and temp workspace
cpp-linter/src/run.rs
mod test made pub(crate) and adds setup_tmp_workspace() to copy demo assets into a temp dir; async tests updated to use per-test --repo-root pointing at the temp workspace.
Spell-check config
cspell.config.yml
Add RAII to allowed words.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • cpp-linter/cpp-linter-rs#190: Modifies parse_tidy_output regex and note-header parsing logic, which this PR refactors further to change return types and responsibility boundaries.
  • cpp-linter/cpp-linter-rs#347: Aligns with this PR's pattern of storing clang-format/clang-tidy patched output as PathBuf cached on disk rather than in-memory bytes.
  • cpp-linter/cpp-linter-rs#77: Previously modified FileObj::make_suggestions_from_patch and diff-aware gating; closely related to how suggestions should be generated from cached patched content.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: obtaining clang-tidy fixes unconditionally, regardless of the tidy-review flag setting.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tidy-fixes-always

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.

coderabbitai[bot]

This comment was marked as resolved.

try to restore scanned file's contents upon error propagation.

add more test isolation to prevent race conditions with shared test asserts
coderabbitai[bot]

This comment was marked as resolved.

@2bndy5 2bndy5 merged commit 41fcd9e into main Jun 12, 2026
73 checks passed
@2bndy5 2bndy5 deleted the tidy-fixes-always branch June 12, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant