Skip to content

fixup #89 to get latest version #90

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 3 commits into from
Jul 6, 2025
Merged

fixup #89 to get latest version #90

merged 3 commits into from
Jul 6, 2025

Conversation

shenxianpeng
Copy link
Collaborator

@shenxianpeng shenxianpeng commented Jul 6, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved version resolution to always select the latest matching version when multiple options are available.
  • Tests

    • Updated test cases to expect the latest patch version for version resolution scenarios.
  • Chores

    • Adjusted test script success criteria to require exactly 9 failed cases instead of 10.

@shenxianpeng shenxianpeng added the bug Something isn't working label Jul 6, 2025
Copy link

coderabbitai bot commented Jul 6, 2025

Walkthrough

The _resolve_version function in cpp_linter_hooks/util.py was modified to return the latest matching version rather than the first. The associated tests in tests/test_util.py were updated to expect the latest versions. The test runner script testing/run.sh changed its success criterion from 10 to 9 failed cases.

Changes

File(s) Change Summary
cpp_linter_hooks/util.py Modified _resolve_version to select the latest matching version numerically and updated docstring.
tests/test_util.py Updated tests to expect latest matching versions instead of the first for _resolve_version.
testing/run.sh Changed test success criterion from 10 to 9 failed cases.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UtilModule as util.py
    User->>UtilModule: Call _resolve_version(versions, user_input)
    UtilModule->>UtilModule: Filter versions starting with user_input
    alt No matches
        UtilModule-->>User: Raise ValueError
    else Matches found
        UtilModule->>UtilModule: Parse versions to integer tuples
        UtilModule->>UtilModule: Select max (latest) version
        UtilModule-->>User: Return latest matching version
    end
Loading

Warning

Review ran into problems

🔥 Problems

GitHub checks timed out after 90 seconds. Some checks were still in progress when the timeout was reached. Consider increasing the GitHub Checks - Timeout Ms value in your CodeRabbit configuration to allow more time for checks to complete.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ddd7de8 and 7b470c4.

📒 Files selected for processing (3)
  • cpp_linter_hooks/util.py (1 hunks)
  • testing/run.sh (1 hunks)
  • tests/test_util.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Run benchmarks
🔇 Additional comments (6)
testing/run.sh (1)

32-32: LGTM — Manual Verification Required for Failure Count Adjustment

The test runner couldn’t execute in this environment due to missing dependencies (pre-commit, tee) and absent result files. Please ensure all test prerequisites are installed and the repository is in the correct state, then re-run:

cd testing
./run.sh

and confirm that the number of failed cases is exactly 9.

• Verify that pre-commit, tee, and Git access are available
• Ensure testing/main.c and result.txt are present or generated
• Confirm the exit code is 0 when only 9 failures occur

cpp_linter_hooks/util.py (3)

116-116: LGTM! Docstring accurately reflects the new behavior.

The updated docstring correctly describes that the function now resolves the "latest matching version" instead of just any matching version.


135-137: Excellent improvement in exception handling.

The exception handling has been properly refined to catch ValueError specifically instead of all exceptions, which was flagged in previous reviews. This allows other unexpected errors to propagate appropriately.


128-133: Robust version parsing implementation.

The version parsing logic using tuple(map(int, v.split("."))) is a clean and effective approach for semantic version comparison. The max() function with this custom key will correctly identify the latest version numerically.

tests/test_util.py (2)

164-169: LGTM! Test expectations correctly updated for latest version behavior.

The test cases now properly expect the latest matching versions:

  • "20" → "20.1.7" (latest 20.x)
  • "20.1" → "20.1.7" (latest 20.1.x)
  • "18" → "18.1.8" (latest 18.x)
  • "18.1" → "18.1.8" (latest 18.1.x)

These expectations align with the modified _resolve_version function behavior.


185-187: LGTM! Clang-tidy test expectations correctly updated.

The updated expectations for clang-tidy version resolution are correct:

  • "20" → "20.1.0" (latest 20.x available)
  • "18" → "18.1.8" (latest 18.x)
  • "19" → "19.1.0.1" (latest 19.x)

These align with the available versions in CLANG_TIDY_VERSIONS.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • 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 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 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jul 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.65%. Comparing base (ddd7de8) to head (7b470c4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #90      +/-   ##
==========================================
+ Coverage   95.48%   95.65%   +0.16%     
==========================================
  Files           3        3              
  Lines         133      138       +5     
==========================================
+ Hits          127      132       +5     
  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 requested a review from Copilot July 6, 2025 18:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates version resolution logic to pick the latest matching version, adjusts related tests to expect the newest patch versions, and updates the CI success threshold in the run script.

  • Switches _resolve_version to parse and select the maximum matching version.
  • Updates tests in test_util.py to assert on latest rather than first matching versions.
  • Adjusts run.sh to consider 9 failures as success instead of 10.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/test_util.py Updated expected version outputs to reflect latest patch versions
testing/run.sh Changed successful failure count from 10 to 9
cpp_linter_hooks/util.py Enhanced _resolve_version to parse versions and return the latest matching release
Comments suppressed due to low confidence (1)

testing/run.sh:28

  • [nitpick] Use modern command substitution $(...) instead of backticks and quote variables (e.g., failed_cases=$(grep -c "Failed" result.txt) and later if [ "$failed_cases" -eq 9 ]) to improve readability and robustness.
failed_cases=`grep -c "Failed" result.txt`

return next(v for v in versions if v.startswith(user_input) or v == user_input)
except StopIteration:
# filter versions that start with the user input
matched_versions = [v for v in versions if v.startswith(user_input)]
Copy link
Preview

Copilot AI Jul 6, 2025

Choose a reason for hiding this comment

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

This prefix match can unintentionally include versions like '20.10.0' when user_input is '20.1'. Consider matching on segment boundaries (e.g., v == user_input or v.startswith(user_input + '.')) to avoid partial overlaps.

Suggested change
matched_versions = [v for v in versions if v.startswith(user_input)]
matched_versions = [v for v in versions if v == user_input or v.startswith(user_input + '.')]

Copilot uses AI. Check for mistakes.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

sonarqubecloud bot commented Jul 6, 2025

Copy link

codspeed-hq bot commented Jul 6, 2025

CodSpeed Performance Report

Merging #90 will improve performances by 10.35%

Comparing patch-3 (7b470c4) with main (ddd7de8)

Summary

⚡ 1 improvements
✅ 61 untouched benchmarks
🆕 6 new benchmarks
⁉️ 6 dropped benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
test_ensure_installed[clang-format-20] 1.3 ms 1.2 ms +10.35%
⁉️ test_resolve_version_clang_format[18-18.1.0] 105 µs N/A N/A
🆕 test_resolve_version_clang_format[18-18.1.8] N/A 142.5 µs N/A
⁉️ test_resolve_version_clang_format[18.1-18.1.0] 105.3 µs N/A N/A
🆕 test_resolve_version_clang_format[18.1-18.1.8] N/A 143.2 µs N/A
⁉️ test_resolve_version_clang_format[20-20.1.0] 108.1 µs N/A N/A
🆕 test_resolve_version_clang_format[20-20.1.7] N/A 132.7 µs N/A
⁉️ test_resolve_version_clang_format[20.1-20.1.0] 108 µs N/A N/A
🆕 test_resolve_version_clang_format[20.1-20.1.7] N/A 132.5 µs N/A
⁉️ test_resolve_version_clang_tidy[18-18.1.1] 93.6 µs N/A N/A
🆕 test_resolve_version_clang_tidy[18-18.1.8] N/A 107.1 µs N/A
🆕 test_resolve_version_clang_tidy[19-19.1.0.1] N/A 107.1 µs N/A
⁉️ test_resolve_version_clang_tidy[19-19.1.0] 93.9 µs N/A N/A

@shenxianpeng shenxianpeng merged commit 73af16b into main Jul 6, 2025
15 of 16 checks passed
@shenxianpeng shenxianpeng deleted the patch-3 branch July 6, 2025 18:04
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.

1 participant