Class: RuboCop::Cop::Airbnb::DefaultScope

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/airbnb/default_scope.rb

Overview

Cop to help prevent the scorge of Default Scopes from ActiveRecord. Once in place they are almost impossible to remove.

Constant Summary collapse

MSG =
'Avoid `default_scope`.  Default scopes make it difficult to '\
'refactor data access patterns since the scope becomes part '\
'of every query unless explicitly excluded, even when it is '\
'unnecessary or incidental to the desired logic.'.freeze
RESTRICT_ON_SEND =
%i(default_scope).freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



13
14
15
16
17
# File 'lib/rubocop/cop/airbnb/default_scope.rb', line 13

def on_send(node)
  return if node.receiver

  add_offense(node)
end