Skip to content

Rails/WhereNot raises an error #1221

Closed
@bquorning

Description

Expected behavior

No error.

Actual behavior

An error occurred.

Steps to reproduce the problem

Run the cop against this snippet:

where(["foo != ?", BAZ])

Stacktrace includes

An error occurred while Rails/WhereNot cop was inspecting test.rb:1:0.
undefined method `source' for nil:NilClass
/Users/bquorning/.gem/ruby/3.2.2/gems/rubocop-rails-2.23.0/lib/rubocop/cop/rails/where_not.rb:49:in `block in on_send'
/Users/bquorning/.gem/ruby/3.2.2/gems/rubocop-rails-2.23.0/lib/rubocop/cop/rails/where_not.rb:69:in `where_method_call?'
/Users/bquorning/.gem/ruby/3.2.2/gems/rubocop-rails-2.23.0/lib/rubocop/cop/rails/where_not.rb:41:in `on_send'

RuboCop version

$ bundle exec rubocop -V
1.59.0 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.2.2) [arm64-darwin22]
  - rubocop-performance 1.20.0
  - rubocop-rails 2.23.0
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.25.0
  - rubocop-rubycw 0.1.6
  - rubocop-thread_safety 0.5.1

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions