Sha256: ac67fd6ddc494d3cde2fb5f82bf5e26590af4ede6a1f2ef53c90e70447ccf4d9
Contents?: true
Size: 627 Bytes
Versions: 4
Compression:
Stored size: 627 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_offence(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
4 entries across 4 versions & 1 rubygems