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

Regression in 0.83.0: ParenthesesAsGroupedExpression for heredoc #7962

Closed
jaredbeck opened this issue May 12, 2020 · 2 comments · Fixed by #7963
Closed

Regression in 0.83.0: ParenthesesAsGroupedExpression for heredoc #7962

jaredbeck opened this issue May 12, 2020 · 2 comments · Fixed by #7963
Labels

Comments

@jaredbeck
Copy link
Contributor

Expected behavior

The following input should not produce an offense.

def users
  ::User.redacted(@redacted.redacted).where(
    <<-SQL
      exists (
        select 1
        from redacted
        where (
          users.id = redacted.redacted_id
          or users.id = redacted.redacted2_id
        )
      )
    SQL
  )
end

Actual behavior

The above input produced the following offense.

app/redacted/redacted/redacted.rb:34:12: W: Lint/ParenthesesAsGroupedExpression: (...) interpreted as grouped expression.
            <<-SQL
           ^

Steps to reproduce the problem

Place the above input in a file and run rubocop 0.83.0 on it.

Confirm regression by running the same experiment in 0.82 and not producing an offense.

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:

0.83.0 (using Parser 2.7.1.2, running on ruby 2.6.6 x86_64-darwin19)
@koic koic added the bug label May 13, 2020
koic added a commit to koic/rubocop that referenced this issue May 13, 2020
…dExpression`

Fixes rubocop#7962.

This PR fixes the following false positive for `Lint/ParenthesesAsGroupedExpression`
when heredoc has a space between the same string as the method name and `(`.

```ruby
foo(
  <<~EOS
    foo (
    )
  EOS
)
```

This PR adds a reproduction test and reverts a required logic removed by rubocop#7909.
bbatsov pushed a commit that referenced this issue May 13, 2020
…sion`

Fixes #7962.

This PR fixes the following false positive for `Lint/ParenthesesAsGroupedExpression`
when heredoc has a space between the same string as the method name and `(`.

```ruby
foo(
  <<~EOS
    foo (
    )
  EOS
)
```

This PR adds a reproduction test and reverts a required logic removed by #7909.
@jaredbeck
Copy link
Contributor Author

Thanks Koichi and Bozhidar! That was fast.

@bbatsov
Copy link
Collaborator

bbatsov commented May 13, 2020

You're welcome!

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.

3 participants