<commit_before>class Wool::GenericLineLengthWarning < Wool::LineWarning
  def self.line_length_limit
    @line_length_limit ||= 80000
  end
  def self.line_length_limit=(val)
    @line_length_limit = val
  end
  class << self
    attr_accessor :severity
  end

  def self.match?(line, context, settings = {})
    !!(line.size > self.line_length_limit)
  end

  def initialize(file, line)
    super('Line too long', file, line, 0, self.class.severity)
  end

  def fix(content_stack = nil)
    self.line
  end

  def desc
    "Line length: #{line.size} > #{self.class.line_length_limit} (max)"
  end
end

module Wool
  def LineLengthCustomSeverity(size, severity)
    new_warning = Class.new(Wool::GenericLineLengthWarning)
    new_warning.line_length_limit = size
    new_warning.severity = severity
    new_warning
  end

  def LineLengthMaximum(size)
    LineLengthCustomSeverity(size, 8)
  end
<commit_msg>Added fix logic for long comments on a line by themselves<commit_after>class Wool::GenericLineLengthWarning < Wool::LineWarning
  def self.line_length_limit
    @line_length_limit ||= 80000
  end
  def self.line_length_limit=(val)
    @line_length_limit = val
  end
  class << self
    attr_accessor :severity
  end

  def self.match?(line, context, settings = {})
    !!(line.size > self.line_length_limit)
  end

  def initialize(file, line)
    super('Line too long', file, line, 0, self.class.severity)
  end

  def fix(content_stack = nil)
    return result if result = fix_long_comment(self.line)
    self.line
  end
  
  def fix_long_comment(text)
    # Must have no leading text
    return text unless text =~ /^(\s+)\#\s*(.*)\Z/
    indent, comment = $1.size, $2
    # The "+ 2" is (indent)#(single space)
    space_for_text_per_line = self.class.line_length_limit - (indent.size + 2)
    lines = ['']
    words = comment.split(/\s/)
    quota = space_for_text_per_line
    current_line = 0
    while words.any?
      word = word.shift
      # break on word big enough to make a new line, unless its the first word
      if quota - (word.size + 1) < 0 && quota < space_for_text_per_line
        current_line += 1
        lines << ''
      end
      lines[current_line] << ' ' if lines[current_line].any?
      lines[current_line] << word
    end
    lines.map { |line| (" " * indent + '# ' + line }.join("\n")
  end
  
  def desc
    "Line length: #{line.size} > #{self.class.line_length_limit} (max)"
  end
end

module Wool
  def LineLengthCustomSeverity(size, severity)
    new_warning = Class.new(Wool::GenericLineLengthWarning)
    new_warning.line_length_limit = size
    new_warning.severity = severity
    new_warning
  end

  def LineLengthMaximum(size)
    LineLengthCustomSeverity(size, 8)
  end

{'fraction_non_alphanumeric': 0.10756240822320118, 'fraction_numerical': 0.008076358296622614, 'mean_word_length': 3.3117088607594938, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5878211', 'n_tokens_mistral': 953, 'n_tokens_neox': 908, 'n_words': 225}