Sha256: 596d7d7c4a6bf5ebb449f19f221f41ce94a0ab8993987815f0c7a773ac26d767
Contents?: true
Size: 752 Bytes
Versions: 6
Compression:
Stored size: 752 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Style # This cop checks for RuntimeError as the argument of raise/fail. # # Currently it checks for code like this: # # @example # # raise RuntimeError, 'message' class RedundantException < Cop MSG = 'Redundant `RuntimeError` argument can be removed.' TARGET_NODE = s(:const, nil, :RuntimeError) 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 end end end end
Version data entries
6 entries across 6 versions & 1 rubygems