Class: Rigor::FlowContribution::Conflict
- Inherits:
-
Data
- Object
- Data
- Rigor::FlowContribution::Conflict
- Defined in:
- lib/rigor/flow_contribution/conflict.rb
Instance Attribute Summary collapse
-
#edge ⇒ Object
readonly
Returns the value of attribute edge.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#provenances ⇒ Object
readonly
Returns the value of attribute provenances.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(target:, edge:, kind:, reason:, provenances:, message:) ⇒ Conflict
constructor
rubocop:disable Metrics/ParameterLists.
-
#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
rubocop:disable Metrics/ParameterLists
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:) # rubocop:disable Metrics/ParameterLists 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 Attribute Details
#edge ⇒ Object (readonly)
Returns the value of attribute edge
31 32 33 |
# File 'lib/rigor/flow_contribution/conflict.rb', line 31 def edge @edge end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
31 32 33 |
# File 'lib/rigor/flow_contribution/conflict.rb', line 31 def kind @kind end |
#message ⇒ Object (readonly)
Returns the value of attribute message
31 32 33 |
# File 'lib/rigor/flow_contribution/conflict.rb', line 31 def @message end |
#provenances ⇒ Object (readonly)
Returns the value of attribute provenances
31 32 33 |
# File 'lib/rigor/flow_contribution/conflict.rb', line 31 def provenances @provenances end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason
31 32 33 |
# File 'lib/rigor/flow_contribution/conflict.rb', line 31 def reason @reason end |
#target ⇒ Object (readonly)
Returns the value of attribute target
31 32 33 |
# File 'lib/rigor/flow_contribution/conflict.rb', line 31 def target @target 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 |