Class: Rigor::CLI::CheckCommand

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

Overview

Executes ‘rigor check` — the analyzer’s primary command.

The other subcommands delegate to a ‘CLI::Command` subclass once they grow beyond a few lines; `check` is the largest of them, owning option parsing, the baseline filter (ADR-22), the incremental modes (ADR-46), cache-stats reporting, editor mode, the CI-native output formats (ADR-51), and the diagnostic-only / heap / budget appendices. Keeping it in its own class follows the same dispatch-vs-implementation split the rest of the CLI uses and keeps `Rigor::CLI` focused on dispatch.

The class-length budget is relaxed (as on ‘Rigor::CLI` itself) because `check` aggregates several independent concerns that are clearer read together than split across micro-classes.

Instance Method Summary collapse

Methods inherited from Command

#initialize

Constructor Details

This class inherits a constructor from Rigor::CLI::Command

Instance Method Details

#runInteger

Returns CLI exit status.

Returns:

  • (Integer)

    CLI exit status.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rigor/cli/check_command.rb', line 31

def run # rubocop:disable Metrics/AbcSize
  load_check_dependencies
  options = parse_check_options
  buffer = Options.resolve_buffer_binding(options, err: @err)
  return CLI::EXIT_USAGE if buffer == :usage_error

  configuration = load_check_configuration(options)
  cache_root = configuration.cache_path
  handle_clear_cache(cache_root) if options.fetch(:clear_cache)

  special = dispatch_special_check_mode(configuration, options, cache_root)
  return special unless special.nil?

  runner = build_check_runner(
    configuration: configuration, options: options,
    buffer: buffer, cache_root: cache_root
  )
  raw_result = runner.run(@argv.empty? ? configuration.paths : @argv)
  result = apply_baseline_filter(raw_result, configuration, options)

  write_result(result, options.fetch(:format))
  emit_ci_detected_output(result, options)
  write_run_stats(result.stats) if result.stats
  write_trace_appendices
  runner.cache_store&.evict!
  write_cache_stats(cache_root, runner.cache_store) if options.fetch(:cache_stats)

  exit_code = result.success? ? 0 : 1
  exit_code = 1 if baseline_strict_violation?(raw_result.diagnostics, configuration, options)
  exit_code
end