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 309 def initialize(source) @source = source.to_sym end
Public Instance Methods
Source
# File lib/archspec/rules/protocol_rules.rb, line 321 def evaluate(graph) graph.edges.filter_map do |edge| next unless edge.type == :instantiates_and_invokes next unless graph.source_components_for(edge).include?(source) Diagnostic.new( rule: id, message: "#{source} must not instantiate and immediately invoke #{edge.to}", location: edge.location, evidence: "#{graph.edge_source_name(edge)} uses #{edge.to}" ) end end
Source
# File lib/archspec/rules/protocol_rules.rb, line 317 def id 'objects.instantiate_and_invoke_forbid' end
Source
# File lib/archspec/rules/protocol_rules.rb, line 313 def merge_key [self.class, source] end