Class: Moult::FlagsReport
- Inherits:
-
Object
- Object
- Moult::FlagsReport
- Defined in:
- lib/moult/flags_report.rb
Overview
The serialized result model for moult flags (schema/flags.schema.json),
sibling to DuplicationReport, DeadCodeReport, CoverageReport,
HealthReport and BoundariesReport. It owns its own JSON envelope and leaves
the other protected contracts untouched.
Each Finding is one flag key and the call sites referencing it. Without a
provider snapshot it carries confidence: null (a flag reference is a recorded
fact) and a Moult::Flags::Classification signal — the value_type, reference count, and
observed default value(s) — and serializes at schema_version 1.
When a provider snapshot is merged (the static<->provider merge) each finding ALSO carries a confidence-graded Moult::Flags::Staleness candidate (status + confidence + reasons), the report carries an analysis.provider provenance block, and the summary a by_staleness_status tally; the envelope reports schema_version 2. The bump is purely additive: with no snapshot the v2-only blocks are omitted and the output is byte-for-byte identical to v1. The snapshot is evidence, never proof — nothing here asserts a flag is certainly stale or dead.
Defined Under Namespace
Classes: Finding, Occurrence
Constant Summary collapse
- SCHEMA_VERSION =
The serialized shape's two additive versions. v1 = usage only; v2 = usage + joined staleness candidates (--provider). Bump either only on a breaking change.
1- SCHEMA_VERSION_WITH_PROVIDER =
2
Instance Attribute Summary collapse
-
#dynamic_references ⇒ Object
readonly
Returns the value of attribute dynamic_references.
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
-
#generated_at ⇒ Object
readonly
Returns the value of attribute generated_at.
-
#git_ref ⇒ Object
readonly
Returns the value of attribute git_ref.
-
#provider_source ⇒ Object
readonly
Returns the value of attribute provider_source.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(root:, findings:, dynamic_references: 0, git_ref: nil, generated_at: nil, provider_source: nil) ⇒ FlagsReport
constructor
A new instance of FlagsReport.
-
#summary ⇒ Hash
Aggregate counts across all flags.
- #to_h ⇒ Object
Constructor Details
#initialize(root:, findings:, dynamic_references: 0, git_ref: nil, generated_at: nil, provider_source: nil) ⇒ FlagsReport
Returns a new instance of FlagsReport.
70 71 72 73 74 75 76 77 |
# File 'lib/moult/flags_report.rb', line 70 def initialize(root:, findings:, dynamic_references: 0, git_ref: nil, generated_at: nil, provider_source: nil) @root = root @findings = findings @dynamic_references = dynamic_references @git_ref = git_ref @generated_at = generated_at @provider_source = provider_source end |
Instance Attribute Details
#dynamic_references ⇒ Object (readonly)
Returns the value of attribute dynamic_references.
61 62 63 |
# File 'lib/moult/flags_report.rb', line 61 def dynamic_references @dynamic_references end |
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
61 62 63 |
# File 'lib/moult/flags_report.rb', line 61 def findings @findings end |
#generated_at ⇒ Object (readonly)
Returns the value of attribute generated_at.
61 62 63 |
# File 'lib/moult/flags_report.rb', line 61 def generated_at @generated_at end |
#git_ref ⇒ Object (readonly)
Returns the value of attribute git_ref.
61 62 63 |
# File 'lib/moult/flags_report.rb', line 61 def git_ref @git_ref end |
#provider_source ⇒ Object (readonly)
Returns the value of attribute provider_source.
61 62 63 |
# File 'lib/moult/flags_report.rb', line 61 def provider_source @provider_source end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
61 62 63 |
# File 'lib/moult/flags_report.rb', line 61 def root @root end |
Instance Method Details
#summary ⇒ Hash
Returns aggregate counts across all flags.
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/moult/flags_report.rb', line 80 def summary base = { flags: findings.size, references: findings.sum { |f| f.occurrences.size }, dynamic_references: dynamic_references, by_value_type: tally { |f| f.value_type } } # v2-only: the staleness-status tally appears only when a snapshot was merged. base[:by_staleness_status] = staleness_tally if provider_source base end |
#to_h ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'lib/moult/flags_report.rb', line 92 def to_h { schema_version: provider_source ? SCHEMA_VERSION_WITH_PROVIDER : SCHEMA_VERSION, tool: {name: "moult", version: Moult::VERSION}, analysis: analysis, summary: summary, findings: findings.map(&:to_h) } end |