class ArchSpec::Rules::NamingRule
Backs the +method_names.matching(…)+ DSL. One rule pairs a selector (which methods it judges) with a constraint (what must hold of them). It judges a component’s defined, public methods in the requested scope, or every such method in the project when source is nil. Every finding is name-based and exact, so confidence is always :high.
Constants
- VALID_SCOPES
Attributes
Public Class Methods
# File lib/archspec/rules/naming_rules.rb, line 17 def initialize(source:, selector:, constraint:, scope: :instance, except: []) unless VALID_SCOPES.include?(scope) raise Error, "method_names scope: must be :instance or :class, got #{scope.inspect}" end @source = source&.to_sym @selector = selector @constraint = constraint @scope = scope @except = Array(except).flatten.map(&:to_sym).to_set end
Public Instance Methods
Source
# File lib/archspec/rules/naming_rules.rb, line 33 def evaluate(graph) selected = candidate_methods(graph).filter_map do |definition| next if except.include?(definition.name) match = selector.match(definition) [definition, match] if match end @constraint.diagnostics(selected, self, graph) end