<commit_before>class Modifier
  attr_accessor :description, :title, :modifier, :function

  def initialize(title, description, modifier, function)
    @title = title
    @description = description
    @modifier = modifier
    @function = function
  end

  def to_json(hash, pod_stats)
    {
      "title" => title,
      "description" => description,
      "modifier" => modifier,
      "applies_for_pod" => function.call(hash, pod_stats)
    }
  end

end

class QualityModifiers

  def generate hash, github_stats
    modify_value = 50
    modifiers.each do |modifier|
      modify_value += modifier.function.call(hash, github_stats) ? modifier.modifier : 0
    end
    modify_value
  end

  def modifiers
    [
      Modifier.new("Test Expectations / Line of Code", 
                    "Testing a library shows that the developers care about long term quality on a project as internalized logic is made explicit via testing.", -20, Proc.new { |hash, stats|
        0.045 < hash[:total_test_expectations].to_i / hash[:total_lines_of_code].to_i
      }),

      Modifier.new("Download size", "Too big of a library can impact startup time, and add redundant assets.", -10, Proc.new { |hash, stats|
        hash[:download_size].to_i > 10000
      }),

      Modifier.new("Lines of Code / File", "Smaller, more composeable classes tend to be easier to understand.", -8, Proc.new { |hash, stats|
        hash[:total_lines_of_code].to_i / hash[:total_files].to_i > 250
      }),

      Modifier.new("Great Documentation", "A full suite of documentation makes it easier to use a library.", 3, Proc.new { |hash, stats|
        hash[:doc_percent].to_i > 90
      }),
<commit_msg>Add protection against divide by zeroes<commit_after>class Modifier
  attr_accessor :description, :title, :modifier, :function

  def initialize(title, description, modifier, function)
    @title = title
    @description = description
    @modifier = modifier
    @function = function
  end

  def to_json(hash, pod_stats)
    {
      "title" => title,
      "description" => description,
      "modifier" => modifier,
      "applies_for_pod" => function.call(hash, pod_stats)
    }
  end

end

class QualityModifiers

  def generate hash, github_stats
    modify_value = 50
    modifiers.each do |modifier|
      modify_value += modifier.function.call(hash, github_stats) ? modifier.modifier : 0
    end
    modify_value
  end

  def modifiers
    [
      Modifier.new("Test Expectations / Line of Code",
                    "Testing a library shows that the developers care about long term quality on a project as internalized logic is made explicit via testing.", -20, Proc.new { |hash, stats|
        lines = hash[:total_lines_of_code].to_i
        if lines
          0.045 < hash[:total_test_expectations].to_i / lines
        else
          false
        end
      }),

      Modifier.new("Download size", "Too big of a library can impact startup time, and add redundant assets.", -10, Proc.new { |hash, stats|
        hash[:download_size].to_i > 10000
      }),

      Modifier.new("Lines of Code / File", "Smaller, more composeable classes tend to be easier to understand.", -8, Proc.new { |hash, stats|
        files = hash[:total_files].to_i
        if files
          hash[:total_lines_of_code].to_i / hash[:total_files].to_i > 250
        else
          false
        end        
      }),

      Modifier.new("Great Documentation", "A full suite of documentation makes it easier to use a library.", 3, Proc.new { |hash, stats|
        hash[:doc_percent].to_i > 90
      }),

{'fraction_non_alphanumeric': 0.10115200899128969, 'fraction_numerical': 0.012924978926664794, 'mean_word_length': 2.7552742616033754, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4852254', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1027, 'n_words': 325}