Navigation Menu

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

Style/RedundantParentheses should ignore yielding hash literal #8208

Closed
karlwithak opened this issue Jun 24, 2020 · 1 comment · Fixed by #8214
Closed

Style/RedundantParentheses should ignore yielding hash literal #8208

karlwithak opened this issue Jun 24, 2020 · 1 comment · Fixed by #8214
Labels
bug good first issue Easy task, suitable for newcomers to the project help wanted

Comments

@karlwithak
Copy link
Contributor

With a method like:

def foo
  yield ({
    a: 6,
    b: 7,
  })
end

Running rubocop -a autocorrects this to:

def foo
  yield {
    a: 6,
    b: 7,
  }
end

And gives this output:

app/test.rb:4:9: E: Lint/Syntax: unexpected token tLCURLY
(Using Ruby 2.5 parser; configure using TargetRubyVersion parameter, under AllCops)
  yield {
        ^
app/test.rb:4:9: C: [Corrected] Style/RedundantParentheses: Don't use parentheses around a literal.
  yield ({ ...
        ^^

When running this auto-corrected file, I get a syntax error:

app/test.rb:4: syntax error, unexpected '{'
  yield {
        ^

I believe the Style/RedundantParentheses cop should not consider parentheses in this situation to be redundant

$ rubocop -V
0.86.0 (using Parser 2.7.1.4, rubocop-ast 0.0.3, running on ruby 2.5.1 x86_64-darwin18)
@marcandre marcandre added bug good first issue Easy task, suitable for newcomers to the project help wanted labels Jun 24, 2020
@karlwithak
Copy link
Contributor Author

I will look into a fix for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Easy task, suitable for newcomers to the project help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants