Sha256: 96ea0d0bff8afa7c2517cb9786189010afa1aea0f4ce7fddddc0a74368e0674b

Contents?: true

Size: 580 Bytes

Versions: 4

Compression:

Stored size: 580 Bytes

Contents

require 'roodi/checks/check'

module Roodi
  module Checks
    class EmptyRescueBodyCheck < Check
      def interesting_nodes
        [:resbody]
      end

      def evaluate(node)
        add_error("Rescue block should not be empty.", 1) unless has_statement?(node)
      end
  
      private
  
      def has_statement?(node)
        found_statement = false
        found_statement = found_statement || node.node_type == :fcall
        node.children.each { |child| found_statement = found_statement || has_statement?(child) }
        found_statement
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
roodi-0.5 lib/roodi/checks/empty_rescue_body_check.rb
roodi-1.1.0 lib/roodi/checks/empty_rescue_body_check.rb
roodi-1.1.1 lib/roodi/checks/empty_rescue_body_check.rb
roodi-1.2.0 lib/roodi/checks/empty_rescue_body_check.rb