Skip to content

Conversation

@2bndy5
Copy link
Contributor

@2bndy5 2bndy5 commented Sep 28, 2025

ref cpp-linter/cpp-linter-action#347

Basically, we just needed to account for the ,-warnings-as-errors appended to the rule name in square brackets.

Without WarningsAsErrors

tests/demo/demo.cpp:2:1: error: included header demo.hpp is not used directly [misc-include-cleaner]

With WarningsAsErrors

tests/demo/demo.cpp:2:1: error: included header demo.hpp is not used directly [misc-include-cleaner,-warnings-as-errors]

Summary by CodeRabbit

  • Bug Fixes
    • Improved clang-tidy note parsing to recognize a wider range of note formats, reducing missed diagnostics.
  • Chores
    • Enforced LF line endings for lock files and Git metadata via .gitattributes to ensure consistent text normalization across platforms.
  • Tests
    • Enabled all Clang-Tidy warnings as errors in the demo configuration to tighten quality gates.
    • Added a type-check suppression in a test to stabilize typing without changing runtime behavior.

ref cpp-linter/cpp-linter-action#347

Basically, we just needed to account for the `,-warnings-as-errors` appended to the rule name in square brackets.

### Without `WarningsAsErrors`
```text
tests/demo/demo.cpp:2:1: error: included header demo.hpp is not used directly [misc-include-cleaner]
```
### With `WarningsAsErrors`
```text
tests/demo/demo.cpp:2:1: error: included header demo.hpp is not used directly [misc-include-cleaner,-warnings-as-errors]
```
@2bndy5 2bndy5 added the bug Something isn't working label Sep 28, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 28, 2025

Walkthrough

Updates repository settings and tests: extends text normalization in .gitattributes, broadens a clang-tidy note header regex in the Python linter tool, adds a type-ignore in a test, and sets all Clang-Tidy warnings as errors in the demo configuration.

Changes

Cohort / File(s) Summary
Repository attributes
`.gitattributes`
Adds LF normalization for *.lock, `.gitignore`, and `.gitattributes` as text.
Clang-Tidy output parsing
`cpp_linter/clang_tools/clang_tidy.py`
Broadens NOTE_HEADER regex to allow optional trailing content inside brackets; no functional changes elsewhere.
Test adjustments
`tests/capture_tools_output/test_tools_output.py`
Adds # type: ignore[arg-type] to a `repo.apply(...)` call to silence a type-checker complaint.
Demo Clang-Tidy config
`tests/demo/.clang-tidy`
Sets WarningsAsErrors: '*' to treat all warnings as errors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

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 clearly and concisely describes the primary change—fixing the clang-tidy output parser to handle the WarningsAsErrors flag—using specific language that directly reflects the modifications made in the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch parse-WarningsAsErrors

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/capture_tools_output/test_tools_output.py (1)

458-458: Prefer precise typing over a blanket type ignore

If the mypy complaint is about diff’s type, consider casting to the expected pygit2 type instead of ignoring the arg type altogether.

Apply this minimal change if it satisfies the checker:

-        repo.apply(diff, pygit2.GIT_APPLY_LOCATION_BOTH)  # type: ignore[arg-type]
+        repo.apply(cast(pygit2.Diff, diff), pygit2.GIT_APPLY_LOCATION_BOTH)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3fca4e1 and e7b4abf.

📒 Files selected for processing (4)
  • .gitattributes (1 hunks)
  • cpp_linter/clang_tools/clang_tidy.py (1 hunks)
  • tests/capture_tools_output/test_tools_output.py (1 hunks)
  • tests/demo/.clang-tidy (1 hunks)
⏰ 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, 19)
  • GitHub Check: test (ubuntu-latest, 17)
  • GitHub Check: test (ubuntu-latest, 15)
  • GitHub Check: test (ubuntu-latest, 9)
  • GitHub Check: test (ubuntu-latest, 12)
  • GitHub Check: test (ubuntu-latest, 16)
  • GitHub Check: test (ubuntu-latest, 18)
  • GitHub Check: test (ubuntu-latest, 11)
  • GitHub Check: test (ubuntu-latest, 14)
  • GitHub Check: test (ubuntu-latest, 10)
  • GitHub Check: test (ubuntu-latest, 13)
  • GitHub Check: test (windows-latest, 10)
  • GitHub Check: test (ubuntu-latest, 20)
  • GitHub Check: test (ubuntu-latest, 21)
  • GitHub Check: test (windows-latest, 14)
  • GitHub Check: test (windows-latest, 15)
  • GitHub Check: test (windows-latest, 13)
  • GitHub Check: test (windows-latest, 18)
  • GitHub Check: test (windows-latest, 17)
  • GitHub Check: test (windows-latest, 19)
🔇 Additional comments (3)
tests/demo/.clang-tidy (1)

3-3: Demo config: enabling WarningsAsErrors is appropriate for exercising the parser

This will force clang-tidy to emit [<check>,-warnings-as-errors], which is exactly what the updated parser targets. Looks good.

.gitattributes (1)

14-16: Normalize additional text files to LF — good hardening

Lock files and Git metadata benefit from consistent EOLs across platforms. Change is safe and reduces flaky diffs.

cpp_linter/clang_tools/clang_tidy.py (1)

13-15: Adopt the non-greedy named-group regex Verified against sample lines—including Windows paths and -warnings-as-errors suffix—ensuring correct captures.

---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,performance-*,bugprone-*,clang-analyzer-*,mpi-*,misc-*,readability-*'
WarningsAsErrors: ''
WarningsAsErrors: '*'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, this would cause a test failure (tests/capture_tools_output/test_database_path.py::test_ninja_database).
Now all is well with the change in RegEx pattern.

@codecov
Copy link

codecov bot commented Sep 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.26%. Comparing base (684fb08) to head (e7b4abf).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #162   +/-   ##
=======================================
  Coverage   98.26%   98.26%           
=======================================
  Files          23       23           
  Lines        1899     1899           
=======================================
  Hits         1866     1866           
  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 2bndy5 merged commit 4d51599 into main Sep 28, 2025
43 checks passed
@2bndy5 2bndy5 deleted the parse-WarningsAsErrors branch September 28, 2025 13:36
2bndy5 added a commit to cpp-linter/cpp-linter-rs that referenced this pull request Oct 2, 2025
2bndy5 added a commit to cpp-linter/cpp-linter-rs that referenced this pull request Oct 2, 2025
2bndy5 added a commit to cpp-linter/cpp-linter-rs that referenced this pull request Oct 2, 2025
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.

2 participants