Class: Rigor::Analysis::Runner
- Inherits:
-
Object
- Object
- Rigor::Analysis::Runner
- Defined in:
- lib/rigor/analysis/runner.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- RUBY_GLOB =
"**/*.rb"- DEFAULT_CACHE_ROOT =
".rigor/cache"
Instance Attribute Summary collapse
-
#cache_store ⇒ Object
readonly
Returns the value of attribute cache_store.
-
#plugin_registry ⇒ Object
readonly
Returns the value of attribute plugin_registry.
Instance Method Summary collapse
-
#initialize(configuration:, explain: false, cache_store: Cache::Store.new(root: DEFAULT_CACHE_ROOT), plugin_requirer: nil) ⇒ Runner
constructor
A new instance of Runner.
-
#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.
Constructor Details
#initialize(configuration:, explain: false, cache_store: Cache::Store.new(root: DEFAULT_CACHE_ROOT), plugin_requirer: nil) ⇒ Runner
Returns a new instance of Runner.
35 36 37 38 39 40 41 42 43 |
# File 'lib/rigor/analysis/runner.rb', line 35 def initialize(configuration:, explain: false, cache_store: Cache::Store.new(root: DEFAULT_CACHE_ROOT), plugin_requirer: nil) @configuration = configuration @explain = explain @cache_store = cache_store @plugin_requirer = plugin_requirer @plugin_registry = Plugin::Registry::EMPTY end |
Instance Attribute Details
#cache_store ⇒ Object (readonly)
Returns the value of attribute cache_store.
24 25 26 |
# File 'lib/rigor/analysis/runner.rb', line 24 def cache_store @cache_store end |
#plugin_registry ⇒ Object (readonly)
Returns the value of attribute plugin_registry.
24 25 26 |
# File 'lib/rigor/analysis/runner.rb', line 24 def plugin_registry @plugin_registry 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.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rigor/analysis/runner.rb', line 53 def run(paths = @configuration.paths) Inference::MethodDispatcher::FileFolding.fold_platform_specific_paths = @configuration.fold_platform_specific_paths environment = Environment.for_project( libraries: @configuration.libraries, signature_paths: @configuration.signature_paths, cache_store: @cache_store ) @plugin_registry = load_plugins expansion = (paths) diagnostics = plugin_load_diagnostics diagnostics += expansion.fetch(:errors) diagnostics += expansion.fetch(:files).flat_map { |path| analyze_file(path, environment) } Result.new(diagnostics: apply_severity_profile(diagnostics)) end |