Skip to content

Commit

Permalink
Revert "[Fix #12649] Fix false positives for Style/InverseMethods"
Browse files Browse the repository at this point in the history
This reverts commit 7b87261.
  • Loading branch information
bbatsov committed Feb 15, 2024
1 parent 7b87261 commit ad79a1e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
1 change: 0 additions & 1 deletion changelog/fix_false_positives_for_style_inverse_methods.md

This file was deleted.

8 changes: 2 additions & 6 deletions lib/rubocop/cop/style/inverse_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def self.autocorrect_incompatible_with
PATTERN

def on_send(node)
inverse_candidate?(node) do |method_call, lhs, method, rhs|
inverse_candidate?(node) do |_method_call, lhs, method, rhs|
return unless inverse_methods.key?(method)
return if negated?(node) || relational_comparison_with_safe_navigation?(method_call)
return if negated?(node)
return if part_of_ignored_node?(node)
return if possible_class_hierarchy_check?(lhs, rhs, method)

Expand Down Expand Up @@ -155,10 +155,6 @@ def negated?(node)
node.parent.respond_to?(:method?) && node.parent.method?(:!)
end

def relational_comparison_with_safe_navigation?(node)
node.csend_type? && CLASS_COMPARISON_METHODS.include?(node.method_name)
end

def not_to_receiver(node, method_call)
node.loc.selector.begin.join(method_call.source_range.begin)
end
Expand Down
24 changes: 0 additions & 24 deletions spec/rubocop/cop/style/inverse_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,30 +209,6 @@ def test_method
end
end

it 'allows comparing for relational comparison operator (`<`) with safe navigation operator' do
expect_no_offenses(<<~RUBY)
!nullable&.<(0)
RUBY
end

it 'allows comparing for relational comparison operator (`<=`) with safe navigation operator' do
expect_no_offenses(<<~RUBY)
!nullable&.<=(0)
RUBY
end

it 'allows comparing for relational comparison operator (`>`) with safe navigation operator' do
expect_no_offenses(<<~RUBY)
!nullable&.>(0)
RUBY
end

it 'allows comparing for relational comparison operator (`>=`) with safe navigation operator' do
expect_no_offenses(<<~RUBY)
!nullable&.>=(0)
RUBY
end

it 'allows comparing camel case constants on the right' do
expect_no_offenses(<<~RUBY)
klass = self.class
Expand Down

0 comments on commit ad79a1e

Please sign in to comment.