Class: RuboCop::Cop::Sequoiacap::DefaultScope

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/sequoiacap/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

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



16
17
18
19
20
# File 'lib/rubocop/cop/sequoiacap/default_scope.rb', line 16

def on_send(node)
  return unless node.command?(:default_scope)

  add_offense(node)
end