Skip to content

fix(encoder): replace values_at with string slicing to avoid latent nil#73

Open
matteoredz wants to merge 1 commit into
mainfrom
fix/name-consonants-values-at
Open

fix(encoder): replace values_at with string slicing to avoid latent nil#73
matteoredz wants to merge 1 commit into
mainfrom
fix/name-consonants-values-at

Conversation

@matteoredz

Copy link
Copy Markdown
Owner

Summary

  • encode_name used consonants.chars.values_at(0, 2..consonants.size).join to skip the 2nd consonant when a name has more than 3 consonants.
  • 2..consonants.size exceeds valid indices by 1; Array#values_at returns nil for the out-of-bounds index, which join silently discards — producing correct output by accident.
  • Replaced with (consonants[0] + consonants[2..-1]).to_s, which is explicit, nil-free, and Ruby 2.5-safe.
  • Added a regression test with a 5-consonant name ("Valentino") to document the expected behaviour.

Test plan

  • bundle exec rake green with 100% line + branch coverage
  • bundle exec rubocop clean on changed files
  • Independent of the other branches — can merge in any order

🤖 Generated with Claude Code

values_at(0, 2..consonants.size) silently returns nil for the
out-of-bounds index and join discards it, producing the correct result
by accident. Replace with the explicit string-slice idiom, which is
Ruby 2.5-safe and expresses the intent clearly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@matteoredz, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 50 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8bd3811d-b38f-4f42-b253-f117cf7bd12a

📥 Commits

Reviewing files that changed from the base of the PR and between b5aceb7 and 5d3b691.

📒 Files selected for processing (2)
  • lib/itax_code/encoder.rb
  • test/itax_code/encoder_test.rb
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/name-consonants-values-at

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.

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.

1 participant