Sha256: aa80ce2d19acac889d9ba36eeb8a89b5f32b8c675e54d86b9f46287fe0ab8fa1
Contents?: true
Size: 627 Bytes
Versions: 2
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_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.19.1 | lib/rubocop/cop/lint/rescue_exception.rb |
rubocop-0.19.0 | lib/rubocop/cop/lint/rescue_exception.rb |