class SimpleCov::FileList
An array of SimpleCov
SourceFile
instances with additional collection helper methods for calculating coverage across them etc.
Public Class Methods
# File lib/simplecov/file_list.rb, line 22 def initialize(files) @files = files end
Public Instance Methods
# File lib/simplecov/file_list.rb, line 97 def branch_covered_percent coverage_statistics[:branch]&.percent end
# File lib/simplecov/file_list.rb, line 26 def coverage_statistics @coverage_statistics ||= compute_coverage_statistics end
Return total count of covered branches
# File lib/simplecov/file_list.rb, line 88 def covered_branches coverage_statistics[:branch]&.covered end
Returns the count of lines that have coverage
# File lib/simplecov/file_list.rb, line 31 def covered_lines coverage_statistics[:line]&.covered end
Computes the coverage based upon lines covered and lines missed @return [Float]
# File lib/simplecov/file_list.rb, line 72 def covered_percent coverage_statistics[:line]&.percent end
Computes the coverage based upon lines covered and lines missed for each file Returns an array with all coverage percentages
# File lib/simplecov/file_list.rb, line 56 def covered_percentages map(&:covered_percent) end
Computes the strength (hits / line) based upon lines covered and lines missed @return [Float]
# File lib/simplecov/file_list.rb, line 78 def covered_strength coverage_statistics[:line]&.strength end
Finds the least covered file and returns that file's name
# File lib/simplecov/file_list.rb, line 61 def least_covered_file min_by(&:covered_percent).filename end
Returns the overall amount of relevant lines of code across all files in this list
# File lib/simplecov/file_list.rb, line 66 def lines_of_code coverage_statistics[:line]&.total end
Return total count of covered branches
# File lib/simplecov/file_list.rb, line 93 def missed_branches coverage_statistics[:branch]&.missed end
Returns the count of lines that have been missed
# File lib/simplecov/file_list.rb, line 36 def missed_lines coverage_statistics[:line]&.missed end
Returns the count of lines that are not relevant for coverage
# File lib/simplecov/file_list.rb, line 41 def never_lines return 0.0 if empty? map { |f| f.never_lines.count }.inject(:+) end
Returns the count of skipped lines
# File lib/simplecov/file_list.rb, line 48 def skipped_lines return 0.0 if empty? map { |f| f.skipped_lines.count }.inject(:+) end
Return total count of branches in all files
# File lib/simplecov/file_list.rb, line 83 def total_branches coverage_statistics[:branch]&.total end
Private Instance Methods
# File lib/simplecov/file_list.rb, line 103 def compute_coverage_statistics total_coverage_statistics = @files.each_with_object(line: [], branch: []) do |file, together| together[:line] << file.coverage_statistics[:line] together[:branch] << file.coverage_statistics[:branch] if SimpleCov.branch_coverage? end coverage_statistics = {line: CoverageStatistics.from(total_coverage_statistics[:line])} coverage_statistics[:branch] = CoverageStatistics.from(total_coverage_statistics[:branch]) if SimpleCov.branch_coverage? coverage_statistics end