Class: Roodi::Checks::CaseMissingElseCheck
- Defined in:
- lib/roodi/checks/case_missing_else_check.rb
Overview
Checks a case statement to make sure it has an ‘else’ clause.
It’s usually a good idea to have an else clause in every case statement. Even if the developer is sure that all currently possible cases are covered, this should be expressed in the else clause. This way the code is protected aginst later changes,
Constant Summary
Constants inherited from Check
Roodi::Checks::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/case_missing_else_check.rb', line 15 def evaluate_start(node) add_error "Case statement is missing an else clause." unless node.last end |
#interesting_nodes ⇒ Object
11 12 13 |
# File 'lib/roodi/checks/case_missing_else_check.rb', line 11 def interesting_nodes [:case] end |