Class: Roodi::Checks::EmptyRescueBodyCheck

Inherits:
Check
  • Object
show all
Defined in:
lib/roodi/checks/empty_rescue_body_check.rb

Overview

Checks the body of a rescue block to make sure it's not empty..

When the body of a rescue block is empty, exceptions can get caught and swallowed without any feedback to the user.

Constant Summary

Constants inherited from Check

Check::NODE_TYPES

Instance Method Summary collapse

Methods inherited from Check

#add_error, #end_file, #errors, #evaluate_end, #evaluate_node, #evaluate_node_end, #evaluate_node_start, #initialize, make, #position, #start_file

Constructor Details

This class inherits a constructor from Roodi::Checks::Check

Instance Method Details

#evaluate_start(node) ⇒ Object


15
16
17
# File 'lib/roodi/checks/empty_rescue_body_check.rb', line 15

def evaluate_start(node)
  add_error("Rescue block should not be empty.") if node.children[1].nil?
end

#interesting_nodesObject


11
12
13
# File 'lib/roodi/checks/empty_rescue_body_check.rb', line 11

def interesting_nodes
  [:resbody]
end