Class: RuboCop::Cop::DatabaseValidations::BelongsTo

Inherits:
Base
  • Object
show all
Defined in:
lib/database_validations/rubocop/cop/belongs_to.rb

Overview

Use db_belongs_to instead of belongs_to.

Examples:

# bad
belongs_to :company

# good
db_belongs_to :company

Constant Summary collapse

MSG =
'Use `db_belongs_to`.'.freeze
RESTRICT_ON_SEND =
%i[belongs_to].freeze
NON_SUPPORTED_OPTIONS =
%i[
  optional
  required
  polymorphic
  foreign_type
].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



26
27
28
29
30
# File 'lib/database_validations/rubocop/cop/belongs_to.rb', line 26

def on_send(node)
  return unless supported?(node)

  add_offense(node.loc.selector)
end