Class: Ibex::RaccMigration::Finding

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/racc_migration/report.rb

Overview

One immutable migration compatibility observation.

Constant Summary collapse

SEVERITIES =

: Array

%i[error warning info].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, severity:, message:, location:, suggestion:) ⇒ Finding

Returns a new instance of Finding.



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ibex/racc_migration/report.rb', line 20

def initialize(code:, severity:, message:, location:, suggestion:)
  unless SEVERITIES.include?(severity)
    raise ArgumentError, "unknown migration finding severity #{severity.inspect}"
  end

  @code = code.dup.freeze
  @severity = severity
  @message = message.dup.freeze
  @location = location
  @suggestion = suggestion.dup.freeze
  freeze
end

Instance Attribute Details

#codeObject (readonly)

: String



12
13
14
# File 'lib/ibex/racc_migration/report.rb', line 12

def code
  @code
end

#locationObject (readonly)

: Frontend::Location?



15
16
17
# File 'lib/ibex/racc_migration/report.rb', line 15

def location
  @location
end

#messageObject (readonly)

: String



14
15
16
# File 'lib/ibex/racc_migration/report.rb', line 14

def message
  @message
end

#severityObject (readonly)

: Symbol



13
14
15
# File 'lib/ibex/racc_migration/report.rb', line 13

def severity
  @severity
end

#suggestionObject (readonly)

: String



16
17
18
# File 'lib/ibex/racc_migration/report.rb', line 16

def suggestion
  @suggestion
end

Instance Method Details

#to_hObject



34
35
36
37
38
39
40
41
42
# File 'lib/ibex/racc_migration/report.rb', line 34

def to_h
  {
    "code" => @code,
    "severity" => @severity.to_s,
    "message" => @message,
    "location" => @location&.to_h&.transform_keys(&:to_s),
    "suggestion" => @suggestion
  }
end