Skip to content

Drop redundant .to_s inside string interpolation#300

Merged
yahonda merged 1 commit into
rsim:masterfrom
yahonda:tidy-redundant-to-s-in-interpolation
May 13, 2026
Merged

Drop redundant .to_s inside string interpolation#300
yahonda merged 1 commit into
rsim:masterfrom
yahonda:tidy-redundant-to-s-in-interpolation

Conversation

@yahonda
Copy link
Copy Markdown
Collaborator

@yahonda yahonda commented May 13, 2026

Summary

In CallableStatement#bind_param_index the leading-colon normalization wrote:

key = ":#{key.to_s}" unless key.to_s =~ /^:/

Ruby's string interpolation already calls to_s on the embedded expression, so the explicit .to_s inside "#{...}" is redundant.

key = ":#{key}" unless key.to_s =~ /^:/

The key.to_s =~ /^:/ on the right-hand side is intentionally kept — it is outside the interpolation and exists to ensure the regex match receives a String regardless of whether key arrives as a Symbol or String. Out of scope here.

Diff stat: lib/plsql/jdbc_connection.rb | 2 +- (1 line modified).

Test plan

  • bundle exec rspec — 468 examples, 0 failures, 1 pre-existing pending
  • CI matrix exercises the JDBC (JRuby) path where this code lives

🤖 Generated with Claude Code

In `CallableStatement#bind_param_index` the leading-colon normalization
wrote `":#{key.to_s}"`. String interpolation already invokes `to_s`
on the embedded expression, so the explicit call is redundant.

The `key.to_s =~ /^:/` on the right-hand side is intentionally kept;
that one is outside the interpolation and ensures the regex match
receives a String regardless of whether `key` is a Symbol or String.

No behavior change. Full suite is green (468 examples, 0 failures,
1 pre-existing pending).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@yahonda yahonda merged commit df3f9f7 into rsim:master May 13, 2026
20 checks passed
@yahonda yahonda deleted the tidy-redundant-to-s-in-interpolation branch May 13, 2026 02:20
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