Class: Roodi::Checks::ForLoopCheck

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

Overview

Checks to make sure for loops are not being used..

Using a for loop is not idiomatic use of Ruby, and is usually a sign that someone with more experience in a different programming language is trying out Ruby. Use Enumerable.each with a block instead.

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/for_loop_check.rb', line 15

def evaluate_start(node)
  add_error "Don't use 'for' loops. Use Enumerable.each instead."
end

#interesting_nodesObject



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

def interesting_nodes
  [:for]
end