class SimpleCov::FileList

methods for calculating coverage across them etc.
An array of SimpleCov SourceFile instances with additional collection helper

def branch_covered_percent

def branch_covered_percent
  coverage_statistics[:branch]&.percent
end

def compute_coverage_statistics

def compute_coverage_statistics
  coverage_statistics = {line: CoverageStatistics.from(coverage_statistics_by_file[:line])}
  coverage_statistics[:branch] = CoverageStatistics.from(coverage_statistics_by_file[:branch]) if SimpleCov.branch_coverage?
  coverage_statistics
end

def compute_coverage_statistics_by_file

def compute_coverage_statistics_by_file
  @files.each_with_object(line: [], branch: []) do |file, together|
    together[:line] << file.coverage_statistics.fetch(:line)
    together[:branch] << file.coverage_statistics.fetch(:branch) if SimpleCov.branch_coverage?
  end
end

def coverage_statistics

def coverage_statistics
  @coverage_statistics ||= compute_coverage_statistics
end

def coverage_statistics_by_file

def coverage_statistics_by_file
  @coverage_statistics_by_file ||= compute_coverage_statistics_by_file
end

def covered_branches

Return total count of covered branches
def covered_branches
  coverage_statistics[:branch]&.covered
end

def covered_lines

Returns the count of lines that have coverage
def covered_lines
  coverage_statistics[:line]&.covered
end

def covered_percent

Returns:
  • (Float) -
def covered_percent
  coverage_statistics[:line]&.percent
end

def covered_percentages

Returns an array with all coverage percentages
Computes the coverage based upon lines covered and lines missed for each file
def covered_percentages
  map(&:covered_percent)
end

def covered_strength

Returns:
  • (Float) -
def covered_strength
  coverage_statistics[:line]&.strength
end

def initialize(files)

def initialize(files)
  @files = files
end

def least_covered_file

Finds the least covered file and returns that file's name
def least_covered_file
  min_by(&:covered_percent).filename
end

def lines_of_code

Returns the overall amount of relevant lines of code across all files in this list
def lines_of_code
  coverage_statistics[:line]&.total
end

def missed_branches

Return total count of covered branches
def missed_branches
  coverage_statistics[:branch]&.missed
end

def missed_lines

Returns the count of lines that have been missed
def missed_lines
  coverage_statistics[:line]&.missed
end

def never_lines

Returns the count of lines that are not relevant for coverage
def never_lines
  return 0.0 if empty?
  map { |f| f.never_lines.count }.inject(:+)
end

def skipped_lines

Returns the count of skipped lines
def skipped_lines
  return 0.0 if empty?
  map { |f| f.skipped_lines.count }.inject(:+)
end

def total_branches

Return total count of branches in all files
def total_branches
  coverage_statistics[:branch]&.total
end