Sha256: 4fb40e62881c179eeb52254bc9aaca412d107e7beccc7512988d1cbbbb7d1469
Contents?: true
Size: 614 Bytes
Versions: 2
Compression:
Stored size: 614 Bytes
Contents
class Splam::Rules::LineLength < Splam::Rule def name "Line length" end # Penalize long line lengths. def run lines = @body.split("\n") lines.each do |line| next if line =~ /\A\s{4,}/ # ignore code blocks multiplier = (lines.size == 1) ? 10 : 1 # one line? fail. # 1 point for each 40 chars in a line. hits = (line.size / 40) * multiplier add_score hits, "lines over 40 chars" # 2 more points if line is longer than 80 hits = (line.size / 80) * 2 * multiplier add_score hits, "lines over 80 chars" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
splam-0.1.1 | lib/splam/rules/line_length.rb |
splam-0.1.0 | lib/splam/rules/line_length.rb |