lib/rubocop/cop/rails/order_by_id.rb in rubocop-rails-2.8.1 vs lib/rubocop/cop/rails/order_by_id.rb in rubocop-rails-2.9.0
- old
+ new
@@ -23,10 +23,11 @@
class OrderById < Base
include RangeHelp
MSG = 'Do not use the `id` column for ordering. '\
'Use a timestamp column to order chronologically.'
+ RESTRICT_ON_SEND = %i[order].freeze
def_node_matcher :order_by_id?, <<~PATTERN
(send _ :order
{
(sym :id)
@@ -35,11 +36,9 @@
(hash (pair (send _ :primary_key) _))
})
PATTERN
def on_send(node)
- return unless node.method?(:order)
-
add_offense(offense_range(node)) if order_by_id?(node)
end
private