<commit_before>module CoverUp
  # This tracks overall coverage results for a run
  class Result
    attr_accessor :files

    # This initializes the result with the individual file results
    def initialize(files)
      self.files = files
    end
    
    # This returns the total amount of lines in this coverage report
    def lines
      sum = 0
      self.files.collect { |f| f.lines }.each { |i| sum += i }
      sum
    end
    
    # This calculates the overall hit percentage for the run
    def hit_percentage
      hit = self.files.collect { |f| f.hit }.flatten
      (hit.length.to_f / self.lines.to_f) * 100.0
    end
    
    # This calculates the overall miss percentage for the run
    def missed_percentage<commit_msg>handle zero lines for a run<commit_after>module CoverUp
  # This tracks overall coverage results for a run
  class Result
    attr_accessor :files

    # This initializes the result with the individual file results
    def initialize(files)
      self.files = files
    end
    
    # This returns the total amount of lines in this coverage report
    def lines
      sum = 0
      self.files.collect { |f| f.lines }.each { |i| sum += i }
      sum
    end
    
    # This calculates the overall hit percentage for the run
    def hit_percentage
      return 0 if self.lines.to_f == 0.0
      hit = self.files.collect { |f| f.hit }.flatten
      (hit.length.to_f / self.lines.to_f) * 100.0
    end
    
    # This calculates the overall miss percentage for the run
    def missed_percentage
      return 0 if self.lines.to_f == 0.0
{'fraction_non_alphanumeric': 0.06513409961685823, 'fraction_numerical': 0.010217113665389528, 'mean_word_length': 2.3482905982905984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5766433', 'n_tokens_mistral': 472, 'n_tokens_neox': 453, 'n_words': 180}