Sha256: 746aa55a8cd71c81f23dd7d72e56e36f9d16da532f46fe572443d51b441f1689
Contents?: true
Size: 963 Bytes
Versions: 9
Compression:
Stored size: 963 Bytes
Contents
# encoding: utf-8 require 'rails_best_practices/core/check' module RailsBestPractices module Lexicals # Keep lines fewer than 80 characters. class LongLineCheck < Core::Check def initialize(options = {}) super() @max_line_length = options['max_line_length'] || 80 end # check if a line is over 80 characters # # @param [String] filename name of the file # @param [String] content content 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 if 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 end end end end
Version data entries
9 entries across 9 versions & 1 rubygems