Sha256: e2b218c1f757f723f36cbffdda71ff6168729975091b79055738f8e28603ee4d

Contents?: true

Size: 555 Bytes

Versions: 9

Compression:

Stored size: 555 Bytes

Contents

require 'roodi/checks/check'

module Roodi
  module Checks
    # 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.
    class ForLoopCheck < Check
      def interesting_nodes
        [:for]
      end

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

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
threedaymonk-roodi-1.3.8 lib/roodi/checks/for_loop_check.rb
roodi-1.3.3 lib/roodi/checks/for_loop_check.rb
roodi-1.3.5 lib/roodi/checks/for_loop_check.rb
roodi-1.3.4 lib/roodi/checks/for_loop_check.rb
roodi-1.3.0 lib/roodi/checks/for_loop_check.rb
roodi-1.3.2 lib/roodi/checks/for_loop_check.rb
roodi-1.3.7 lib/roodi/checks/for_loop_check.rb
roodi-1.4.0 lib/roodi/checks/for_loop_check.rb
roodi-1.3.6 lib/roodi/checks/for_loop_check.rb