class RuboCop::Cop::Rails::RedundantForeignKey

def default_foreign_key(node, association_type, association_name, options)

def default_foreign_key(node, association_type, association_name, options)
  if association_type == :belongs_to
    "#{association_name}_id"
  elsif (as = find_as_option(options))
    "#{as}_id"
  else
    node.parent_module_name&.foreign_key
  end
end