Module: SimpleCov::CoverageViolations
- Defined in:
- lib/simplecov/coverage_violations.rb
Class Method Summary collapse
-
.baseline(result, baseline) ⇒ Object
A baseline violation needs the file below its floor on both axes: a percent under the floor's, and (when the floor records one) more misses than it allows.
- .maximum_drop(result, thresholds, last_run: nil, mode: SimpleCov.drop_baseline) ⇒ Object
- .maximum_missed(result, caps) ⇒ Object
- .maximum_missed_by_file(result, defaults, overrides = {}, baseline: nil) ⇒ Object
-
.maximum_overall(result, thresholds) ⇒ Object
An actual of 95.4287 floors to 95.42, so a maximum of 95.42 passes (#187).
-
.minimum_by_file(result, defaults, overrides = {}, baseline: nil) ⇒ Object
A file and criterion with a
baselinefloor is exempt here: the baseline check holds it to its own floor instead, which is the fall-through the ratchet workflow rests on (#1268). - .minimum_by_group(result, thresholds) ⇒ Object
- .minimum_overall(result, thresholds) ⇒ Object
Class Method Details
.baseline(result, baseline) ⇒ Object
A baseline violation needs the file below its floor on both axes: a percent under the floor's, and (when the floor records one) more misses than it allows. The missed count is what keeps percent movement from pure edits out of the answer.
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/simplecov/coverage_violations.rb', line 40 def baseline(result, baseline) return [] unless baseline result.files.flat_map do |file| entry = baseline.entry_for(file.project_filename) next [] unless entry entry.filter_map { |criterion, floor| baseline_violation(file, criterion, floor) } end end |
.maximum_drop(result, thresholds, last_run: nil, mode: SimpleCov.drop_baseline) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/simplecov/coverage_violations.rb', line 77 def maximum_drop(result, thresholds, last_run: nil, mode: SimpleCov.drop_baseline) baseline = drop_baseline_percents(mode, last_run) return [] unless baseline thresholds.filter_map do |criterion, maximum| actual = compute_drop(criterion, result, baseline) {criterion: criterion, maximum: maximum, actual: actual} if actual && actual > maximum end end |
.maximum_missed(result, caps) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/simplecov/coverage_violations.rb', line 51 def maximum_missed(result, caps) caps.filter_map do |criterion, maximum| actual = missed_for(result, criterion) or next {criterion: criterion, maximum: maximum, actual: actual} if actual > maximum end end |
.maximum_missed_by_file(result, defaults, overrides = {}, baseline: nil) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/simplecov/coverage_violations.rb', line 58 def maximum_missed_by_file(result, defaults, overrides = {}, baseline: nil) result.files.flat_map do |file| effective = effective_per_file_thresholds(file, defaults, overrides) effective.filter_map do |criterion, maximum| next if baseline&.covers?(file.project_filename, criterion) file_missed_cap_violation(file, criterion, maximum) end end end |
.maximum_overall(result, thresholds) ⇒ Object
An actual of 95.4287 floors to 95.42, so a maximum of 95.42 passes (#187).
15 16 17 18 19 20 |
# File 'lib/simplecov/coverage_violations.rb', line 15 def maximum_overall(result, thresholds) thresholds.filter_map do |criterion, expected| actual = floored_percent_for(result, criterion) or next {criterion: criterion, expected: expected, actual: actual} if actual > expected end end |
.minimum_by_file(result, defaults, overrides = {}, baseline: nil) ⇒ Object
A file and criterion with a baseline floor is exempt here: the baseline
check holds it to its own floor instead, which is the fall-through the
ratchet workflow rests on (#1268).
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/simplecov/coverage_violations.rb', line 25 def minimum_by_file(result, defaults, overrides = {}, baseline: nil) result.files.flat_map do |file| effective = effective_per_file_thresholds(file, defaults, overrides) effective.filter_map do |criterion, expected| next if baseline&.covers?(file.project_filename, criterion) file_minimum_violation(file, criterion, expected) end end end |
.minimum_by_group(result, thresholds) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/simplecov/coverage_violations.rb', line 69 def minimum_by_group(result, thresholds) thresholds.flat_map do |group_name, minimums| group = lookup_group(result, group_name) none = [] # : Array[Hash[Symbol, untyped]] group ? group_minimum_violations(group_name, group, minimums) : none end end |
.minimum_overall(result, thresholds) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/simplecov/coverage_violations.rb', line 6 def minimum_overall(result, thresholds) thresholds.filter_map do |criterion, expected| actual = floored_percent_for(result, criterion) or next {criterion: criterion, expected: expected, actual: actual} if actual < expected end end |