Class: Rigor::Analysis::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/analysis/result.rb,
sig/rigor.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(diagnostics: [], stats: nil) ⇒ Result

Returns a new instance of Result.

Parameters:

  • stats (Rigor::Analysis::RunStats, nil) (defaults to: nil)

    end-of-run telemetry (target file count, RBS class breakdown, wall + RSS) collected by the Runner. Nil when stats collection wasn't requested or wasn't applicable (early-exit paths like validate_target_ruby failure).

  • diagnostics: (Array[Diagnostic]) (defaults to: [])
  • stats: (RunStats, nil) (defaults to: nil)


11
12
13
14
# File 'lib/rigor/analysis/result.rb', line 11

def initialize(diagnostics: [], stats: nil)
  @diagnostics = diagnostics
  @stats = stats
end

Instance Attribute Details

#diagnosticsArray[Diagnostic] (readonly)

Returns the value of attribute diagnostics.

Returns:



6
7
8
# File 'lib/rigor/analysis/result.rb', line 6

def diagnostics
  @diagnostics
end

#statsRunStats? (readonly)

Returns the value of attribute stats.

Returns:



6
7
8
# File 'lib/rigor/analysis/result.rb', line 6

def stats
  @stats
end

Instance Method Details

#error_countInteger

Returns:

  • (Integer)


20
21
22
# File 'lib/rigor/analysis/result.rb', line 20

def error_count
  diagnostics.count(&:error?)
end

#success?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/rigor/analysis/result.rb', line 16

def success?
  diagnostics.none?(&:error?)
end

#to_hHash[String, untyped]

Returns:

  • (Hash[String, untyped])


24
25
26
27
28
29
30
31
32
# File 'lib/rigor/analysis/result.rb', line 24

def to_h
  hash = {
    "success" => success?,
    "error_count" => error_count,
    "diagnostics" => diagnostics.map(&:to_h)
  }
  hash["stats"] = @stats.to_h if @stats
  hash
end