Skip to content

clang-format hook support --verbose output #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 4, 2025
Merged

Conversation

shenxianpeng
Copy link
Collaborator

@shenxianpeng shenxianpeng commented Jul 3, 2025

closes #77

Summary by CodeRabbit

  • New Features

    • Added support for a verbose output option when running the clang-format pre-commit hook.
    • Introduced a sample pre-commit configuration file demonstrating the use of verbose mode.
    • Enhanced the test script to run multiple pre-commit configurations sequentially and report results.
  • Documentation

    • Added a "Troubleshooting" section to the README with guidance on debugging clang-format hook issues, including how to enable verbose output.
  • Tests

    • Added new tests to verify clang-format hook behavior with verbose output enabled.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jul 3, 2025
Copy link

coderabbitai bot commented Jul 3, 2025

Warning

Rate limit exceeded

@shenxianpeng has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 55 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between fcbf65a and e0b7980.

📒 Files selected for processing (3)
  • README.md (7 hunks)
  • cpp_linter_hooks/clang_format.py (2 hunks)
  • pyproject.toml (1 hunks)
## Walkthrough

A verbose mode was added to the clang-format pre-commit hook by introducing a `--verbose` flag to the hook's argument parser. Documentation and testing updates were made to guide users on enabling and verifying verbose output, including a new troubleshooting section in the README and corresponding test cases.

## Changes

| File(s)                                            | Change Summary                                                                                       |
|---------------------------------------------------|---------------------------------------------------------------------------------------------------|
| README.md                                         | Added troubleshooting section with instructions for enabling verbose output in clang-format hook.|
| cpp_linter_hooks/clang_format.py                   | Added `-v`/`--verbose` flag to argument parser for verbose output support; updated command execution and output handling. |
| testing/pre-commit-config-verbose.yaml             | New pre-commit config testing clang-format with `--verbose` enabled using both `--verbose` and `-v`.|
| testing/run.sh                                    | Updated to include new verbose test config in pre-commit test sequence with explicit runs and result aggregation. |
| tests/test_clang_format.py                        | Added two tests for `run_clang_format` with the `--verbose` flag, covering success and error cases.|

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant PreCommit
    participant ClangFormatHook
    participant ClangFormat

    User->>PreCommit: Run pre-commit with --all-files
    PreCommit->>ClangFormatHook: Execute clang-format hook (with --verbose)
    ClangFormatHook->>ClangFormat: Run clang-format with --verbose
    ClangFormat-->>ClangFormatHook: Output processed files (verbose)
    ClangFormatHook-->>PreCommit: Return result, including verbose output
    PreCommit-->>User: Show hook results and verbose details

Assessment against linked issues

Objective Addressed Explanation
Add support to print details of files processed/causing failure via clang-format verbose output (#77)
Document how to enable and use verbose output for troubleshooting (#77)
Add tests to verify verbose mode and error handling in clang-format hook (#77)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found.


<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIGL0wiMAAzfApmakhYfHwAa3tsbm5U0IADCCkKAXxEEhL+PG48aMgAdzRkBwFmdRp6OTDYD2wavkRBjAAPeExuMiJ0ZFtIDEcBSkgAdgBOFCxcQb8SIsR1VPkGQrAveAwaCgB6C+4rm7uwLNzEDRgDpUQGCjwbjifBYG60eAMajSAYZfaoJZxaowpAODwrZhrPgbDbfABy+HQtAhIIwaF8Slw2i8yFSkBIE248TJpOQLUoHl4+Ak8CU9Bu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Kx2Saw6xExGw1Bmw0w2x3LPRqF1AjkASZySB5RFQR5PZHJWx2wPLaAABWTHOJXKxQjYNANAJIIq2QpQjYRQxQnBXKrYRQpIDYJIAAFg2EKriS2AAGYGABAurMckhMcuqsrYqIARIBBZDcq4kuqZrMc1gWq+qWqWq4lmrcqNgBAAAORQlqkgDajYLqrYLHBgWgBqzHY6yWdMOKoasVWQvKxQ3K2Q3qpIBqgQRq3KrqgQDYTHFqtALYLYXa16rYJIAQWgHqlmS6saqfWQrqvKhgIarYeqlqhgd6qax6wagQNa/qrqsqkgFaxGhgOJQakajy/azHDapID6tAB656hgf6javqgqrYTHdqmquJQmrYAmzHYkOatAb64muKpIJ6zHXK362Qjalq+q3K2gAqrqlq2gcqpa4kLq+62gRQ/5RVFqja2mnYNyjymLRKxAZK1KugJcqSfQIAA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=cpp-linter/cpp-linter-hooks&utm_content=79):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0339700 and d561507.

📒 Files selected for processing (5)
  • README.md (1 hunks)
  • cpp_linter_hooks/clang_format.py (1 hunks)
  • testing/pre-commit-config-verbose.yaml (1 hunks)
  • testing/run.sh (1 hunks)
  • tests/test_clang_format.py (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Test
tests/test_clang_format.py

[error] 98-98: Test failure: 'test_run_clang_format_verbose_error' failed due to assertion error. Expected error message 'Invalid value for -style' not found in output despite clang-format reporting 'Invalid value for -style'.

🔇 Additional comments (4)
testing/run.sh (1)

4-4: Good addition to test coverage.

The script correctly includes the new verbose configuration file in the test loop, ensuring the verbose functionality is tested alongside existing configurations.

testing/pre-commit-config-verbose.yaml (1)

1-6: Well-structured configuration file.

The pre-commit configuration correctly includes the --verbose flag and follows the standard format. This will be useful for testing verbose output functionality once it's properly implemented.

README.md (1)

154-167: Excellent documentation addition.

The troubleshooting section provides clear guidance on enabling verbose output for debugging clang-format issues. The example configuration is helpful and matches the intended usage pattern.

tests/test_clang_format.py (1)

69-83: Test may pass for the wrong reasons.

This test verifies that the verbose flag doesn't break the formatting functionality, but it doesn't actually verify that verbose output is produced since the verbose flag isn't implemented in the main code.

Once the verbose functionality is properly implemented in clang_format.py, this test should be enhanced to verify that verbose output is actually generated.

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)
cpp_linter_hooks/clang_format.py (1)

39-44: Consider simplifying the dry-run handling logic.

The dry-run handling works correctly but could be simplified using a ternary operator as suggested by static analysis.

Apply this diff to simplify the logic:

-        # Handle special case for dry-run mode
-        if "--dry-run" in command:
-            retval = -1  # Special code to identify dry-run mode
-        else:
-            retval = sp.returncode
+        # Handle special case for dry-run mode
+        retval = -1 if "--dry-run" in command else sp.returncode
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb25133 and 63bef2d.

📒 Files selected for processing (1)
  • cpp_linter_hooks/clang_format.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
cpp_linter_hooks/clang_format.py (3)
cpp_linter_hooks/util.py (1)
  • ensure_installed (38-51)
cpp_linter_hooks/clang_tidy.py (1)
  • main (32-36)
testing/good.c (1)
  • main (2-6)
🪛 Ruff (0.11.9)
cpp_linter_hooks/clang_format.py

40-43: Use ternary operator retval = -1 if "--dry-run" in command else sp.returncode instead of if-else-block

(SIM108)

🔇 Additional comments (8)
cpp_linter_hooks/clang_format.py (8)

2-2: LGTM: Import needed for verbose output.

The sys import is correctly added to support printing verbose information to stderr.


11-13: LGTM: Verbose flag properly implemented.

The verbose argument is correctly added with both short (-v) and long (--verbose) forms, addressing the previous review comment about the flag being defined but never used.


20-24: LGTM: Verbose flag correctly passed to clang-format.

The implementation properly checks the parsed verbose flag and appends --verbose to the clang-format command when requested.


28-37: LGTM: Output capture enhanced for verbose mode.

The subprocess call correctly captures both stdout and stderr, combining them for comprehensive output handling. This enables proper verbose output display and error reporting.


45-48: LGTM: Verbose output properly implemented.

The verbose information is correctly printed when the verbose flag is enabled, providing useful debugging information to users.


51-53: LGTM: Exception handling improved.

The explicit FileNotFoundError handling provides clearer error reporting and is more specific than generic exception handling.


55-61: LGTM: Well-designed verbose output function.

The helper function appropriately prints debugging information to stderr and handles empty output gracefully. The function design is clean and focused.


66-71: LGTM: Main function properly handles dry-run mode.

The main function correctly handles the dry-run special case by excluding the sentinel return code from error output and converting it to a success return code.

Copy link

codecov bot commented Jul 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.12%. Comparing base (0339700) to head (e0b7980).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #79      +/-   ##
==========================================
+ Coverage   89.61%   95.12%   +5.51%     
==========================================
  Files           3        3              
  Lines          77       82       +5     
==========================================
+ Hits           69       78       +9     
+ Misses          8        4       -4     

☔ 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.

@shenxianpeng shenxianpeng changed the title support verbose output clang-format hook support --verbose output Jul 3, 2025
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 (3)
README.md (3)

133-135: Prefer “for” instead of “of” in the note sentence

The phrase reads a bit awkwardly. Re-wording improves clarity and matches common pre-commit phrasing.

-> [!NOTE]
-> Use `--dry-run` in `args` of `clang-format` to print instead of changing the format, e.g.:
+> [!NOTE]
+> Use `--dry-run` in the `args` for `clang-format` to print the diff rather than change the files, e.g.:

63-66: Keep args list style consistent across snippets

Other snippets present each flag as a separate list element (no commas inside the string). Using the same style here avoids confusion about whether the comma is part of the argument.

-        args: [--style=file, --version=18] # Specifies version
+        args: [--style=file, --version=18]  # two separate list items – comma separates YAML list, not the argument string

95-106: Call out that -v/--verbose is mutually exclusive with --quiet

If the hook already exposes a --quiet flag, it’s worth noting here that the two are mutually exclusive to avoid user confusion.

Consider appending a brief sentence such as:

_Note: `--verbose` cannot be combined with `--quiet`; the last flag wins._
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7368f3b and fcbf65a.

📒 Files selected for processing (2)
  • README.md (8 hunks)
  • testing/run.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • testing/run.sh
🧰 Additional context used
🪛 LanguageTool
README.md

[uncategorized] ~134-~134: “of” seems less likely than “or” (‘either … or’).
Context: ...> [!NOTE] > Use--dry-runinargsofclang-format` to print instead of chan...

(AI_HYDRA_LEO_CP_OF_OR)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test (3.14)
  • GitHub Check: test (3.12)

@shenxianpeng shenxianpeng added the enhancement New feature or request label Jul 4, 2025
Copy link

sonarqubecloud bot commented Jul 4, 2025

@shenxianpeng shenxianpeng removed the documentation Improvements or additions to documentation label Jul 4, 2025
@shenxianpeng shenxianpeng merged commit 70e1f52 into main Jul 4, 2025
15 checks passed
@shenxianpeng shenxianpeng deleted the support-verbose branch July 4, 2025 00:31
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.

Print details which file caused pre-commit run -a failed
1 participant