class Rubocop::Cop::Style::LineLength

This cop checks the length of lines in the source code. The maximum length is configurable.

Constants

MSG

Public Class Methods

max() click to toggle source
# File lib/rubocop/cop/style/line_length.rb, line 24
def self.max
  LineLength.config['Max']
end

Public Instance Methods

inspect(source_buffer, source, tokens, ast, comments) click to toggle source
# File lib/rubocop/cop/style/line_length.rb, line 11
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