Sha256: 56093a5a4a237661832e411903c9f0931188e12d710a5444071600cdc9b2a278

Contents?: true

Size: 993 Bytes

Versions: 2

Compression:

Stored size: 993 Bytes

Contents

require_relative '../ruler'

class Tailor
  module Rulers
    class MaxLineLengthRuler < Tailor::Ruler
      def ignored_nl_update(lexed_line, lineno, column)
        log "<#{self.class}> Line length: #{lexed_line.line_length}"
        measure(lexed_line, lineno, column)
      end

      def nl_update(lexed_line, lineno, column)
        ignored_nl_update(lexed_line, lineno, column)
      end

      # Checks to see if the line has more characters that given at +@config+.
      #
      # @param [Fixnum] lexed_line The line to measure.
      # @param [Fixnum] lineno Line the potential problem is on.
      # @param [Fixnum] column Column the potential problem is on
      def measure(lexed_line, lineno, column)
        if lexed_line.line_length > @config
          options = {
            actual_length: lexed_line.line_length,
            should_be_at: @config
          }
          @problems << Problem.new(:line_length, lineno, column, options)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tailor-1.0.0.alpha2 lib/tailor/rulers/max_line_length_ruler.rb
tailor-1.0.0.alpha lib/tailor/rulers/max_line_length_ruler.rb