Class: Ibex::RaccMigration::Finding

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

Overview

One immutable migration compatibility observation.

Constant Summary collapse

SEVERITIES =

Signature:

  • Array[Symbol]

Returns:

  • (Array[Symbol])
%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.

RBS:

  • (code: String, severity: Symbol, message: String, location: Frontend::Location?, suggestion: String) -> void

Parameters:

  • code: (String)
  • severity: (Symbol)
  • message: (String)
  • location: (Frontend::Location, nil)
  • suggestion: (String)


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

#codeString (readonly)

Signature:

  • String

Returns:

  • (String)


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

def code
  @code
end

#locationFrontend::Location? (readonly)

Signature:

  • Frontend::Location?

Returns:



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

def location
  @location
end

#messageString (readonly)

Signature:

  • String

Returns:

  • (String)


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

def message
  @message
end

#severitySymbol (readonly)

Signature:

  • Symbol

Returns:

  • (Symbol)


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

def severity
  @severity
end

#suggestionString (readonly)

Signature:

  • String

Returns:

  • (String)


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

def suggestion
  @suggestion
end

Instance Method Details

#to_hHash[String, untyped]

RBS:

  • () -> Hash[String, untyped]

Returns:

  • (Hash[String, untyped])


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