Class: LayerChecker::DependencyValidator
- Inherits:
-
Object
- Object
- LayerChecker::DependencyValidator
- Defined in:
- lib/layer_checker/dependency_validator.rb
Instance Attribute Summary collapse
-
#analyzer ⇒ Object
readonly
Returns the value of attribute analyzer.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#violations ⇒ Object
readonly
Returns the value of attribute violations.
Instance Method Summary collapse
-
#initialize(config, analyzer) ⇒ DependencyValidator
constructor
A new instance of DependencyValidator.
- #validate ⇒ Object
Constructor Details
#initialize(config, analyzer) ⇒ DependencyValidator
Returns a new instance of DependencyValidator.
9 10 11 12 13 |
# File 'lib/layer_checker/dependency_validator.rb', line 9 def initialize(config, analyzer) @config = config @analyzer = analyzer @violations = [] end |
Instance Attribute Details
#analyzer ⇒ Object (readonly)
Returns the value of attribute analyzer.
7 8 9 |
# File 'lib/layer_checker/dependency_validator.rb', line 7 def analyzer @analyzer end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/layer_checker/dependency_validator.rb', line 7 def config @config end |
#violations ⇒ Object (readonly)
Returns the value of attribute violations.
7 8 9 |
# File 'lib/layer_checker/dependency_validator.rb', line 7 def violations @violations end |
Instance Method Details
#validate ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/layer_checker/dependency_validator.rb', line 15 def validate @violations = [] @analyzer.file_dependencies.each do |file_path, file_info| source_module = file_info[:module] # Handle unassigned files if source_module.nil? handle_unassigned_file(file_path, file_info) next end # Check each dependency file_info[:dependencies].each do |dependency| check_dependency(file_path, source_module, dependency) end end # Deduplicate violations (same file, line, source and target) @violations.uniq! do |v| [v.source_file, v.line_number, v.source_module&.full_name, v.target_module&.full_name] end @violations end |