123456789_123456789_123456789_123456789_123456789_

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

Instance Method Summary

Constructor Details

.new(result, maximum_coverage_drop) ⇒ MaximumCoverageDropCheck

[ GitHub ]

  
# File 'lib/simplecov/exit_codes/maximum_coverage_drop_check.rb', line 8

def initialize(result, maximum_coverage_drop)
  @result = result
  @maximum_coverage_drop = maximum_coverage_drop
end

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 29

def exit_code
  SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP
end

#report

[ GitHub ]

  
# File 'lib/simplecov/exit_codes/maximum_coverage_drop_check.rb', line 17

def report
  violations.each do |violation|
    $stderr.printf(
      "%<criterion>s coverage has dropped by %<drop_percent>.2f%% since the last time " \
      "(maximum allowed: %<max_drop>.2f%%).\n",
      criterion: violation.fetch(:criterion).capitalize,
      drop_percent: violation.fetch(:actual),
      max_drop: violation.fetch(:maximum)
    )
  end
end

#violations (private)

[ GitHub ]

  
# File 'lib/simplecov/exit_codes/maximum_coverage_drop_check.rb', line 35

def violations
  @violations ||= SimpleCov::CoverageViolations.maximum_drop(@result, @maximum_coverage_drop)
end