Class: SimpleCov::ExitCodes::MaximumOverallCoverageCheck
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/simplecov/exit_codes/maximum_overall_coverage_check.rb |
Overview
Fails when the overall (project-wide) coverage for any criterion is
above the configured maximum. Pair with
MinimumOverallCoverageCheck (or use
SimpleCov.expected_coverage) to pin coverage to an exact value
and surface unexpected increases instead of silently absorbing them.
Class Method Summary
Instance Attribute Summary
- #failing? ⇒ Boolean readonly
Instance Method Summary
- #exit_code
- #report
- #report_violation(violation) private
- #violations private
Constructor Details
.new(result, maximum_coverage) ⇒ MaximumOverallCoverageCheck
Instance Attribute Details
#failing? ⇒ Boolean (readonly)
[ GitHub ]
# File 'lib/simplecov/exit_codes/maximum_overall_coverage_check.rb', line 16
def failing? violations.any? end
Instance Method Details
#exit_code
[ GitHub ]# File 'lib/simplecov/exit_codes/maximum_overall_coverage_check.rb', line 24
def exit_code SimpleCov::ExitCodes::MAXIMUM_COVERAGE end
#report
[ GitHub ]# File 'lib/simplecov/exit_codes/maximum_overall_coverage_check.rb', line 20
def report violations.each { |violation| report_violation(violation) } end
#report_violation(violation) (private)
[ GitHub ]# File 'lib/simplecov/exit_codes/maximum_overall_coverage_check.rb', line 34
def report_violation(violation) warn format( "%<criterion>s coverage (%<actual>s) is above the expected maximum coverage (%<expected>.2f%%). " \ "Time to bump the threshold!", criterion: violation.fetch(:criterion).capitalize, actual: SimpleCov::Color.colorize_percent(violation.fetch(:actual)), expected: violation.fetch(:expected) ) end
#violations (private)
[ GitHub ]# File 'lib/simplecov/exit_codes/maximum_overall_coverage_check.rb', line 30
def violations @violations ||= SimpleCov::CoverageViolations.maximum_overall(@result, @maximum_coverage) end