Class: Ace::Lint::Molecules::ValidatorChain
- Inherits:
-
Object
- Object
- Ace::Lint::Molecules::ValidatorChain
- Defined in:
- lib/ace/lint/molecules/validator_chain.rb
Overview
Executes multiple validators sequentially and aggregates results Handles validator availability, fallbacks, and result deduplication
Instance Attribute Summary collapse
-
#fallback_validators ⇒ Object
readonly
Returns the value of attribute fallback_validators.
-
#validators ⇒ Object
readonly
Returns the value of attribute validators.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#initialize(validators, fallback_validators: [], project_root: nil) ⇒ ValidatorChain
constructor
Initialize with validators to run.
-
#run(file_paths, fix: false) ⇒ Hash
Run validators on file(s).
Constructor Details
#initialize(validators, fallback_validators: [], project_root: nil) ⇒ ValidatorChain
Initialize with validators to run
19 20 21 22 23 24 |
# File 'lib/ace/lint/molecules/validator_chain.rb', line 19 def initialize(validators, fallback_validators: [], project_root: nil) @validators = Array(validators) @fallback_validators = Array(fallback_validators) @project_root = project_root || Dir.pwd @warnings = [] end |
Instance Attribute Details
#fallback_validators ⇒ Object (readonly)
Returns the value of attribute fallback_validators.
13 14 15 |
# File 'lib/ace/lint/molecules/validator_chain.rb', line 13 def fallback_validators @fallback_validators end |
#validators ⇒ Object (readonly)
Returns the value of attribute validators.
13 14 15 |
# File 'lib/ace/lint/molecules/validator_chain.rb', line 13 def validators @validators end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
13 14 15 |
# File 'lib/ace/lint/molecules/validator_chain.rb', line 13 def warnings @warnings end |
Instance Method Details
#run(file_paths, fix: false) ⇒ Hash
Run validators on file(s)
30 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 |
# File 'lib/ace/lint/molecules/validator_chain.rb', line 30 def run(file_paths, fix: false) paths = Array(file_paths) return empty_result if paths.empty? # Determine which validators to actually run active_validators = resolve_validators if active_validators.empty? return unavailable_result end # Run each validator and collect results all_results = [] runners_used = [] active_validators.each do |validator_name| runner = Atoms::ValidatorRegistry.runner_for(validator_name) next unless runner # Look up config for this validator using ConfigLocator config = Atoms::ConfigLocator.locate(validator_name, project_root: @project_root) config_path = config[:exists] ? config[:path] : nil result = runner.run(paths, fix: fix, config_path: config_path) all_results << result runners_used << validator_name end # Aggregate and deduplicate results aggregate_results(all_results, runners_used) end |