Module: Kettle::Soup::Cover::CoverageThresholds
- Defined in:
- lib/kettle/soup/cover/coverage_thresholds.rb
Overview
Applies the selected SimpleCov minimum coverage policy.
Class Method Summary collapse
-
.configure!(configuration) ⇒ Object
-
.configure_minimum!(configuration) ⇒ Object
-
.configure_strict_criteria!(configuration) ⇒ Object
-
.merge_minimum_coverage(existing, minimums) ⇒ Hash{Symbol => Numeric}
Merges minimums into minimums that are already configured.
Class Method Details
.configure!(configuration) ⇒ Object
10 11 12 13 |
# File 'lib/kettle/soup/cover/coverage_thresholds.rb', line 10 def configure!(configuration) configure_strict_criteria!(configuration) configure_minimum!(configuration) if Constants::MIN_COVERAGE_HARD end |
.configure_minimum!(configuration) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/kettle/soup/cover/coverage_thresholds.rb', line 26 def configure_minimum!(configuration) if Constants::MIN_COVERAGE_STRICT configuration.minimum_coverage(line: 100, branch: 100, method: 100) else # SimpleCov's `minimum_coverage(hash)` replaces the whole minimums # Hash, so merge into the minimums already configured (for example # by the project's .simplecov) instead of dropping or lowering them. configuration.minimum_coverage( merge_minimum_coverage( configuration.minimum_coverage, branch: Constants::MIN_COVERAGE_BRANCH, line: Constants::MIN_COVERAGE_LINE ) ) end end |
.configure_strict_criteria!(configuration) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kettle/soup/cover/coverage_thresholds.rb', line 15 def configure_strict_criteria!(configuration) return unless Constants::MIN_COVERAGE_STRICT configuration.enable_coverage(:branch) configuration.enable_coverage(:method) if SimpleCov::Configuration.method_defined?(:coverage_for_eval_supported?) && configuration.coverage_for_eval_supported? configuration.enable_coverage(:eval) end end |
.merge_minimum_coverage(existing, minimums) ⇒ Hash{Symbol => Numeric}
Merges minimums into minimums that are already configured.
For each criterion the higher of the two values wins, so a minimum
the project set itself is never lowered. Criteria only existing
has, such as method coverage, are kept as they are.
54 55 56 57 58 |
# File 'lib/kettle/soup/cover/coverage_thresholds.rb', line 54 def merge_minimum_coverage(existing, minimums) existing.merge(minimums) do |_criterion, current, minimum| [current, minimum].compact.max end end |