class Rubocop::Cop::Style::RescueModifier
This cop checks for uses of rescue in its modifier form.
Constants
- MSG
Public Instance Methods
normal_rescue?(node)
click to toggle source
# File lib/rubocop/cop/style/rescue_modifier.rb, line 28 def normal_rescue?(node) return false unless node case node.type when :rescue # Skip only the rescue node and continue processing its children. process_regular_node(node) true when :ensure first_child = node.children.first if first_child && first_child.type == :rescue process_regular_node(first_child) true else false end else false end end
on_def(node)
click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/rescue_modifier.rb, line 16 def on_def(node) _method_name, _args, body = *node return if normal_rescue?(body) super end
on_defs(node)
click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/rescue_modifier.rb, line 22 def on_defs(node) _receiver, _method_name, _args, body = *node return if normal_rescue?(body) super end
on_kwbegin(node)
click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/rescue_modifier.rb, line 10 def on_kwbegin(node) body, *_ = *node return if normal_rescue?(body) super end
on_rescue(node)
click to toggle source
# File lib/rubocop/cop/style/rescue_modifier.rb, line 49 def on_rescue(node) add_offence(:convention, node.loc.expression, MSG) end