Sha256: dd64c4af5b870a013067dd9370c94eb7469d62a1e3867cdc37be7a831d50105f

Contents?: true

Size: 661 Bytes

Versions: 15

Compression:

Stored size: 661 Bytes

Contents

module Skeptic
  module Rules
    class LineLength
      DESCRIPTION = 'Limit the line length'

      attr_reader :line_lengths

      def initialize(limit)
        @limit = limit
        @line_lengths = {}
      end

      def apply_to(code, tokens, sexp)
        code.lines.each_with_index do |line, index|
          @line_lengths[index + 1] = line.chomp.length
        end
        self
      end

      def violations
        @line_lengths.select { |line, length| length > @limit }.map do |line, length|
          "Line #{line} is too long: #{length} columns"
        end
      end

      def name
        "Line length (#@limit)"
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
skeptic-0.0.16 lib/skeptic/rules/line_length.rb
skeptic-0.0.15 lib/skeptic/rules/line_length.rb
skeptic-0.0.14 lib/skeptic/rules/line_length.rb
skeptic-0.0.12 lib/skeptic/rules/line_length.rb
skeptic-0.0.11 lib/skeptic/rules/line_length.rb
skeptic-0.0.10 lib/skeptic/rules/line_length.rb
skeptic-0.0.9 lib/skeptic/rules/line_length.rb
skeptic-0.0.8 lib/skeptic/rules/line_length.rb
skeptic-0.0.7 lib/skeptic/rules/line_length.rb
skeptic-0.0.6 lib/skeptic/rules/line_length.rb
skeptic-0.0.5 lib/skeptic/rules/line_length.rb
skeptic-0.0.4 lib/skeptic/rules/line_length.rb
skeptic-0.0.3 lib/skeptic/rules/line_length.rb
skeptic-0.0.2 lib/skeptic/rules/line_length.rb
skeptic-0.0.1 lib/skeptic/rules/line_length.rb