Sha256: 6b9184faa6dbfcfe2fef998c64a927ce3bc5b9df9ba2de62b6e03ffc3dc342c6

Contents?: true

Size: 701 Bytes

Versions: 1

Compression:

Stored size: 701 Bytes

Contents

require 'roodi/checks/check'

module Roodi
  module Checks
    class ModuleLineCountCheck < Check
      def initialize(line_count = 300)
        super()
        @line_count = line_count
      end
      
      def interesting_nodes
        [:module]
      end

      def evaluate(node)
        line_count = count_lines(node)
        add_error "Module \"#{node[1]}\" has #{line_count} lines.  It should have #{@line_count} or less." unless line_count <= @line_count
      end
  
      private
  
      def count_lines(node)
        count = 0
        count = count + 1 if node.node_type == :newline
        node.children.each {|node| count += count_lines(node)}
        count
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roodi-1.2.0 lib/roodi/checks/module_line_count_check.rb