Class: SimpleCov::ExitCodes::MaximumCoverageDropCheck
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/simplecov/exit_codes/maximum_coverage_drop_check.rb |
Overview
Fails when any coverage criterion has dropped by more than the configured maximum since the last recorded run.
Class Method Summary
Instance Attribute Summary
- #failing? ⇒ Boolean readonly
Instance Method Summary
- #exit_code
- #report
-
#message_for(violation)
private
The "drop percent" is a delta, not a coverage level — it has no natural green/yellow/red mapping.
- #violations private
Constructor Details
.new(result, maximum_coverage_drop) ⇒ MaximumCoverageDropCheck
Instance Attribute Details
#failing? ⇒ Boolean (readonly)
[ GitHub ]
# File 'lib/simplecov/exit_codes/maximum_coverage_drop_check.rb', line 13
def failing? violations.any? end
Instance Method Details
#exit_code
[ GitHub ]# File 'lib/simplecov/exit_codes/maximum_coverage_drop_check.rb', line 21
def exit_code SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP end
#message_for(violation) (private)
The "drop percent" is a delta, not a coverage level — it has no natural green/yellow/red mapping. Callers color the whole line red so the failure is still visible at a glance.
# File 'lib/simplecov/exit_codes/maximum_coverage_drop_check.rb', line 30
def (violation) format( "%<criterion>s coverage has dropped by %<drop_percent>.2f%% since the last time " \ "(maximum allowed: %<max_drop>.2f%%).", criterion: violation.fetch(:criterion).capitalize, drop_percent: violation.fetch(:actual), max_drop: violation.fetch(:maximum) ) end
#report
[ GitHub ]# File 'lib/simplecov/exit_codes/maximum_coverage_drop_check.rb', line 17
def report violations.each { |violation| warn SimpleCov::Color.colorize((violation), :red) } end
#violations (private)
[ GitHub ]# File 'lib/simplecov/exit_codes/maximum_coverage_drop_check.rb', line 40
def violations @violations ||= SimpleCov::CoverageViolations.maximum_drop(@result, @maximum_coverage_drop) end