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

Rails/WhereNot raises an error #1221

Closed
bquorning opened this issue Dec 18, 2023 · 0 comments · Fixed by #1222
Closed

Rails/WhereNot raises an error #1221

bquorning opened this issue Dec 18, 2023 · 0 comments · Fixed by #1222
Assignees
Labels
bug Something isn't working

Comments

@bquorning
Copy link
Contributor

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
@bquorning bquorning self-assigned this Dec 19, 2023
bquorning added a commit that referenced this issue Dec 19, 2023
Fix an exception in `Rails/WhereNot` when calling `.where` on an implicit
receiver (e.g. inside model code).

Fixes #1221
bquorning added a commit that referenced this issue Dec 19, 2023
Fix `Rails/WhereNot` which raised an exception when calling `.where` on an
implicit receiver (e.g. inside model code).
@bquorning bquorning added the bug Something isn't working label Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant