Sha256: 4a19abb2b5f0071350889d1696c73113191daa2da427dfebafa3a4f8e6e6c685
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
# encoding: utf-8 module Rubocop module Cop module Style # This cop checks for uses of rescue in its modifier form. class RescueModifier < Cop MSG = 'Avoid using rescue in its modifier form.' def on_rescue(node) return if ignored_node?(node) add_offence(:convention, node.loc.expression, MSG) end def on_kwbegin(node) body, *_ = *node check_rescue(body) end def on_def(node) _method_name, _args, body = *node check_rescue(body) end def on_defs(node) _receiver, _method_name, _args, body = *node check_rescue(body) end def check_rescue(node) return unless node case node.type when :rescue ignore_node(node) when :ensure first_child = node.children.first if first_child && first_child.type == :rescue ignore_node(first_child) end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems