Class: ArchSpec::Rules::ForbidDependenciesRule

Inherits:
DependencyRule show all
Defined in:
lib/archspec/rules/dependency_rules.rb

Overview

Backs ArchSpec::DSL::ComponentProxy#cannot_use. Flags references from the source to any of the named components.

Instance Attribute Summary

Attributes inherited from DependencyRule

#source, #targets

Instance Method Summary collapse

Methods inherited from DependencyRule

#initialize, #merge!, #merge_key

Constructor Details

This class inherits a constructor from ArchSpec::Rules::DependencyRule

Instance Method Details

#evaluate(graph) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/archspec/rules/dependency_rules.rb', line 66

def evaluate(graph)
  relevant_edges(graph).flat_map do |edge|
    forbidden = graph.target_components_for(edge) & targets

    forbidden.map do |target|
      Diagnostic.new(
        rule: id,
        message: "#{source} must not depend on #{target}",
        location: edge.location,
        evidence: "#{graph.edge_source_name(edge)} #{edge.verb} #{edge.to}"
      )
    end
  end
end

#idObject



62
63
64
# File 'lib/archspec/rules/dependency_rules.rb', line 62

def id
  'dependencies.forbid'
end