1.76.1 fixed some of the issues, but it is still dangerous to trust it on pattern matching.
Expected behavior$ cat rubocop/redundant_parens_2.rb
# frozen_string_literal: true
lhs = {foo: 1}
res = (lhs in {foo:})
puts res
$ ruby rubocop/redundant_parens_2.rb
true
$ bundle exec rubocop -A rubocop/redundant_parens_2.rb
Inspecting 1 file
C
Offenses:
rubocop/redundant_parens_2.rb:2:1: C: [Corrected] Layout/EmptyLineAfterMagicComment: Add an empty line after magic comments.
lhs = {foo: 1}
^
rubocop/redundant_parens_2.rb:3:7: C: [Corrected] Style/RedundantParentheses: Don't use parentheses around a one-line pattern matching.
res = (lhs in {foo:})
^^^^^^^^^^^^^^^
1 file inspected, 2 offenses detected, 2 offenses corrected
$ cat rubocop/redundant_parens_2.rb
# frozen_string_literal: true
lhs = {foo: 1}
res = lhs in {foo:}
puts res
$ ruby rubocop/redundant_parens_2.rb
{:foo=>1}
RuboCop version
$ bundle exec rubocop -V
1.76.1 (using Parser 3.3.8.0, Prism 1.4.0, rubocop-ast 1.45.1, analyzing as Ruby 3.3, running on ruby 3.3.8) [arm64-darwin24]
- rubocop-minitest 0.38.1
- rubocop-performance 1.25.0
Cheers!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4