class Ducalis::PreferableMethods

Constants

ALWAYS_TRUE
DESCRIPTION
DETAILS
OFFENSE
VALIDATE_CHECK

Public Instance Methods

on_send(node) click to toggle source
# File lib/ducalis/cops/preferable_methods.rb, line 64
def on_send(node)
  who, what, *args = *node
  return unless DESCRIPTION.key?(what)

  alternative, reason, condition = DESCRIPTION.fetch(what)
  return unless condition.call(who, what, args)

  add_offense(node, :expression, format(OFFENSE, original: what,
                                                 alternative: alternative,
                                                 reason: reason))
end