class RuboCop::Cop::Style::RaiseException

This cop checks for uses of `raise e`. @example case e when condition

statement

else

raise e

end

Constants

ALLOWED_TYPES
MSG

Public Instance Methods

on_send(node) click to toggle source
# File lib/raise_exception.rb, line 21
def on_send(node)
  return unless node.command?(:raise)

  # args will contain the type of arguments ex) (send nil :e)
  _receiver, _selector, args = *node

  add_offense(node, :expression, MSG) unless ALLOWED_TYPES.include?(args.type)
end