Parent

Methods

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Style::RedundantException

This cop checks for RuntimeError as the argument of raise/fail.

Currently it checks for code like this:

@example

raise RuntimeError, 'message'

Constants

MSG
TARGET_NODE

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/style/redundant_exception.rb, line 17
def on_send(node)
  return unless command?(:raise, node) || command?(:fail, node)

  _receiver, _selector, *args = *node

  return unless args.size == 2

  first_arg, = *args

  add_offense(first_arg, :expression) if first_arg == TARGET_NODE
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.