Class: Rigor::FlowContribution::Conflict
- Inherits:
-
Object
- Object
- Rigor::FlowContribution::Conflict
- Defined in:
- lib/rigor/flow_contribution/conflict.rb
Instance Method Summary collapse
-
#initialize(target:, edge:, kind:, reason:, provenances:, message:) ⇒ Conflict
constructor
A new instance of Conflict.
-
#to_diagnostic(path:, line:, column:, severity: :error) ⇒ Object
ADR-7 § “Slice 5-C” — converts the conflict into a ‘Rigor::Analysis::Diagnostic` for the run result.
- #to_h ⇒ Object
Constructor Details
#initialize(target:, edge:, kind:, reason:, provenances:, message:) ⇒ Conflict
Returns a new instance of Conflict.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rigor/flow_contribution/conflict.rb', line 32 def initialize(target:, edge:, kind:, reason:, provenances:, message:) unless CONFLICT_VALID_REASONS.include?(reason) raise ArgumentError, "FlowContribution::Conflict reason must be one of " \ "#{CONFLICT_VALID_REASONS.inspect}, got #{reason.inspect}" end super(target: target, edge: edge, kind: kind, reason: reason, provenances: provenances.dup.freeze, message: .to_s.dup.freeze) end |
Instance Method Details
#to_diagnostic(path:, line:, column:, severity: :error) ⇒ Object
ADR-7 § “Slice 5-C” — converts the conflict into a ‘Rigor::Analysis::Diagnostic` for the run result. Carries `source_family: :contribution_merge` so the qualified-rule formatter (slice 5 formatter half, `ef730b2`) prefixes the rule id with `contribution_merge.` and the JSON output side-bands `source_family` + `rule` for plugin attribution.
The ‘rule` identifier is the kebab-case form of the conflict reason (`return_type_collapse` →`return-type-collapse`, etc.) so the qualified rule reads `[contribution_merge.return-type-collapse]` in the standard text stream.
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rigor/flow_contribution/conflict.rb', line 67 def to_diagnostic(path:, line:, column:, severity: :error) require_relative "../analysis/diagnostic" unless defined?(Rigor::Analysis::Diagnostic) Rigor::Analysis::Diagnostic.new( path: path, line: line, column: column, message: , severity: severity, rule: reason.to_s.tr("_", "-"), source_family: :contribution_merge ) end |
#to_h ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rigor/flow_contribution/conflict.rb', line 43 def to_h { "target" => target.to_s, "edge" => edge.to_s, "kind" => kind.to_s, "reason" => reason.to_s, "sources" => provenances.map { |p| p.respond_to?(:to_h) ? p.to_h : p.to_s }, "message" => } end |