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 #11107] Fix a false positive for Style/OperatorMethodCall #11108

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#11107](https://github.com/rubocop/rubocop/issues/11107): Fix a false positive for `Style/OperatorMethodCall` when a constant receiver uses an operator method. ([@koic][])
1 change: 1 addition & 0 deletions lib/rubocop/cop/style/operator_method_call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class OperatorMethodCall < Base

def on_send(node)
return unless (dot = node.loc.dot)
return if node.receiver.const_type?

_lhs, _op, rhs = *node
return if rhs.children.first
Expand Down
6 changes: 6 additions & 0 deletions spec/rubocop/cop/style/operator_method_call_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,10 @@
foo.` bar
RUBY
end

it 'does not register an offense when using `Foo.+(bar)`' do
expect_no_offenses(<<~RUBY)
Foo.+(bar)
RUBY
end
end