We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Given the following example: (code&.upcase).to_s Rubocop will not mark the parentheses as redundant.
(code&.upcase).to_s
However, with this similar example: (code.upcase).to_s Rubocop will correctly mark the parentheses as redundant.
(code.upcase).to_s
Happy to help with a PR if this is in fact a bug.
As far as I can tell, there is no reason not to mark such parentheses as redundant:
Style/RedundantParentheses: Don't use parentheses around a method call. (code&.upcase).to_s, ^^^^^^^^^^^^^^
Rubocop does not mark any offenses
test.rb
With default configuration run rubocop --only Style/RedundantParentheses test.rb and notice no offenses
rubocop --only Style/RedundantParentheses test.rb
Optionally, modify the contents of test.rb to:
$ rubocop --version 0.76.0 (using Parser 2.6.5.0, running on ruby 2.3.8 x86_64-darwin18)
The text was updated successfully, but these errors were encountered:
Style/RedundantParentheses
Thanks, @koic!
Sorry, something went wrong.
[Fix rubocop#7515] Fix a false negative for Style/RedundantParentheses
98ff307
Fixes rubocop#7515. This PR fixes a false negative for `Style/RedundantParentheses` when calling a method with safe navigation operator.
Merge pull request #7516 from koic/fix_a_false_negative_for_style_red…
097a6aa
…undant_parentheses [Fix #7515] Fix a false negative for `Style/RedundantParentheses`
Successfully merging a pull request may close this issue.
Given the following example:
(code&.upcase).to_s
Rubocop will not mark the parentheses as redundant.
However, with this similar example:
(code.upcase).to_s
Rubocop will correctly mark the parentheses as redundant.
Happy to help with a PR if this is in fact a bug.
Expected behavior
As far as I can tell, there is no reason not to mark such parentheses as redundant:
Actual behavior
Rubocop does not mark any offenses
Steps to reproduce the problem
test.rb
With default configuration run
rubocop --only Style/RedundantParentheses test.rb
and notice no offensesOptionally, modify the contents of
test.rb
to:rubocop --only Style/RedundantParentheses test.rb
and note that the parentheses are flaggedRuboCop version
The text was updated successfully, but these errors were encountered: