Skip to content

update_ruby_recipe: use spaceship operator for sorting versions#53

Merged
jdx merged 1 commit into
jdx:mainfrom
ashkulz:fix_update_ruby_recipe
Jul 6, 2026
Merged

update_ruby_recipe: use spaceship operator for sorting versions#53
jdx merged 1 commit into
jdx:mainfrom
ashkulz:fix_update_ruby_recipe

Conversation

@ashkulz

@ashkulz ashkulz commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Array does not include Comparable, so > on the nested arrays returned by #version_sort_key raised NoMethodError. This was introduced via 335de38 on #48.

This causing the autobump workflow to fail with the 3.4.10 release.

Summary by CodeRabbit

  • Bug Fixes
    • Improved how Ruby version entries are placed in the update list, helping keep entries in the correct order when new versions are added or updated.

Array does not include Comparable, so '>' on the nested arrays
returned by #version_sort_key raised NoMethodError. This was
introduced via 335de38 on #48.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change modifies a single comparison expression in the updated_recipe_text method within libexec/update_ruby_recipe.rb, replacing a direct greater-than comparison of version_sort_key results with an equivalent three-way comparison using <=> checked against zero.

Changes

Insertion Ordering Fix

Layer / File(s) Summary
Insertion position comparison
libexec/update_ruby_recipe.rb
Replaced direct > comparison of version_sort_key values with a <=> three-way comparison checked against 0 to determine insert_at.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Poem

A tiny hop, a spaceship's flight,
Comparing versions left and right,
One line changed, so neat, so small,
Yet keeps the recipes in order, all! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: switching update_ruby_recipe version sorting to the spaceship operator.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown

Greptile Summary

Fixes a NoMethodError crash in the autobump workflow caused by using > to compare nested arrays from version_sort_key, which doesn't work because Ruby's Array does not include Comparable. The fix replaces > with the spaceship operator <=> and checks the result against 0, which is valid since Array does define #<=>.

  • Replaces version_sort_key(...) > version_sort_key(...) with (version_sort_key(...) <=> version_sort_key(...)) > 0 on line 68 of libexec/update_ruby_recipe.rb.
  • The change is minimal and correctly restores insertion-order sorting for new Ruby versions in recipes/rubies.yml.

Confidence Score: 5/5

Safe to merge — the one-line change correctly resolves the crash and the rest of the script is unchanged.

The fix is a minimal, targeted correction for a well-understood NoMethodError. The spaceship operator is defined on Array and produces the right ordering semantics for the nested arrays returned by version_sort_key. No other code paths are affected.

No files require special attention.

Important Files Changed

Filename Overview
libexec/update_ruby_recipe.rb Replaces > with (<=> ...) > 0 for comparing nested arrays returned by version_sort_key, fixing a NoMethodError since Array does not include Comparable.

Reviews (1): Last reviewed commit: "update_ruby_recipe: use spaceship operat..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
libexec/update_ruby_recipe.rb (1)

68-68: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Apply RuboCop-suggested style fix.

RuboCop flags Style/NumericPredicate (prefer .positive? over > 0) and Layout/LineLength (133/118) for this line.

♻️ Proposed fix
-      insert_at = blocks.find { |block| (version_sort_key(block.fetch(:version)) <=> version_sort_key(`@version`)) > 0 }&.fetch(:start)
+      insert_at = blocks.find do |block|
+        (version_sort_key(block.fetch(:version)) <=> version_sort_key(`@version`)).positive?
+      end&.fetch(:start)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libexec/update_ruby_recipe.rb` at line 68, Update the block selection in
update_ruby_recipe.rb to satisfy RuboCop by replacing the numeric comparison in
the insert_at assignment with a predicate-based check, using the existing
version_sort_key, blocks, and `@version` logic in the same expression. Keep the
line within the style length limit by breaking the chained call across lines or
refactoring the expression for readability without changing behavior.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@libexec/update_ruby_recipe.rb`:
- Line 68: Update the block selection in update_ruby_recipe.rb to satisfy
RuboCop by replacing the numeric comparison in the insert_at assignment with a
predicate-based check, using the existing version_sort_key, blocks, and `@version`
logic in the same expression. Keep the line within the style length limit by
breaking the chained call across lines or refactoring the expression for
readability without changing behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 2bd10ed1-e393-436e-8a4b-a753905aacba

📥 Commits

Reviewing files that changed from the base of the PR and between a2d36d9 and 7cc75ca.

📒 Files selected for processing (1)
  • libexec/update_ruby_recipe.rb

@ashkulz

ashkulz commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@jdx can you merge this PR? That'll allow us to use the 3.4.10 precompiled ruby 🙂

@jdx jdx merged commit 4fce6ce into jdx:main Jul 6, 2026
10 checks passed
@ashkulz ashkulz deleted the fix_update_ruby_recipe branch July 7, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants