class RailsBestPractices::Lexicals::LongLineCheck

def check(filename, content)

Parameters:
  • content (String) -- content of the file
  • filename (String) -- name of the file
def check(filename, content)
  # Only check ruby files
  if /\.rb$/ =~ filename
    line_no = 0
    content.each_line do |line|
      line_no += 1
      actual_line_length = line.sub(/\s+$/, '').length
      next unless actual_line_length > @max_line_length
      add_error(
        "line is longer than #{@max_line_length} characters (#{actual_line_length} characters)",
        filename,
        line_no
      )
    end
  end
end