Class: Moult::BoundariesReport

Inherits:
Object
  • Object
show all
Defined in:
lib/moult/boundaries_report.rb

Overview

The serialized result model for moult boundaries (schema/boundaries.schema.json), sibling to DuplicationReport, DeadCodeReport, CoverageReport and HealthReport. It owns its own JSON envelope and leaves the other protected contracts untouched.

Each Finding is one recorded architecture-boundary violation group. Unlike the dead-code/duplication contracts it carries confidence: null (a packwerk violation is a recorded fact, not a probabilistic candidate) and a Moult::Boundaries::Severity classification instead — the honest per-finding grade for this slice. Nothing here asserts the code is wrong, only that packwerk recorded a declared-boundary crossing.

Defined Under Namespace

Classes: Finding, Occurrence

Constant Summary collapse

SCHEMA_VERSION =

Bump only on a breaking change to the serialized shape.

1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, findings:, git_ref: nil, generated_at: nil, backend: "packwerk", backend_version: nil, configured: false) ⇒ BoundariesReport

Returns a new instance of BoundariesReport.

Parameters:

  • root (String)

    absolute analysis root

  • findings (Array<Finding>)

    ranked, most-severe first

  • backend (String) (defaults to: "packwerk")

    detector backend name (e.g. "packwerk")

  • backend_version (String, nil) (defaults to: nil)

    backend gem version, when known

  • configured (Boolean) (defaults to: false)

    whether the project is packwerk-configured



56
57
58
59
60
61
62
63
64
65
# File 'lib/moult/boundaries_report.rb', line 56

def initialize(root:, findings:, git_ref: nil, generated_at: nil,
  backend: "packwerk", backend_version: nil, configured: false)
  @root = root
  @findings = findings
  @git_ref = git_ref
  @generated_at = generated_at
  @backend = backend
  @backend_version = backend_version
  @configured = configured
end

Instance Attribute Details

#backendObject (readonly)

Returns the value of attribute backend.



49
50
51
# File 'lib/moult/boundaries_report.rb', line 49

def backend
  @backend
end

#backend_versionObject (readonly)

Returns the value of attribute backend_version.



49
50
51
# File 'lib/moult/boundaries_report.rb', line 49

def backend_version
  @backend_version
end

#configuredObject (readonly)

Returns the value of attribute configured.



49
50
51
# File 'lib/moult/boundaries_report.rb', line 49

def configured
  @configured
end

#findingsObject (readonly)

Returns the value of attribute findings.



49
50
51
# File 'lib/moult/boundaries_report.rb', line 49

def findings
  @findings
end

#generated_atObject (readonly)

Returns the value of attribute generated_at.



49
50
51
# File 'lib/moult/boundaries_report.rb', line 49

def generated_at
  @generated_at
end

#git_refObject (readonly)

Returns the value of attribute git_ref.



49
50
51
# File 'lib/moult/boundaries_report.rb', line 49

def git_ref
  @git_ref
end

#rootObject (readonly)

Returns the value of attribute root.



49
50
51
# File 'lib/moult/boundaries_report.rb', line 49

def root
  @root
end

Instance Method Details

#summaryHash

Returns aggregate counts across all violation groups.

Returns:

  • (Hash)

    aggregate counts across all violation groups



68
69
70
71
72
73
74
75
# File 'lib/moult/boundaries_report.rb', line 68

def summary
  {
    findings: findings.size,
    violations: findings.sum { |f| f.occurrences.size },
    by_type: tally { |f| f.violation_type },
    by_severity: tally { |f| f.severity }
  }
end

#to_hObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/moult/boundaries_report.rb', line 77

def to_h
  {
    schema_version: SCHEMA_VERSION,
    tool: {name: "moult", version: Moult::VERSION},
    analysis: {
      root: root,
      git_ref: git_ref,
      generated_at: generated_at,
      detector: {
        backend: backend,
        backend_version: backend_version,
        configured: configured
      }
    },
    summary: summary,
    findings: findings.map(&:to_h)
  }
end