Class: Coverband::Utils::FileList
- Inherits:
-
Array
- Object
- Array
- Coverband::Utils::FileList
- Defined in:
- lib/coverband/utils/file_list.rb
Instance Method Summary collapse
-
#covered_lines ⇒ Object
Returns the count of lines that have coverage Using sum avoids intermediate array allocation compared to map.inject.
-
#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.
- #first_seen_at ⇒ Object
-
#formatted_covered_percent ⇒ Float
Computes the coverage based upon lines covered and lines missed, formatted.
-
#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 Using sum avoids intermediate array allocation compared to map.inject
15 16 17 18 19 |
# File 'lib/coverband/utils/file_list.rb', line 15 def covered_lines return 0.0 if empty? @covered_lines ||= sum(&:covered_lines_count) end |
#covered_percent ⇒ Float
Computes the coverage based upon lines covered and lines missed
57 58 59 60 61 |
# File 'lib/coverband/utils/file_list.rb', line 57 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
44 45 46 |
# File 'lib/coverband/utils/file_list.rb', line 44 def covered_percentages map(&:covered_percent) end |
#covered_strength ⇒ Float
Computes the strength (hits / line) based upon lines covered and lines missed
71 72 73 74 75 |
# File 'lib/coverband/utils/file_list.rb', line 71 def covered_strength return 0.0 if empty? || lines_of_code.zero? Float(sum { |f| f.covered_strength * f.lines_of_code } / lines_of_code) end |
#first_seen_at ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/coverband/utils/file_list.rb', line 77 def first_seen_at min = nil each do |f| val = f.first_updated_at next if val.is_a?(String) min = val if min.nil? || val < min end min end |
#formatted_covered_percent ⇒ Float
Computes the coverage based upon lines covered and lines missed, formatted
65 66 67 |
# File 'lib/coverband/utils/file_list.rb', line 65 def formatted_covered_percent covered_percent.round(2) end |
#lines_of_code ⇒ Object
Returns the overall amount of relevant lines of code across all files in this list
49 50 51 52 53 |
# File 'lib/coverband/utils/file_list.rb', line 49 def lines_of_code return 0.0 if empty? @lines_of_code ||= sum(&:lines_of_code) end |
#missed_lines ⇒ Object
Returns the count of lines that have been missed
22 23 24 25 26 |
# File 'lib/coverband/utils/file_list.rb', line 22 def missed_lines return 0.0 if empty? @missed_lines ||= sum(&:missed_lines_count) end |
#never_lines ⇒ Object
Returns the count of lines that are not relevant for coverage
29 30 31 32 33 |
# File 'lib/coverband/utils/file_list.rb', line 29 def never_lines return 0.0 if empty? @never_lines ||= sum(&:never_lines_count) end |
#skipped_lines ⇒ Object
Returns the count of skipped lines
36 37 38 39 40 |
# File 'lib/coverband/utils/file_list.rb', line 36 def skipped_lines return 0.0 if empty? @skipped_lines ||= sum(&:skipped_lines_count) end |