Class: Ducalis::RaiseWithoutErrorClass

Inherits:
RuboCop::Cop::Cop
  • Object
show all
Defined in:
lib/ducalis/cops/raise_without_error_class.rb

Constant Summary collapse

OFFENSE =
<<-MESSAGE.gsub(/^ +\|\s/, '').strip
  | It's better to add exception class as raise argument. It will make easier to catch and process it later.
MESSAGE

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/ducalis/cops/raise_without_error_class.rb', line 11

def on_send(node)
  _who, what, *args = *node
  return if what != :raise
  return if args.first && args.first.type != :str

  add_offense(node, :expression, OFFENSE)
end