class Rubocop::Cop::Lint::RescueException
This cop checks for rescue blocks targeting the Exception class.
Constants
- MSG
Public Instance Methods
on_resbody(node)
click to toggle source
Calls superclass method
# File lib/rubocop/cop/lint/rescue_exception.rb, line 10 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(:warning, node.location.expression, MSG) end super end
targets_exception?(rescue_arg_node)
click to toggle source
# File lib/rubocop/cop/lint/rescue_exception.rb, line 20 def targets_exception?(rescue_arg_node) return false unless rescue_arg_node.type == :const namespace, klass_name = *rescue_arg_node return false unless namespace.nil? || namespace.type == :cbase klass_name == :Exception end