Skip to content

Commit

Permalink
Merge pull request #1208 from fatkodima/fix-where-missing-error
Browse files Browse the repository at this point in the history
Fix an error for `Rails/WhereMissing` where join method is called without arguments
  • Loading branch information
koic committed Dec 10, 2023
2 parents 9d5a223 + 533b942 commit a280038
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#1206](https://github.com/rubocop/rubocop-rails/issues/1206): Fix an error for `Rails/WhereMissing` where join method is called without arguments. ([@fatkodima][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/where_missing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class WhereMissing < Base
PATTERN

def on_send(node)
return unless node.first_argument.sym_type?
return unless node.first_argument&.sym_type?

root_receiver = root_receiver(node)
where_node_and_argument(root_receiver) do |where_node, where_argument|
Expand Down
6 changes: 6 additions & 0 deletions spec/rubocop/cop/rails/where_missing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ def test
Foo.left_joins(bar: :foo).where(bars: { id: nil })
RUBY
end

it 'does not register an offense when using `left_joins` without arguments' do
expect_no_offenses(<<~RUBY)
Foo.left_joins(left_joins).where(bars: { id: nil })
RUBY
end
end

context 'Rails 6.0', :rails60 do
Expand Down

0 comments on commit a280038

Please sign in to comment.