Skip to content

Commit

Permalink
Merge pull request #7639 from gsamokovarov/omit-parentheses-rhs-of-op…
Browse files Browse the repository at this point in the history
…erators

Fix  edge case in `omit_parentheses` style of `Style/MethodCallWithArgsParentheses`
  • Loading branch information
koic committed Jan 10, 2020
2 parents 1a6ef08 + c7d6d76 commit 7e37a77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bug fixes

* [#7639](https://github.com/rubocop-hq/rubocop/pull/7639): Fix logical operator edge case in `omit_parentheses` style of `Style/MethodCallWithArgsParentheses`. ([@gsamokovarov][])

### Changes

* [#7636](https://github.com/rubocop-hq/rubocop/issues/7636): Remove `console` from `Lint/Debugger` to prevent false positives. ([@gsamokovarov][])
Expand Down
Expand Up @@ -74,10 +74,11 @@ def call_in_literals?(node)
end

def call_in_logical_operators?(node)
node.parent &&
(logical_operator?(node.parent) ||
node.parent.send_type? &&
node.parent.arguments.any?(&method(:logical_operator?)))
parent = node.parent&.block_type? ? node.parent.parent : node.parent
parent &&
(logical_operator?(parent) ||
parent.send_type? &&
parent.arguments.any?(&method(:logical_operator?)))
end

def call_in_optional_arguments?(node)
Expand Down
Expand Up @@ -471,6 +471,11 @@ def seatle_style arg: default(42)
it 'accepts parens in calls with logical operators' do
expect_no_offenses('foo(a) && bar(b)')
expect_no_offenses('foo(a) || bar(b)')
expect_no_offenses(<<~RUBY)
foo(a) || bar(b) do
pass
end
RUBY
end

it 'accepts parens in calls with args with logical operators' do
Expand Down

0 comments on commit 7e37a77

Please sign in to comment.