class ArchSpec::Rules::CannotInstantiateAndInvokeRule
Backs ArchSpec::DSL::ComponentProxy#cannot_instantiate_and_invoke. Flags the one-shot Thing.new(...).call pattern.
Attributes
Public Class Methods
Source
# File lib/archspec/rules/protocol_rules.rb, line 210 def initialize(source) @source = source.to_sym end
Public Instance Methods
Source
# File lib/archspec/rules/protocol_rules.rb, line 222 def evaluate(graph) graph.edges.filter_map do |edge| next unless edge.type == :instantiates_and_invokes next unless graph.component_names_for_path(edge.from_path).include?(source) Diagnostic.new( rule: id, message: "#{source} must not instantiate and immediately invoke #{edge.to}", location: edge.location, evidence: "#{edge.from_constant || edge.from_path} uses #{edge.to}" ) end end
Source
# File lib/archspec/rules/protocol_rules.rb, line 218 def id 'objects.instantiate_and_invoke_forbid' end
Source
# File lib/archspec/rules/protocol_rules.rb, line 214 def merge_key [self.class, source] end