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

Bug of Style/SpaceInsideHashLiteralBraces #3958

Closed
nodo opened this issue Jan 23, 2017 · 2 comments · Fixed by #3976
Closed

Bug of Style/SpaceInsideHashLiteralBraces #3958

nodo opened this issue Jan 23, 2017 · 2 comments · Fixed by #3976
Labels

Comments

@nodo
Copy link

nodo commented Jan 23, 2017

Rubcop raises a style violation when the value of on hash is an open curly bracket in a string (see below).

Expected behavior

This line of code should not be a rubocop offense:

{ key: '{' }

Please note that there is just 1 space surrounding the string. Any other character does not raise a style violation.

Actual behavior

Inspecting 1 file
C

Offenses:

rubocop_issue.rb:1:7: C: Space inside empty hash literal braces detected.
{ key: '{' }
      ^^^

1 file inspected, 1 offense detected

Steps to reproduce the problem

  1. Create a file with this line { key: '{' }
  2. Run rubocop

RuboCop version

$ rubocop -V                                                                                                                                                                                                                            
0.47.1 (using Parser 2.3.3.1, running on ruby 2.4.0 x86_64-darwin15)
@bbatsov bbatsov added the bug label Jan 24, 2017
@bbatsov
Copy link
Collaborator

bbatsov commented Jan 24, 2017

Nice catch!

@nodo
Copy link
Author

nodo commented Jan 25, 2017

Thanks @bbatsov. FYI: I am working on this. I will send a PR soon.

bbatsov pushed a commit that referenced this issue Feb 6, 2017
When checking the braces, it uses the type instead of text to avoid
confusion a brace in a string. This avoid a confusion when token text is
a brace, but the token type is a string.
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.

2 participants