Skip to content

Commit

Permalink
[Fixes rubocop#8534] Fix Lint/BinaryOperatorWithIdenticalOperands f…
Browse files Browse the repository at this point in the history
…or binary operators used as unary operators
  • Loading branch information
marcandre committed Aug 13, 2020
1 parent 4fd12d1 commit 068b601
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@
### Bug fixes

* [#8508](https://github.com/rubocop-hq/rubocop/pull/8508): Fix a false positive for `Style/CaseLikeIf` when conditional contains comparison with a class. Mark `Style/CaseLikeIf` as not safe. ([@fatkodima][])
* [#8534](https://github.com/rubocop-hq/rubocop/issues/8534): Fix `Lint/BinaryOperatorWithIdenticalOperands` for binary operators used as unary operators. ([@marcandre][])

### Changes

Expand Down
Expand Up @@ -35,7 +35,7 @@ def on_send(node)
return unless node.binary_operation?

lhs, operation, rhs = *node
return if MATH_OPERATORS.include?(node.method_name) && rhs.basic_literal?
return if MATH_OPERATORS.include?(node.method_name) && lhs.basic_literal?

add_offense(node, message: format(MSG, op: operation)) if lhs == rhs
end
Expand Down
Expand Up @@ -31,4 +31,10 @@
x = 1 << 1
RUBY
end

it 'does not crash on operator without any argument' do
expect_no_offenses(<<~RUBY)
foo.*
RUBY
end
end

0 comments on commit 068b601

Please sign in to comment.