Class: OKF::Bundle::Linter::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/okf/bundle/linter/report.rb

Overview

The result of linting a bundle for curation quality (see OKF::Bundle::Linter). Mirrors OKF::Bundle::Validator::Result, but lint has no errors — only :warn and :info findings — and carries free-form stats in place of conformance counts. A bundle is "healthy" when it has no :warn findings; :info never makes it unhealthy. Every finding is a self-describing Hash so #to_h is a stable machine substrate an agent can act on.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReport

Returns a new instance of Report.



15
16
17
18
# File 'lib/okf/bundle/linter/report.rb', line 15

def initialize
  @findings = []
  @stats = {}
end

Instance Attribute Details

#findingsObject (readonly)

Returns the value of attribute findings.



13
14
15
# File 'lib/okf/bundle/linter/report.rb', line 13

def findings
  @findings
end

#statsObject (readonly)

Returns the value of attribute stats.



13
14
15
# File 'lib/okf/bundle/linter/report.rb', line 13

def stats
  @stats
end

Instance Method Details

#add_info(check, path, message, metric: nil) ⇒ Object



24
25
26
# File 'lib/okf/bundle/linter/report.rb', line 24

def add_info(check, path, message, metric: nil)
  @findings << finding(:info, check, path, message, metric)
end

#add_warning(check, path, message, metric: nil) ⇒ Object



20
21
22
# File 'lib/okf/bundle/linter/report.rb', line 20

def add_warning(check, path, message, metric: nil)
  @findings << finding(:warn, check, path, message, metric)
end

#healthy?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/okf/bundle/linter/report.rb', line 36

def healthy?
  warnings.empty?
end

#infoObject



32
33
34
# File 'lib/okf/bundle/linter/report.rb', line 32

def info
  findings.select { |f| f[:severity] == :info }
end

#stat(key, value) ⇒ Object



40
41
42
# File 'lib/okf/bundle/linter/report.rb', line 40

def stat(key, value)
  @stats[key] = value
end

#to_hObject



44
45
46
# File 'lib/okf/bundle/linter/report.rb', line 44

def to_h
  { healthy: healthy?, stats: stats, findings: findings }
end

#warningsObject



28
29
30
# File 'lib/okf/bundle/linter/report.rb', line 28

def warnings
  findings.select { |f| f[:severity] == :warn }
end