Class: SimpleCov::FileList

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

Overview

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

Instance Method Summary collapse

Instance Method Details

#covered_linesObject

Returns the count of lines that have coverage


5
6
7
8
# File 'lib/simplecov/file_list.rb', line 5

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)

35
36
37
38
# File 'lib/simplecov/file_list.rb', line 35

def covered_percent
  return 100.0 if empty? or lines_of_code == 0
  Float(covered_lines * 100.0 / lines_of_code)
end

#covered_strengthFloat

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

Returns:

  • (Float)

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

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

#lines_of_codeObject

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


29
30
31
# File 'lib/simplecov/file_list.rb', line 29

def lines_of_code
  covered_lines + missed_lines
end

#missed_linesObject

Returns the count of lines that have been missed


11
12
13
14
# File 'lib/simplecov/file_list.rb', line 11

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


17
18
19
20
# File 'lib/simplecov/file_list.rb', line 17

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

#skipped_linesObject

Returns the count of skipped lines


23
24
25
26
# File 'lib/simplecov/file_list.rb', line 23

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