Module: Moult::Formatters::BoundariesTable
- Defined in:
- lib/moult/formatters/boundaries_table.rb
Overview
Human-readable table of architecture-boundary violations. Renders from the same BoundariesReport as the JSON formatter so the two cannot disagree. Sorting already happened in Boundaries; this layer owns column formatting only.
The heading is deliberate: these are recorded packwerk violations, classified by severity — never a claim that the code is certainly wrong.
Constant Summary collapse
- MAX_FILES =
3
Class Method Summary collapse
- .files(occurrences) ⇒ Object
- .heading(summary) ⇒ Object
- .render(report) ⇒ String
- .row(finding) ⇒ Object
Class Method Details
.files(occurrences) ⇒ Object
46 47 48 49 50 |
# File 'lib/moult/formatters/boundaries_table.rb', line 46 def files(occurrences) shown = occurrences.first(MAX_FILES).map(&:path) extra = occurrences.size - shown.size extra.positive? ? "#{shown.join(", ")} (+#{extra} more)" : shown.join(", ") end |
.heading(summary) ⇒ Object
29 30 31 32 33 |
# File 'lib/moult/formatters/boundaries_table.rb', line 29 def heading(summary) by_sev = %w[high medium low].filter_map { |s| "#{summary[:by_severity][s]} #{s}" if summary[:by_severity][s].to_i.positive? } "Architecture-boundary violations (packwerk, recorded — not certainties): " \ "#{summary[:findings]} groups, #{summary[:violations]} violations (#{by_sev.join(", ")})" end |
.render(report) ⇒ String
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/moult/formatters/boundaries_table.rb', line 18 def render(report) return "Not a packwerk project (no packwerk.yml): no architecture boundaries to check." unless report.configured findings = report.findings return "No architecture-boundary violations recorded." if findings.empty? headers = %w[SEV TYPE REFERENCING DEFINING CONSTANT FILES] rows = findings.map { |f| row(f) } [heading(report.summary), "", TextTable.render(headers, rows)].join("\n") end |
.row(finding) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/moult/formatters/boundaries_table.rb', line 35 def row(finding) [ finding.severity, finding.violation_type, finding.referencing_package, finding.defining_package, finding.constant, files(finding.occurrences) ] end |