Skip to content
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

Incorrect auto-correct Lint/LiteralInInterpolation if contains numbers #5862

Closed
david942j opened this issue May 8, 2018 · 1 comment · Fixed by #5863
Closed

Incorrect auto-correct Lint/LiteralInInterpolation if contains numbers #5862

david942j opened this issue May 8, 2018 · 1 comment · Fixed by #5863

Comments

@david942j
Copy link

Hi rubocop teams,
I found rubocop incorrectly fixes the LiteralInInterpolation.

This bug causes the Ruby program behave different between before/after being fixed by rubocop's auto-correct.


Expected behavior

$ cat a.rb
# puts "Hey, #{0x20}"
$ rubocop a.rb -a
<output omitted>
$ cat a.rb
# puts 'Hey, 32'

Actual behavior

$ cat a.rb
# puts "Hey, #{0x20}"
$ rubocop a.rb -a
<output omitted>
$ cat a.rb
# puts 'Hey, 0x20'   <----- incorrect!

Invoke rubocop without auto-correct, it shows:

Inspecting 1 file
W

Offenses:

a.rb:1:14: W: Lint/LiteralInInterpolation: Literal interpolation detected.
puts "Hey, #{0x20}"
             ^^^^

1 file inspected, 1 offense detected

Steps to reproduce the problem

Prepare a.rb:

puts "Hey, #{0x20}"

then

$ rubocop -a a.rb

RuboCop version

Include the output of rubocop -V. Here's an example:

$ rubocop -V
0.55.0 (using Parser 2.5.1.0, running on ruby 2.4.3 x86_64-linux)
koic added a commit to koic/rubocop that referenced this issue May 8, 2018
…tion`

Fixes rubocop#5862.

This PR fixes an incorrect auto-correct for `Lint/LiteralInInterpolation` if
contains numbers.
@koic
Copy link
Member

koic commented May 8, 2018

Thanks for the feedback. I confirmed this reproduction. I opened a PR #5863.

bbatsov pushed a commit that referenced this issue May 8, 2018
Fixes #5862.

This PR fixes an incorrect auto-correct for `Lint/LiteralInInterpolation` if
contains numbers.
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 a pull request may close this issue.

2 participants