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

Autocorrect doesn't insert spaces when converting } to end #2183

Closed
geowy opened this issue Aug 25, 2015 · 0 comments
Closed

Autocorrect doesn't insert spaces when converting } to end #2183

geowy opened this issue Aug 25, 2015 · 0 comments

Comments

@geowy
Copy link

geowy commented Aug 25, 2015

I encountered this problem when trying to autocorrect curly braces to do...ends. If the closing braces are right next to each other rubocop will just replace each } with end without inserting any spaces, e.g. }} will become endend.

This is probably easier to demonstrate:

$ rubocop -V
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.7-compliant syntax, but you are running 2.1.3.
0.33.0 (using Parser 2.3.0.pre.2, running on ruby 2.1.3 x86_64-darwin13.0)
$
$
$
$ cat test.rb
(0..3).each { |a| a.times {
  puts a
}}
$
$
$
$ rubocop -a test.rb
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.7-compliant syntax, but you are running 2.1.3.
Inspecting 1 file
E

Offenses:

test.rb:1:13: C: [Corrected] Avoid using {...} for multi-line blocks.
(0..3).each { |a| a.times {
            ^
test.rb:1:19: C: [Corrected] Block body expression is on the same line as the block start.
(0..3).each { |a| a.times {
                  ^^^^^^^^^
test.rb:1:27: C: [Corrected] Avoid using {...} for multi-line blocks.
(0..3).each { |a| a.times {
                          ^
test.rb:4:1: E: unexpected token $end

1 file inspected, 4 offenses detected, 3 offenses corrected
$
$
$
$ cat test.rb
(0..3).each do |a| a.times do
  puts a
endend
bbatsov added a commit that referenced this issue Aug 25, 2015
[Fix #2183] Fix auto-correcting adjacent braces
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

1 participant