Class: SimpleCov::FileList
- Inherits:
-
Array
- Object
- Array
- SimpleCov::FileList
- Defined in:
- lib/simplecov/file_list.rb
Instance Method Summary collapse
-
#covered_lines ⇒ Object
Returns the count of lines that have coverage.
-
#covered_percent ⇒ Float
Computes the coverage based upon lines covered and lines missed.
-
#covered_percentages ⇒ Object
Computes the coverage based upon lines covered and lines missed for each file Returns an array with all coverage percentages.
-
#covered_strength ⇒ Float
Computes the strength (hits / line) based upon lines covered and lines missed.
-
#least_covered_file ⇒ Object
Finds the least covered file and returns that file’s name.
-
#lines_of_code ⇒ Object
Returns the overall amount of relevant lines of code across all files in this list.
-
#missed_lines ⇒ Object
Returns the count of lines that have been missed.
-
#never_lines ⇒ Object
Returns the count of lines that are not relevant for coverage.
-
#skipped_lines ⇒ Object
Returns the count of skipped lines.
Instance Method Details
#covered_lines ⇒ Object
Returns the count of lines that have coverage
6 7 8 9 |
# File 'lib/simplecov/file_list.rb', line 6 def covered_lines return 0.0 if empty? map { |f| f.covered_lines.count }.inject(&:+) end |
#covered_percent ⇒ Float
Computes the coverage based upon lines covered and lines missed
47 48 49 50 |
# File 'lib/simplecov/file_list.rb', line 47 def covered_percent return 100.0 if empty? || lines_of_code.zero? Float(covered_lines * 100.0 / lines_of_code) end |
#covered_percentages ⇒ Object
Computes the coverage based upon lines covered and lines missed for each file Returns an array with all coverage percentages
31 32 33 |
# File 'lib/simplecov/file_list.rb', line 31 def covered_percentages map(&:covered_percent) end |
#covered_strength ⇒ Float
Computes the strength (hits / line) based upon lines covered and lines missed
54 55 56 57 |
# File 'lib/simplecov/file_list.rb', line 54 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_file ⇒ Object
Finds the least covered file and returns that file’s name
36 37 38 |
# File 'lib/simplecov/file_list.rb', line 36 def least_covered_file sort_by(&:covered_percent).first.filename end |
#lines_of_code ⇒ Object
Returns the overall amount of relevant lines of code across all files in this list
41 42 43 |
# File 'lib/simplecov/file_list.rb', line 41 def lines_of_code covered_lines + missed_lines end |
#missed_lines ⇒ Object
Returns the count of lines that have been missed
12 13 14 15 |
# File 'lib/simplecov/file_list.rb', line 12 def missed_lines return 0.0 if empty? map { |f| f.missed_lines.count }.inject(&:+) end |
#never_lines ⇒ Object
Returns the count of lines that are not relevant for coverage
18 19 20 21 |
# File 'lib/simplecov/file_list.rb', line 18 def never_lines return 0.0 if empty? map { |f| f.never_lines.count }.inject(&:+) end |
#skipped_lines ⇒ Object
Returns the count of skipped lines
24 25 26 27 |
# File 'lib/simplecov/file_list.rb', line 24 def skipped_lines return 0.0 if empty? map { |f| f.skipped_lines.count }.inject(&:+) end |