-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
heredoc as hash value raises Style/RedundantParentheses #2874
Comments
This doesn't specifically have anything to do with heredocs.
|
From
|
I consider this to be a bug in Ruby's parser. Wonder if they would accept a patch... |
I guess I can't say that it has nothing to do with heredocs: the issue is that a heredoc must always be terminated with a newline (you can't put anything else on the terminating line), so a bare heredoc can't be used anywhere where the parser can't swallow a newline. If you surround it with parens, it's OK. |
Maybe we shouldn't consider parens redundant if the right paren comes directly after the terminating line of a heredoc? That would probably require us to walk the entire subtree looking for a heredoc, which is a bit of a pain. |
OR, rather than looking at the AST, we look at the tokens. Find the token for the rparen, see if it is preceded by |
^ this Also, this issue appeared between: $ rubocop -V
0.34.2 (using Parser 2.2.3.0, running on ruby 2.1.6 x86_64-linux) and the specified version in OP. |
That's probably when the |
`Style/RedundantParentheses` doesn't register an offense for parentheses in array and hash literals when the removal would cause invalid syntax. For example, the following is accepted: array = [( <<-EOF something EOF ), 'something']
`Style/RedundantParentheses` doesn't register an offense for parentheses in array and hash literals when the removal would cause invalid syntax. For example, the following is accepted: array = [( <<-EOF something EOF ), 'something']
I'll let the command line do the talking:
$ rubocop -V # supplied by ChefDK 0.11.0 0.37.2 (using Parser 2.3.0.5, running on ruby 2.1.6 x86_64-darwin12.0)
Don't know whether this issue is related to #2654 and/or #2845. This is the closest I got before raising a new issue.
The text was updated successfully, but these errors were encountered: