Class: Rigor::CLI::TriageCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/cli/triage_command.rb

Overview

ADR-23 — executes ‘rigor triage`.

Runs the same analysis as ‘rigor check`, then summarises the diagnostic stream (rule distribution, per-file hotspots, heuristic hints) instead of printing the raw per-line list. Read-only and advisory (WD4): never edits config, never writes a baseline. Always exits 0 — it is an inspection command, not a gate (`rigor check` remains the gate).

Constant Summary collapse

USAGE =
"Usage: rigor triage [options] [paths]"
DEFAULT_SECTIONS =
%i[distribution hotspots hints].freeze

Instance Method Summary collapse

Constructor Details

#initialize(argv:, out:, err:) ⇒ TriageCommand

Returns a new instance of TriageCommand.



25
26
27
28
29
# File 'lib/rigor/cli/triage_command.rb', line 25

def initialize(argv:, out:, err:)
  @argv = argv
  @out = out
  @err = err
end

Instance Method Details

#runInteger

Returns CLI exit status (always 0).

Returns:

  • (Integer)

    CLI exit status (always 0).



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rigor/cli/triage_command.rb', line 32

def run
  options = parse_options
  configuration = Configuration.load(options.fetch(:config))
  diagnostics = analyze(configuration)

  report = Triage.analyze(diagnostics, top: options.fetch(:top),
                                       hints: options.fetch(:sections).include?(:hints))
  renderer = TriageRenderer.new(report, sections: options.fetch(:sections))
  @out.puts(options.fetch(:format) == "json" ? renderer.json : renderer.text)
  0
end