Sha256: 6540851e05e1ae04667669227063825376ce3eae7ed48a43baa95eb331f17f26
Contents?: true
Size: 877 Bytes
Versions: 4
Compression:
Stored size: 877 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Style # This cop checks for uses of rescue in its modifier form. class RescueModifier < Cop include CheckMethods MSG = 'Avoid using `rescue` in its modifier form.' def on_rescue(node) return if ignored_node?(node) add_offense(node, :expression) end def on_kwbegin(node) body, *_ = *node check(nil, nil, nil, body) end def check(_node, _method_name, _args, body) return unless body case body.type when :rescue ignore_node(body) when :ensure first_child = body.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