Sha256: 95390dc21f0921971bde9b27bcb06741388f1bf7f46727971fe63dd5764f6f38

Contents?: true

Size: 921 Bytes

Versions: 5

Compression:

Stored size: 921 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
        include ConfigurableMax

        MSG = 'Line is too long. [%d/%d]'

        def investigate(processed_source)
          processed_source.lines.each_with_index do |line, index|
            if line.length > max
              message = format(MSG, line.length, max)
              add_offense(nil,
                          source_range(processed_source.buffer,
                                       processed_source[0...index], max,
                                       line.length - max),
                          message) do
                self.max = line.length
              end
            end
          end
        end

        def max
          cop_config['Max']
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.21.0 lib/rubocop/cop/style/line_length.rb
rubocop-0.20.1 lib/rubocop/cop/style/line_length.rb
rubocop-0.20.0 lib/rubocop/cop/style/line_length.rb
rubocop-0.19.1 lib/rubocop/cop/style/line_length.rb
rubocop-0.19.0 lib/rubocop/cop/style/line_length.rb