Class: SimpleCov::FileList

Inherits:
Array
  • Object
show all
Defined in:
lib/simplecov/file_list.rb

Instance Method Summary collapse

Instance Method Details

#covered_linesObject

Returns the count of lines that have coverage



8
9
10
11
# File 'lib/simplecov/file_list.rb', line 8

def covered_lines
  return 0.0 if empty?
  map { |f| f.covered_lines.count }.inject(:+)
end

#covered_percentFloat

Computes the coverage based upon lines covered and lines missed

Returns:

  • (Float)


49
50
51
52
# File 'lib/simplecov/file_list.rb', line 49

def covered_percent
  return 100.0 if empty? || lines_of_code.zero?
  Float(covered_lines * 100.0 / lines_of_code)
end

#covered_percentagesObject

Computes the coverage based upon lines covered and lines missed for each file Returns an array with all coverage percentages



33
34
35
# File 'lib/simplecov/file_list.rb', line 33

def covered_percentages
  map(&:covered_percent)
end

#covered_strengthFloat

Computes the strength (hits / line) based upon lines covered and lines missed

Returns:

  • (Float)


56
57
58
59
# File 'lib/simplecov/file_list.rb', line 56

def covered_strength
  return 0.0 if empty? || lines_of_code.zero?
  Float(map { |f| f.covered_strength * f.lines_of_code }.inject(:+) / lines_of_code)
end

#least_covered_fileObject

Finds the least covered file and returns that file’s name



38
39
40
# File 'lib/simplecov/file_list.rb', line 38

def least_covered_file
  sort_by(&:covered_percent).first.filename
end

#lines_of_codeObject

Returns the overall amount of relevant lines of code across all files in this list



43
44
45
# File 'lib/simplecov/file_list.rb', line 43

def lines_of_code
  covered_lines + missed_lines
end

#missed_linesObject

Returns the count of lines that have been missed



14
15
16
17
# File 'lib/simplecov/file_list.rb', line 14

def missed_lines
  return 0.0 if empty?
  map { |f| f.missed_lines.count }.inject(:+)
end

#never_linesObject

Returns the count of lines that are not relevant for coverage



20
21
22
23
# File 'lib/simplecov/file_list.rb', line 20

def never_lines
  return 0.0 if empty?
  map { |f| f.never_lines.count }.inject(:+)
end

#skipped_linesObject

Returns the count of skipped lines



26
27
28
29
# File 'lib/simplecov/file_list.rb', line 26

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