class Ducalis::ParamsPassing

Constants

OFFENSE
PARAMS_CALL

Public Instance Methods

on_send(node) click to toggle source
# File lib/ducalis/cops/params_passing.rb, line 13
def on_send(node)
  _who, _what, *args = *node
  node = inspect_args(args)
  add_offense(node, :expression, OFFENSE) if node
end

Private Instance Methods

inspect_args(args) click to toggle source
# File lib/ducalis/cops/params_passing.rb, line 21
def inspect_args(args)
  return if Array(args).empty?

  args.find { |arg| arg == PARAMS_CALL }.tap do |node|
    return node if node
  end
  inspect_hash(args.find { |arg| arg.type == :hash })
end
inspect_hash(args) click to toggle source
# File lib/ducalis/cops/params_passing.rb, line 30
def inspect_hash(args)
  return if args.nil?

  args.children.find { |arg| arg.to_a[1] == PARAMS_CALL }
end