lib/simplabs/excellent/checks/for_loop_check.rb in simplabs-excellent-1.0.1 vs lib/simplabs/excellent/checks/for_loop_check.rb in simplabs-excellent-1.2.1

- old
+ new

@@ -4,17 +4,33 @@ module Excellent module Checks + # This check reports code that uses +for+ loops as in: + # + # for user in @users + # do_something(user) + # end + # + # The use of for loops in Ruby is contrary to the language's basic concept of iterators. The above statement would better be written as: + # + # @users.each do |user| + # do_something(user) + # end + # + # ==== Applies to + # + # * +for+ loops class ForLoopCheck < Base - def interesting_nodes - [:for] + def initialize #:nodoc: + super + @interesting_nodes = [:for] end - def evaluate(node) - add_error('For loop used.') + def evaluate(context) #:nodoc: + add_warning(context, 'For loop used.') end end end