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

Rubocop autocorrecting "#$1" produces incorrect code #1465

Closed
ghost opened this issue Nov 25, 2014 · 1 comment
Closed

Rubocop autocorrecting "#$1" produces incorrect code #1465

ghost opened this issue Nov 25, 2014 · 1 comment

Comments

@ghost
Copy link

ghost commented Nov 25, 2014

Big fan of Rubocop, we discovered a bug in it's autocorrect feature with certain code:

$ rubocop -V
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.5-compliant syntax, but you are running 2.1.4.
0.27.1 (using Parser 2.2.0.pre.8, running on ruby 2.1.4 x86_64-darwin14.0)
$ rubocop -a interpolation.rb
# interpolation.rb
# Before code:
'foo' =~ /fo(o)/
puts "Match: #$1"

# After code:
'foo' =~ /fo(o)/
puts 'Match: #Regexp.last_match[1]'

It should have been produced:

'foo' =~ /fo(o)/
puts "Match: #{Regexp.last_match[1]}"
@ghost
Copy link
Author

ghost commented Nov 26, 2014

Great, thank you!

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

No branches or pull requests

0 participants