Class: Rigor::Analysis::Result

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

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).



13
14
15
16
# File 'lib/rigor/analysis/result.rb', line 13

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

Instance Attribute Details

#diagnosticsObject (readonly)

Returns the value of attribute diagnostics.



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

def diagnostics
  @diagnostics
end

#statsObject (readonly)

Returns the value of attribute stats.



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

def stats
  @stats
end

Instance Method Details

#error_countObject



22
23
24
# File 'lib/rigor/analysis/result.rb', line 22

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

#success?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rigor/analysis/result.rb', line 18

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

#to_hObject



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

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