Sha256: cd561971ebdab46718886c9ad1f710d679264135c88c573ceabc94851541fdab

Contents?: true

Size: 831 Bytes

Versions: 3

Compression:

Stored size: 831 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop checks the length of lines in the source code.
      # The maximum length is configurable.
      class LineLength < Cop
        MSG = 'Line is too long. [%d/%d]'

        def inspect(source_buffer, source, tokens, ast, comments)
          source.each_with_index do |line, index|
            max = LineLength.max
            if line.length > max
              message = sprintf(MSG, line.length, max)
              add_offence(:convention,
                          source_range(source_buffer, source[0...index], max,
                                       line.length - max),
                          message)
            end
          end
        end

        def self.max
          LineLength.config['Max']
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rubocop-0.9.1 lib/rubocop/cop/style/line_length.rb
sabat-rubocop-0.9.0 lib/rubocop/cop/style/line_length.rb
rubocop-0.9.0 lib/rubocop/cop/style/line_length.rb