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

False-positive and broken autocorrect in Style/RedundantParentheses #2729

Closed
savef opened this issue Jan 27, 2016 · 3 comments
Closed

False-positive and broken autocorrect in Style/RedundantParentheses #2729

savef opened this issue Jan 27, 2016 · 3 comments

Comments

@savef
Copy link
Contributor

savef commented Jan 27, 2016

The following code gives "don't use parentheses around a literal":
assert_equal ({ id: 1 }), some_method_call

The parentheses here are needed and when autocorrect removes them we're left with a syntax error.

Whether or not this is a false-positive might be up for debate, I imagine some would want to force this literal into a variable declaration because it is pretty ugly, but the autocorrect is definitely broken.

@lumeet
Copy link
Contributor

lumeet commented Jan 28, 2016

Thanks, that's definitely a bug. However, I'd still try to avoid those parentheses and instead put them around all arguments like this: assert_equal({ id: 1 }, some_method_call).

@savef
Copy link
Contributor Author

savef commented Jan 28, 2016

Thinking about whether or not this could be called a false-positive I've decided that it must be, because even if we don't like the code it's certainly not redundant. We'd have to employ a new cop to say "this style is really ugly" IMO.

@lumeet
Copy link
Contributor

lumeet commented Jan 28, 2016

I was a little hasty with the wording, sorry. @savef, your comment summarizes pretty well my opinion, too. The bug will be fixed soon but I leave the UglyButNotSoImportantParentheses cop to someone else. ;)

bbatsov added a commit that referenced this issue Jan 29, 2016
[Fix #2729] Fix hash bug in RedundantParentheses
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

2 participants