Sha256: 8f355d6f509671849512297a56e788e93eaed88494fa2c4cca35f92aa88772ba
Contents?: true
Size: 765 Bytes
Versions: 2
Compression:
Stored size: 765 Bytes
Contents
require 'roodi/checks/check' module Roodi module Checks class EmptyRescueBodyCheck < Check STATEMENT_NODES = [:fcall, :return, :attrasgn, :vcall] def interesting_nodes [:resbody] end def evaluate(node) add_error({}, 1) unless has_statement?(node) end private def has_statement?(node) return true if STATEMENT_NODES.include?(node.node_type) return true if assigning_other_than_exception_to_local_variable?(node) return true if node.children.any? { |child| has_statement?(child) } end def assigning_other_than_exception_to_local_variable?(node) node.node_type == :lasgn && node[2].to_a != [:gvar, :$!] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
marcoow-roodi-1.3.2 | lib/roodi/checks/empty_rescue_body_check.rb |
marcoow-roodi-1.3.4 | lib/roodi/checks/empty_rescue_body_check.rb |