Class: Rigor::Analysis::Runner

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

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

RUBY_GLOB =
"**/*.rb"

Instance Method Summary collapse

Constructor Details

#initialize(configuration:, explain: false) ⇒ Runner

Returns a new instance of Runner.



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

def initialize(configuration:, explain: false)
  @configuration = configuration
  @explain = explain
end

Instance Method Details

#run(paths = @configuration.paths) ⇒ Object

Walks every Ruby file under ‘paths`, parses it, builds a per-node scope index through `Rigor::Inference::ScopeIndexer`, and runs the `Rigor::Analysis::CheckRules` catalogue over it. Returns a `Rigor::Analysis::Result` aggregating every produced diagnostic plus any Prism parse errors. The Environment is built once at run start through `Environment.for_project` so all files share the same RBS load.



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

def run(paths = @configuration.paths)
  environment = Environment.for_project(
    libraries: @configuration.libraries,
    signature_paths: @configuration.signature_paths
  )
  expansion = expand_paths(paths)

  diagnostics = expansion.fetch(:errors)
  diagnostics += expansion.fetch(:files).flat_map { |path| analyze_file(path, environment) }

  Result.new(diagnostics: diagnostics)
end