Module: CC::Analyzer::Validator

Included in:
IssueValidator, MeasurementValidator
Defined in:
lib/cc/analyzer/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



4
5
6
# File 'lib/cc/analyzer/validator.rb', line 4

def error
  @error
end

Instance Method Details

#initialize(document) ⇒ Object



6
7
8
9
# File 'lib/cc/analyzer/validator.rb', line 6

def initialize(document)
  @document = document
  validate
end

#validateObject Also known as: valid?



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cc/analyzer/validator.rb', line 11

def validate
  return @valid unless @valid.nil?

  if document && invalid_messages.any?
    @error = {
      message: "#{invalid_messages.join("; ")}: `#{document}`.",
      document: document,
    }
    @valid = false
  else
    @valid = true
  end
end