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 fights with it self regarding TrailingComma vs SpaceInsideBrackets [Lock-up] #908

Closed
danlo opened this issue Mar 19, 2014 · 5 comments · Fixed by #918
Closed

Rubocop fights with it self regarding TrailingComma vs SpaceInsideBrackets [Lock-up] #908

danlo opened this issue Mar 19, 2014 · 5 comments · Fixed by #918
Labels

Comments

@danlo
Copy link

danlo commented Mar 19, 2014

Rubocop 0.19.1

.rubocop.yml

TrailingComma:
  EnforcedStyleForMultiline: comma
  SupportedStyles:
    - comma
    - no_comma
# test.rb
profile_options = {
  formats: [:flat, :graph_html, :call_tree]
}

puts profile_options

rubocop -Da test.rb

This will lock up rubocop in an endless fight.

Thank you! I love this!

@danlo danlo changed the title Rubocop fights with it self regarding TrailingComma vs SpaceInsideBrackets Rubocop fights with it self regarding TrailingComma vs SpaceInsideBrackets [Lock-up] Mar 19, 2014
@bbatsov
Copy link
Collaborator

bbatsov commented Mar 19, 2014

What version are you using? We fixed this in 0.19 if memory serves. —
Sent from Mailbox for iPhone

On Wed, Mar 19, 2014 at 8:40 PM, Daniel Lo [email protected]
wrote:

.rubocop.yml

TrailingComma:
  EnforcedStyleForMultiline: comma
  SupportedStyles:
    - comma
    - no_comma
# test.rb
profile_options = {
  formats: [:flat, :graph_html, :call_tree]
}
puts profile_options

rubocop -Da test.rb
This will lock up rubocop and kill it

Thank you! I love this!

Reply to this email directly or view it on GitHub:
#908

@danlo
Copy link
Author

danlo commented Mar 19, 2014

@bbatsov

[deployer@local current]$ rubocop -v
0.19.1

@jonas054
Copy link
Collaborator

@danlo I have not been able to re-create your problem, and I don't understand what could be wrong because TrailingComma doesn't support auto-correct.

@danlo
Copy link
Author

danlo commented Mar 19, 2014

@jonas054 @bbatsov

The issue comes about after you make the TrailingComma fix:

Here is a complete screen display (Note on the 2nd version of test.rb, a comma was added; I also used time to show that the rubocop does not immediately exit and that I must ctrl-c out; as for the -a, that is what I think its SpaceInSideBrackets that auto-corrects (default on)):

[deployer@local rubocop]$ date
Wed Mar 19 21:10:29 UTC 2014
[deployer@local rubocop]$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
[deployer@local rubocop]$ rubocop -v
0.19.1
[deployer@local rubocop]$ cat .rubocop.yml
TrailingComma:
  EnforcedStyleForMultiline: comma
  SupportedStyles:
    - comma
    - no_comma
[deployer@local rubocop]$ cat test.rb
profile_options = {
  formats: [:flat, :graph_html, :call_tree]
}

puts profile_options
[deployer@local rubocop]$ ls -al
total 16
drwxrwxr-x.  2 deployer deployer 4096 Mar 19 21:10 .
drwx------. 11 deployer deployer 4096 Mar 19 21:08 ..
-rw-rw-r--.  1 deployer deployer   96 Mar 19 21:09 .rubocop.yml
-rw-rw-r--.  1 deployer deployer   88 Mar 19 21:10 test.rb
[deployer@local rubocop]$ rubocop -Da test.rb
Inspecting 1 file
C

Offenses:

test.rb:2:3: C: TrailingComma: Put a comma after the last item of a multiline hash.
  formats: [:flat, :graph_html, :call_tree]
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected
[deployer@local rubocop]$ cat > test.rb
# test.rb
profile_options = {
  formats: [:flat, :graph_html, :call_tree,]
}

puts profile_options
[deployer@local rubocop]$ time rubocop -Da test.rb
Inspecting 1 file
^?^C
Exiting... Interrupt again to exit immediately.
^C
real    0m13.643s
user    0m9.900s
sys     0m3.608s
[deployer@local rubocop]$

@jonas054 jonas054 added the bug label Mar 19, 2014
@jonas054
Copy link
Collaborator

Thanks. I see now.

The hanging is a bug, of course. I should mention, though, that you've configured TrailingComma to enforce comma after the last element in a multi-line hash or array, which means that you should add the comma after ].

I haven't done any debugging, but it looks like it's SpaceAfterComma and SpaceInSideBrackets that keep changing the file back and forth. We need to fix that.

hiroponz pushed a commit to hiroponz/rubocop that referenced this issue Mar 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants