Module: ArchSpec::Formatters::Text

Extended by:
Text
Included in:
Text
Defined in:
lib/archspec/formatters/text.rb

Instance Method Summary collapse

Instance Method Details



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/archspec/formatters/text.rb', line 6

def print(output = $stdout, graph:, diagnostics:)
  if diagnostics.empty?
    output.puts "ArchSpec passed: #{graph.files.size} files, #{graph.constants.size} constants, #{graph.edges.size} facts checked."
    return
  end

  output.puts "#{diagnostics.size} architecture #{diagnostics.size == 1 ? "violation" : "violations"}"
  output.puts

  diagnostics.each do |diagnostic|
    output.puts "[#{diagnostic.rule}] #{diagnostic.location.relative_path(graph.root)}:#{diagnostic.location.line}:#{diagnostic.location.column}"
    output.puts "  #{diagnostic.message}"
    output.puts "  evidence: #{diagnostic.evidence}"
    output.puts "  confidence: #{diagnostic.confidence}"
    output.puts "  id: #{diagnostic.fingerprint(root: graph.root)}"
    output.puts
  end
end