Sha256: dbb28fe273b9d29ada724fb70b06100d93ac686122c7bf94863733120aae23a3
Contents?: true
Size: 875 Bytes
Versions: 2
Compression:
Stored size: 875 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.19.1 | lib/rubocop/cop/style/rescue_modifier.rb |
rubocop-0.19.0 | lib/rubocop/cop/style/rescue_modifier.rb |