Class: SimpleCov::ExitCodes::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/exit_codes/check.rb

Overview

Shared skeleton for the threshold checks. Subclasses supply exit_code, compute_violations (memoized here, since failing? and report_lines both consult it), and violation_lines.

Instance Method Summary collapse

Constructor Details

#initialize(result, thresholds) ⇒ Check

Returns a new instance of Check.



9
10
11
12
# File 'lib/simplecov/exit_codes/check.rb', line 9

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

Instance Method Details

#failing?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/simplecov/exit_codes/check.rb', line 14

def failing?
  violations.any?
end

#reportObject



30
31
32
# File 'lib/simplecov/exit_codes/check.rb', line 30

def report
  report_lines.each { |line| ExitCodes.print_error(line) }
end

#report_linesObject

Concatenated rather than flat-mapped: a check answering a bare string instead of its list of lines is an error this raises, not a spelling the flattening would forgive.



25
26
27
28
# File 'lib/simplecov/exit_codes/check.rb', line 25

def report_lines
  lines = [] #: Array[String]
  violations.each_with_object(lines) { |violation, into| into.concat(violation_lines(violation)) }
end

#violationsObject



18
19
20
# File 'lib/simplecov/exit_codes/check.rb', line 18

def violations
  @violations ||= compute_violations
end