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

Lint/ParenthesesAsGroupedExpression: a false positive case with hash rocket argument #8834

Closed
deepj opened this issue Oct 2, 2020 · 0 comments · Fixed by #8839
Closed

Lint/ParenthesesAsGroupedExpression: a false positive case with hash rocket argument #8834

deepj opened this issue Oct 2, 2020 · 0 comments · Fixed by #8839
Labels

Comments

@deepj
Copy link
Contributor

deepj commented Oct 2, 2020

The following case uses state_machine DSL for describing an event of state machine inside a Rails model.

Expected behavior

transition (any - %i[failed canceled processing]) => :processing

The code doesn't violate Lint/ParenthesesAsGroupedExpression cop

Actual behavior

W: Lint/ParenthesesAsGroupedExpression: (...) interpreted as grouped expression.
      transition (any - %i[failed canceled processing]) => :processing
                ^

Auto-corrected to:

transition(any - %i[failed canceled processing]) => :processing

This breaks code. Since the argument for transition method is (any - %i[failed canceled processing]) => :processing

Steps to reproduce the problem

Code snippet

    event :regenerate do
      transition (any - %i[failed canceled processing]) => :processing
    end

Run

rubocop --only Lint/ParenthesesAsGroupedExpression

RuboCop version

$ rubocop -V
0.92.0 (using Parser 2.7.1.5, rubocop-ast 0.7.1, running on ruby 2.7.1 x86_64-darwin18)
@koic koic added the bug label Oct 2, 2020
koic added a commit to koic/rubocop that referenced this issue Oct 2, 2020
…edExpression`

Fixes rubocop#8834.

Fix a false positive for `Style/ParenthesesAsGroupedExpression` when
method argument parentheses are omitted and hash argument key is enclosed
in parentheses.
bbatsov added a commit that referenced this issue Oct 8, 2020
…ssion` (#8839)

Fixes #8834.

Fix a false positive for `Style/ParenthesesAsGroupedExpression` when
method argument parentheses are omitted and hash argument key is enclosed
in parentheses.

Co-authored-by: Bozhidar Batsov <bozhidar@batsov.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants