class RailsBestPractices::Lexicals::LongLineCheck
Keep lines fewer than 80 characters.
def check(filename, content)
-
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
def initialize(options = {})
def initialize(options = {}) super(options) @max_line_length = options['max_line_length'] || 80 end