KEMBAR78
Style/RedundantParentheses false positive on one-line rescue within array · Issue #14386 · rubocop/rubocop · GitHub
Skip to content

Style/RedundantParentheses false positive on one-line rescue within array #14386

@lucthev

Description

@lucthev

When a one-line rescue is used as an array element, v1.79 suggests removing the parentheses, but doing so is a syntax error. Likely as a result of #14355?

[
  (foo rescue nil),
]

Expected behavior

No Style/RedundantParentheses offenses.

Actual behavior

test.rb:2:3: C: [Correctable] Style/RedundantParentheses: Don't use parentheses around a one-line rescue.
  (foo rescue nil),
  ^^^^^^^^^^^^^^^^

Steps to reproduce the problem

# test.rb
[
  (foo rescue nil),
]
$ rubocop --cache=false --only Style/RedundantParentheses test.rb

RuboCop version

1.79.0 (using Parser 3.3.9.0, Prism 1.4.0, default, rubocop-ast 1.46.0, analyzing as Ruby 3.4, running on ruby 3.4.1) [arm64-darwin23]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions