Class: OKF::Bundle::Linter::Report
- Inherits:
-
Object
- Object
- OKF::Bundle::Linter::Report
- 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
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
- #add_info(check, path, message, metric: nil) ⇒ Object
- #add_warning(check, path, message, metric: nil) ⇒ Object
- #healthy? ⇒ Boolean
- #info ⇒ Object
-
#initialize ⇒ Report
constructor
A new instance of Report.
- #stat(key, value) ⇒ Object
- #to_h ⇒ Object
- #warnings ⇒ Object
Constructor Details
#initialize ⇒ Report
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
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
13 14 15 |
# File 'lib/okf/bundle/linter/report.rb', line 13 def findings @findings end |
#stats ⇒ Object (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, , metric: nil) @findings << finding(:info, check, path, , 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, , metric: nil) @findings << finding(:warn, check, path, , metric) end |
#healthy? ⇒ Boolean
36 37 38 |
# File 'lib/okf/bundle/linter/report.rb', line 36 def healthy? warnings.empty? end |
#info ⇒ Object
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_h ⇒ Object
44 45 46 |
# File 'lib/okf/bundle/linter/report.rb', line 44 def to_h { healthy: healthy?, stats: stats, findings: findings } end |
#warnings ⇒ Object
28 29 30 |
# File 'lib/okf/bundle/linter/report.rb', line 28 def warnings findings.select { |f| f[:severity] == :warn } end |