Skip to content

Conversation

@2bndy5
Copy link
Contributor

@2bndy5 2bndy5 commented Dec 23, 2025

ref cpp-linter/cpp-linter-action#388

See also official LLVM python script about their use of --lines values.

I updated some of the test assets to correspond with these changes..

Summary by CodeRabbit

  • Bug Fixes

    • Fixed line-range calculations so reported ranges use correct inclusive boundaries (no off-by-one offsets).
  • Tests

    • Updated multiple test expectations and captured output fixtures to reflect the corrected line-number reporting.

✏️ Tip: You can customize this high-level summary in your review settings.

ref cpp-linter/cpp-linter-action#388

See also official [LLVM python script][llvm-py] about their use of `--lines` values.

I updated some of the test assets to correspond with these changes..

[llvm-py]: https://github.com/llvm/llvm-project/blob/14784225cf028af54dda350114d5495ab94d572e/clang/tools/clang-format/git-clang-format#L633
@github-actions github-actions bot added the bug Something isn't working label Dec 23, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 23, 2025

Walkthrough

Adjusted inclusive handling of line ranges and test expectations: clarified clang-format line-range comment; changed range consolidation to stop extending end by +1; updated multiple test JSON files and a unit test to reflect the new inclusive range boundaries.

Changes

Cohort / File(s) Summary
Range logic & formatting
cpp_linter/common_fs/__init__.py, cpp_linter/clang_tools/clang_format.py
Updated _consolidate_list_to_ranges to produce inclusive end boundaries (removed +1 offsets). Added/clarified comment near clang-format lines argument; no control-flow changes.
Test expected results (chocolate-doom)
tests/capture_tools_output/chocolate-doom/.../67715d6e2725322e6132e9ff99b9a2a3f3b10c83/expected-result_{0,1,2}.json, tests/capture_tools_output/chocolate-doom/.../71091562db5b0e7853d08ffa2f110af49cc3bc0d/expected-result_{0,1,2}.json
Decremented several lines_added numeric endpoints (e.g., 214→213, 56→55) to match inclusive range semantics.
Test expected results (shenxianpeng repo)
tests/capture_tools_output/shenxianpeng/test-repo/.../662ad4cf90084063ea9c089b8de4aff0b8959d0e/expected-result_{0,1,2}.json
Single-line adjustments of lines_added (5404→5403) across JSON fixtures.
Unit test update
tests/test_misc.py
Updated FileObj.serialize() expectations: lines_added changed from [[5, 6], [10, 11]] to [[5, 5], [10, 10]] to reflect inclusive ranges.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • shenxianpeng

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: treat clang-format --lines as inclusive ranges' directly and clearly describes the main change across the entire changeset: correcting how line ranges are interpreted as inclusive rather than exclusive.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fmt-inclusive-line-ranges

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6884a95 and 25aea4b.

📒 Files selected for processing (1)
  • cpp_linter/clang_tools/clang_format.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • cpp_linter/clang_tools/clang_format.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: test (ubuntu-latest, 13)
  • GitHub Check: test (ubuntu-latest, 12)
  • GitHub Check: test (windows-latest, 11)
  • GitHub Check: test (windows-latest, 15)
  • GitHub Check: test (ubuntu-latest, 14)
  • GitHub Check: test (windows-latest, 17)
  • GitHub Check: test (ubuntu-latest, 18)
  • GitHub Check: test (windows-latest, 10)
  • GitHub Check: test (windows-latest, 9)
  • GitHub Check: test (windows-latest, 12)
  • GitHub Check: test (ubuntu-latest, 21)
  • GitHub Check: test (windows-latest, 20)
  • GitHub Check: test (ubuntu-latest, 17)
  • GitHub Check: test (windows-latest, 14)
  • GitHub Check: test (windows-latest, 19)
  • GitHub Check: test (windows-latest, 13)
  • GitHub Check: test (windows-latest, 16)
  • GitHub Check: test (windows-latest, 21)
  • GitHub Check: test (ubuntu-latest, 20)
  • GitHub Check: test (windows-latest, 18)

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.

@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.26%. Comparing base (7e2a47a) to head (25aea4b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #175   +/-   ##
=======================================
  Coverage   98.26%   98.26%           
=======================================
  Files          23       23           
  Lines        1897     1897           
=======================================
  Hits         1864     1864           
  Misses         33       33           

☔ View full report in Codecov by Sentry.
📢 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.

@2bndy5
Copy link
Contributor Author

2bndy5 commented Dec 23, 2025

Apparently, this is already being done in cpp-linter-rs.

@2bndy5
Copy link
Contributor Author

2bndy5 commented Dec 25, 2025

I looked at the history of the LLVM py script... The --lines value has always been inclusive since it was first introduced (around clang v3.4) in the python script (see llvm/llvm-project@695bad5). I'm now confident this patch should not cause undesirable regressions.

@2bndy5 2bndy5 merged commit 0f9d326 into main Dec 26, 2025
43 checks passed
@2bndy5 2bndy5 deleted the fmt-inclusive-line-ranges branch December 26, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants