class Gitlab::Styles::Rubocop::Cop::ActiveRecordDependent

Cop that prevents the use of `dependent: …` in ActiveRecord models.

Constants

METHOD_NAMES
MSG

Public Instance Methods

on_send(node) click to toggle source
# File lib/gitlab/styles/rubocop/cop/active_record_dependent.rb, line 18
def on_send(node)
  return unless in_model?(node)
  return unless METHOD_NAMES.include?(node.children[1])

  node.children.last.each_node(:pair) do |pair|
    key_name = pair.children[0].children[0]

    add_offense(pair) if key_name == :dependent
  end
end