class ArchSpec::Rules::MustBeEmptyRule
Backs ArchSpec::DSL::ComponentProxy#must_be_empty. Flags every file in a component that is meant to hold none.
Attributes
Public Class Methods
Source
# File lib/archspec/rules/component_rules.rb, line 10 def initialize(source, because: nil) @source = source.to_sym @because = because end
Public Instance Methods
Source
# File lib/archspec/rules/component_rules.rb, line 23 def evaluate(graph) component = graph.components[source] return [] unless component component.files.sort.map do |path| relative = graph.files[path]&.relative_path || path Diagnostic.new( rule: id, message: because ? "#{source} must stay empty: #{because}" : "#{source} must stay empty", location: SourceLocation.new(path, 1, 1), evidence: "#{relative} belongs to #{source}" ) end end
Source
# File lib/archspec/rules/component_rules.rb, line 15 def merge_key [self.class, source] end