Class: Rigor::Analysis::Runner

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

Constant Summary collapse

RUBY_GLOB =
"**/*.rb"

Instance Method Summary collapse

Constructor Details

#initialize(configuration:) ⇒ Runner

Returns a new instance of Runner.



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

def initialize(configuration:)
  @configuration = configuration
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.



29
30
31
32
33
34
35
36
37
# File 'lib/rigor/analysis/runner.rb', line 29

def run(paths = @configuration.paths)
  environment = Environment.for_project
  expansion = expand_paths(paths)

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

  Result.new(diagnostics: diagnostics)
end