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

Fix a false positive for Lint/ParenthesesAsGroupedExpression #7909

Conversation

koic
Copy link
Member

@koic koic commented Apr 26, 2020

This PR fixes a false positive for Lint/ParenthesesAsGroupedExpression when using an intended grouped parentheses.

puts (2 + 3) * 4

I noticed this false positive in implementing this cop's auto-correction. So, I plan to open a PR that implements auto-correction separately from this PR.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@koic koic force-pushed the fix_a_false_positive_for_parentheses_as_grouped_expression branch from 397c1ce to 4a8b5e5 Compare April 26, 2020 11:39
koic added a commit to koic/ruby-style-guide that referenced this pull request Apr 26, 2020
Follow up of rubocop/rubocop#7909.

This PR refines an example for "Space in Method Calls" rule.

The example code is not compatible.

```ruby
def f(num)
  num * 2
end

p f (3 + 2) + 1 #=> 12
p f(3 + 2) + 1  #=> 11
```

This PR replaces an example code.
@koic koic force-pushed the fix_a_false_positive_for_parentheses_as_grouped_expression branch from 4a8b5e5 to 47297ff Compare April 27, 2020 02:13
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 29, 2020

The fix looks good, but we should probably tweak the examples in the docs, as they look a lot like math expressions. :-)

@koic koic force-pushed the fix_a_false_positive_for_parentheses_as_grouped_expression branch 2 times, most recently from 56f76c5 to 5be9497 Compare April 29, 2020 07:48
@koic
Copy link
Member Author

koic commented Apr 29, 2020

I tweaked the existing examples and added a new examples.

bbatsov pushed a commit to rubocop/ruby-style-guide that referenced this pull request Apr 30, 2020
Follow up of rubocop/rubocop#7909.

This PR refines an example for "Space in Method Calls" rule.

The example code is not compatible.

```ruby
def f(num)
  num * 2
end

p f (3 + 2) + 1 #=> 12
p f(3 + 2) + 1  #=> 11
```

This PR replaces an example code.
@koic koic force-pushed the fix_a_false_positive_for_parentheses_as_grouped_expression branch from 5be9497 to 21cb1fd Compare May 1, 2020 03:58
This PR fixes a false positive for `Lint/ParenthesesAsGroupedExpression`
when using an intended grouped parentheses.

```ruby
puts (2 + 3) * 4
```

I noticed this false positive in implementing this cop's auto-correction.
So, I plan to open a PR that implements auto-correction separately from
this PR.
@koic koic force-pushed the fix_a_false_positive_for_parentheses_as_grouped_expression branch from 21cb1fd to 5d5cf77 Compare May 7, 2020 09:21
@koic koic merged commit 6baec8f into rubocop:master May 9, 2020
@koic koic deleted the fix_a_false_positive_for_parentheses_as_grouped_expression branch May 9, 2020 05:11
koic added a commit to koic/rubocop that referenced this pull request May 10, 2020
Follow up to rubocop#7909.

This PR supports autocorrection for `Lint/ParenthesesAsGroupedExpression`.
koic added a commit to koic/rubocop that referenced this pull request 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 pull request 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants