Class: RuboCop::Cop::CableReady::ApplicationRecordEnableUpdates

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/cable_ready/application_record_enable_updates.rb

Constant Summary collapse

MSG =
"%<method_name>s should not be switched on globally"

Instance Method Summary collapse

Methods inherited from Base

inherited

Instance Method Details

#on_send(node) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rubocop/cop/cable_ready/application_record_enable_updates.rb', line 17

def on_send(node)
  receiver_node, _method_name, *_arg_nodes = *node.parent.parent

  return unless %i[enable_updates enable_cable_ready_updates].include?(node.method_name)

  return unless is_application_record?(receiver_node)

  return unless node.ancestors.any? { |ancestor| active_record_base_class?(ancestor) }

  message = format(MSG, method_name: node.method_name)
  add_offense(node, message: message)
end