class ArchSpec::Diagnostic
One reported violation: the rule id, a message, the source location, the evidence ArchSpec found, and a confidence. Formatters and the todo file read these. Its fingerprint is the stable id used to match todo entries and suppress specific findings.
Attributes
Public Class Methods
# File lib/archspec/diagnostic.rb, line 13 def initialize(rule:, message:, location:, evidence:, confidence: :high) @rule = rule @message = message @location = location @evidence = evidence @confidence = confidence end
Public Instance Methods
Source
# File lib/archspec/diagnostic.rb, line 23 def fingerprint(root: nil) path = root ? location.relative_path(root) : location.path Digest::SHA256.hexdigest( [rule, message, path, evidence].join("\0") )[0, 24] end
Line numbers stay out of the fingerprint so todo entries survive edits that only shift code around.
Source
# File lib/archspec/diagnostic.rb, line 31 def to_h(root:) { id: fingerprint(root: root), rule: rule, message: message, path: location.relative_path(root), line: location.line, column: location.column, evidence: evidence, confidence: confidence.to_s } end