-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
The Style/ArrayIntersect seems to blow up when checking code without an explicit receiver for the intersection method, in this case on a method that's implemented on an Array subclass.
Expected behavior
No error.
Actual behavior
An error occurred:
An error occurred while Style/ArrayIntersect cop was inspecting /Users/reidab/code/thedyrt/api/app/lib/fail.rb:8:5.
/Users/reidab/.rbenv/versions/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.81.1/lib/rubocop/cop/style/array_intersect.rb:148:in `on_send': undefined method `source' for nil (NoMethodError)
replacement = "#{bang}#{receiver.source}#{dot}intersect?(#{argument.source})"
^^^^^^^
Steps to reproduce the problem
Attempt to check something like this
class SpecialArray < Array
def intersection(other)
# some custom intersection logic
self & other
end
def intersect?(other)
!intersection(other).empty?
end
endRuboCop version
1.81.1 (using Parser 3.3.9.0, Prism 1.5.1, rubocop-ast 1.47.1, analyzing as Ruby 3.3, running on ruby 3.3.9) [arm64-darwin25]
- rubocop-factory_bot 2.27.1
- rubocop-performance 1.26.0
- rubocop-rails 2.33.3
- rubocop-rake 0.7.1
- rubocop-rspec 3.7.0
- rubocop-rspec_rails 2.31.0
- rubocop-sorbet 0.10.5