Skip to content

Conversation

@shenxianpeng
Copy link
Collaborator

@shenxianpeng shenxianpeng commented Oct 28, 2025

Summary by CodeRabbit

  • New Features

    • Added a command-line tool to manage clang tool installations and verify versions.
  • Documentation

    • Added a new "Clang Tool Wheel CLI" section in Quick Start with installation, version-resolution behavior, and usage examples; included in the README output area.
  • Tests

    • Added tests covering success, failure, and default-tool scenarios for the new CLI.
@shenxianpeng shenxianpeng added the enhancement New feature or request label Oct 28, 2025
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 28, 2025
@shenxianpeng shenxianpeng marked this pull request as ready for review October 28, 2025 21:33
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.00%. Comparing base (7332611) to head (7feda5b).

Additional details and impacted files
@@ Coverage Diff @@ ## main #136 +/- ## ========================================== + Coverage 94.44% 95.00% +0.55%  ========================================== Files 4 4 Lines 108 120 +12 ========================================== + Hits 102 114 +12  Misses 6 6 

☔ 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 force-pushed the feature/support-install-clang-wheel branch from 4f23a60 to 33aeacc Compare October 28, 2025 21:34
@coderabbitai
Copy link

coderabbitai bot commented Oct 28, 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 0 minutes and 22 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 997feb4 and 7feda5b.

📒 Files selected for processing (1)
  • cpp_linter_hooks/util.py (2 hunks)

Walkthrough

Adds a CLI entrypoint clang-tools-wheel implemented in cpp_linter_hooks.util:main, documents it in README.md, registers the script in pyproject.toml, and adds tests and pytest marker config. The CLI parses --tool/--version, resolves installation via _resolve_install, and returns exit codes.

Changes

Cohort / File(s) Summary
Documentation
README.md
Added "Clang Tool Wheel CLI" section and Table of Contents entry describing the CLI, installation, version resolution behavior, and example usage for clang-format/clang-tidy.
CLI Implementation
cpp_linter_hooks/util.py
Added from argparse import ArgumentParser, a new main() function that parses --tool and --version, calls _resolve_install(...), prints success/failure, and returns exit code; added if __name__ == "__main__" guard.
Project Configuration
pyproject.toml
Added [project.scripts] entry clang-tools-wheel = "cpp_linter_hooks.util:main" and added [tool.pytest.ini_options] with markers = ["benchmark: mark test as a benchmark test"].
Tests
tests/test_util.py
Added three benchmarked tests for util.main(): test_main_success, test_main_failure, and test_main_default_tool, using monkeypatch to mock _resolve_install and sys.argv.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to argument parsing edge cases and default behavior when --tool is omitted.
  • Verify _resolve_install() call signature and that printed messages and exit codes match expectations.
  • Check test mocking covers both success/failure paths and doesn't rely on global state.
  • Confirm pyproject.toml script entry points to the correct module:function path.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "feat: support CLI tool to install clang tool wheels" accurately and clearly describes the main changes in the changeset. The modifications introduce a new CLI entry point (clang-tools-wheel) in pyproject.toml, implement a main() function in cpp_linter_hooks/util.py that parses tool and version arguments and resolves installation paths, add documentation to README.md, and include comprehensive tests. The title is specific and concise enough that a developer scanning the history would immediately understand the primary change without needing further context.

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

🧹 Nitpick comments (2)
README.md (1)

76-104: Consider mentioning supported tools explicitly.

The documentation clearly demonstrates usage for both clang-format and clang-tidy, but it might be helpful to explicitly state which tools are supported (e.g., "Supports: clang-format and clang-tidy") to set clear expectations for users.

cpp_linter_hooks/util.py (1)

98-103: Improve error message formatting.

When --version is not specified (None), the error message displays "Failed to install clang-format version None", which is awkward. Consider formatting the message to handle the None case more gracefully.

Apply this diff:

 if path: print(f"{args.tool} installed at: {path}") return 0 else: - print(f"Failed to install {args.tool} version {args.version}") + version_str = f" version {args.version}" if args.version else "" + print(f"Failed to install {args.tool}{version_str}") return 1
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7332611 and 33aeacc.

📒 Files selected for processing (3)
  • README.md (2 hunks)
  • cpp_linter_hooks/util.py (2 hunks)
  • pyproject.toml (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
cpp_linter_hooks/util.py (2)
cpp_linter_hooks/clang_tidy.py (1)
  • main (32-36)
cpp_linter_hooks/clang_format.py (1)
  • main (64-72)
⏰ 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). (3)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.14)
  • GitHub Check: Run benchmarks
🔇 Additional comments (3)
pyproject.toml (1)

43-43: LGTM!

The new script entry point is correctly registered and follows the same pattern as the existing hook entries.

cpp_linter_hooks/util.py (2)

4-4: LGTM!

The import is necessary for the new CLI functionality and follows proper import organization.


106-107: LGTM!

The module guard correctly implements the standard pattern for CLI entry points and properly propagates the exit code.

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 28, 2025

CodSpeed Performance Report

Merging #136 will not alter performance

Comparing feature/support-install-clang-wheel (7feda5b) with main (c1d5f09)1

Summary

✅ 60 untouched
🆕 3 new
⏩ 13 skipped2

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 test_main_default_tool N/A 638.4 µs N/A
🆕 test_main_failure N/A 680.4 µs N/A
🆕 test_main_success N/A 679 µs N/A

Footnotes

  1. No successful run was found on main (7332611) during the generation of this report, so c1d5f09 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 13 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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

284-320: Consider using Mock objects for better test verification.

The lambda mocks have unused tool and version parameters, and the tests don't verify that _resolve_install is called with the expected arguments. Using unittest.mock.Mock with assert_called_once_with would be more idiomatic and provide stronger test coverage.

Apply this diff to improve the tests:

 @pytest.mark.benchmark def test_main_success(monkeypatch): - # Patch _resolve_install to simulate success - monkeypatch.setattr( - "cpp_linter_hooks.util._resolve_install", - lambda tool, version: "/usr/bin/clang-format", - ) + from unittest.mock import Mock + mock_resolve = Mock(return_value="/usr/bin/clang-format") + monkeypatch.setattr("cpp_linter_hooks.util._resolve_install", mock_resolve) monkeypatch.setattr( sys, "argv", ["util.py", "--tool", "clang-format", "--version", "15.0.7"] ) exit_code = util.main() assert exit_code == 0 + mock_resolve.assert_called_once_with("clang-format", "15.0.7") @pytest.mark.benchmark def test_main_failure(monkeypatch): - # Patch _resolve_install to simulate failure - monkeypatch.setattr( - "cpp_linter_hooks.util._resolve_install", lambda tool, version: None - ) + from unittest.mock import Mock + mock_resolve = Mock(return_value=None) + monkeypatch.setattr("cpp_linter_hooks.util._resolve_install", mock_resolve) monkeypatch.setattr( sys, "argv", ["util.py", "--tool", "clang-format", "--version", "99.99.99"] ) exit_code = util.main() assert exit_code == 1 + mock_resolve.assert_called_once_with("clang-format", "99.99.99") @pytest.mark.benchmark def test_main_default_tool(monkeypatch): - # Patch _resolve_install to simulate success for default tool - monkeypatch.setattr( - "cpp_linter_hooks.util._resolve_install", - lambda tool, version: "/usr/bin/clang-format", - ) + from unittest.mock import Mock + mock_resolve = Mock(return_value="/usr/bin/clang-format") + monkeypatch.setattr("cpp_linter_hooks.util._resolve_install", mock_resolve) monkeypatch.setattr(sys, "argv", ["util.py"]) exit_code = util.main() assert exit_code == 0 + mock_resolve.assert_called_once_with("clang-format", None)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 33aeacc and 997feb4.

📒 Files selected for processing (2)
  • pyproject.toml (2 hunks)
  • tests/test_util.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pyproject.toml
🧰 Additional context used
🧬 Code graph analysis (1)
tests/test_util.py (1)
cpp_linter_hooks/util.py (1)
  • main (92-103)
🪛 Ruff (0.14.2)
tests/test_util.py

289-289: Unused lambda argument: tool

(ARG005)


289-289: Unused lambda argument: version

(ARG005)


302-302: Unused lambda argument: tool

(ARG005)


302-302: Unused lambda argument: version

(ARG005)


316-316: Unused lambda argument: tool

(ARG005)


316-316: Unused lambda argument: version

(ARG005)

⏰ 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). (5)
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.14)
  • GitHub Check: test (3.12)
  • GitHub Check: Run benchmarks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

2 participants