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

Inherits:
RuboCop::Cop
  • 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
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
31
# File 'lib/database_validations/rubocop/cop/belongs_to.rb', line 26

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

  add_offense(node, location: :selector)
end