Sha256: 96d696905ae3b8b57ebc6c9a93b57afa4a60a8626f0029a905c8685abeb2216b
Contents?: true
Size: 629 Bytes
Versions: 2
Compression:
Stored size: 629 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Lint # This cop checks for *rescue* blocks targeting the Exception class. class RescueException < Cop MSG = 'Avoid rescuing the `Exception` class.' def on_resbody(node) return unless node.children.first rescue_args = node.children.first.children if rescue_args.any? { |a| targets_exception?(a) } add_offense(node, :expression) end end def targets_exception?(rescue_arg_node) Util.const_name(rescue_arg_node) == 'Exception' end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.20.1 | lib/rubocop/cop/lint/rescue_exception.rb |
rubocop-0.20.0 | lib/rubocop/cop/lint/rescue_exception.rb |