Sha256: 8cb7499815203e68ea170bf3b5603be28240075fce149f664d6413fe07bb9ac6

Contents?: true

Size: 743 Bytes

Versions: 2

Compression:

Stored size: 743 Bytes

Contents

module Pelusa
  module Lint
    class LineRestriction
      def initialize
        @lines = Set.new
      end

      def check(klass)
        initialize
        iterate_lines!(klass)

        return SuccessfulAnalysis.new(name) if lines < limit

        FailedAnalysis.new(name, lines) do |lines|
          "This class has #{lines} lines."
        end
      end

      private

      def name
        "Is below #{limit} lines"
      end

      def limit
        50
      end

      def lines
        @lines.max - @lines.min
      end

      def iterate_lines!(klass)
        iterator = Iterator.new do |node|
          @lines << node.line if node.respond_to?(:line)
        end
        Array(klass).each(&iterator)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pelusa-0.0.2 lib/pelusa/lint/line_restriction.rb
pelusa-0.0.1 lib/pelusa/lint/line_restriction.rb