Class: Moult::HealthReport
- Inherits:
-
Object
- Object
- Moult::HealthReport
- Defined in:
- lib/moult/health_report.rb
Overview
The serialized result model for moult health (schema/health.schema.json),
sibling to DuplicationReport, DeadCodeReport and CoverageReport. It owns
its own JSON envelope and leaves the other protected contracts untouched.
The composite is a confidence-graded health SIGNAL, never a verdict: it records every contributing component (and every skipped/errored one) plus the reasons behind each sub-score, so the headline number is auditable. Nothing here asserts a pass/fail — that gate is Phase 4.
Defined Under Namespace
Classes: ComponentView, FileView
Constant Summary collapse
- SCHEMA_VERSION =
Bump only on a breaking change to the serialized shape.
1
Instance Attribute Summary collapse
-
#churn_since ⇒ Object
readonly
Returns the value of attribute churn_since.
-
#churn_window ⇒ Object
readonly
Returns the value of attribute churn_window.
-
#components ⇒ Object
readonly
Returns the value of attribute components.
-
#coverage_source ⇒ Object
readonly
Returns the value of attribute coverage_source.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#generated_at ⇒ Object
readonly
Returns the value of attribute generated_at.
-
#git_ref ⇒ Object
readonly
Returns the value of attribute git_ref.
-
#grade ⇒ Object
readonly
Returns the value of attribute grade.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
-
#initialize(root:, score:, grade:, components:, files:, git_ref: nil, generated_at: nil, coverage_source: nil, churn_window: nil, churn_since: nil) ⇒ HealthReport
constructor
A new instance of HealthReport.
- #to_h ⇒ Object
Constructor Details
#initialize(root:, score:, grade:, components:, files:, git_ref: nil, generated_at: nil, coverage_source: nil, churn_window: nil, churn_since: nil) ⇒ HealthReport
Returns a new instance of HealthReport.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/moult/health_report.rb', line 60 def initialize(root:, score:, grade:, components:, files:, git_ref: nil, generated_at: nil, coverage_source: nil, churn_window: nil, churn_since: nil) @root = root @score = score @grade = grade @components = components @files = files @git_ref = git_ref @generated_at = generated_at @coverage_source = coverage_source @churn_window = churn_window @churn_since = churn_since end |
Instance Attribute Details
#churn_since ⇒ Object (readonly)
Returns the value of attribute churn_since.
51 52 53 |
# File 'lib/moult/health_report.rb', line 51 def churn_since @churn_since end |
#churn_window ⇒ Object (readonly)
Returns the value of attribute churn_window.
51 52 53 |
# File 'lib/moult/health_report.rb', line 51 def churn_window @churn_window end |
#components ⇒ Object (readonly)
Returns the value of attribute components.
51 52 53 |
# File 'lib/moult/health_report.rb', line 51 def components @components end |
#coverage_source ⇒ Object (readonly)
Returns the value of attribute coverage_source.
51 52 53 |
# File 'lib/moult/health_report.rb', line 51 def coverage_source @coverage_source end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
51 52 53 |
# File 'lib/moult/health_report.rb', line 51 def files @files end |
#generated_at ⇒ Object (readonly)
Returns the value of attribute generated_at.
51 52 53 |
# File 'lib/moult/health_report.rb', line 51 def generated_at @generated_at end |
#git_ref ⇒ Object (readonly)
Returns the value of attribute git_ref.
51 52 53 |
# File 'lib/moult/health_report.rb', line 51 def git_ref @git_ref end |
#grade ⇒ Object (readonly)
Returns the value of attribute grade.
51 52 53 |
# File 'lib/moult/health_report.rb', line 51 def grade @grade end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
51 52 53 |
# File 'lib/moult/health_report.rb', line 51 def root @root end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
51 52 53 |
# File 'lib/moult/health_report.rb', line 51 def score @score end |
Instance Method Details
#to_h ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/moult/health_report.rb', line 74 def to_h { schema_version: SCHEMA_VERSION, tool: {name: "moult", version: Moult::VERSION}, analysis: { root: root, git_ref: git_ref, generated_at: generated_at, coverage: coverage_source&.to_h, churn: {window: churn_window, since: churn_since} }, overall: { score: score, grade: grade, components_present: components.count(&:present), components_total: components.size, files_total: files.size }, components: components.map(&:to_h), files: files.map(&:to_h) } end |