fix: parse clang-tidy output when WarningsAsErrors is asserted#162
Conversation
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] ```
There was a problem hiding this comment.
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 ignoreIf 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
📒 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 parserThis 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 hardeningLock 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-errorssuffix—ensuring correct captures.
| --- | ||
| Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,performance-*,bugprone-*,clang-analyzer-*,mpi-*,misc-*,readability-*' | ||
| WarningsAsErrors: '' | ||
| WarningsAsErrors: '*' |
There was a problem hiding this comment.
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.

ref cpp-linter/cpp-linter-action#347
Basically, we just needed to account for the
,-warnings-as-errorsappended to the rule name in square brackets.Without
WarningsAsErrorsWith
WarningsAsErrorsSummary by CodeRabbit