8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/archspec/rules/zeitwerk_rule.rb', line 8
def evaluate(graph)
graph.files.values.filter_map do |file|
next unless file.expected_constant
defined = graph.constants_for_path(file.path).map(&:name)
next if defined.include?(file.expected_constant)
Diagnostic.new(
rule: id,
message: "#{file.relative_path} should define #{file.expected_constant}",
location: SourceLocation.new(file.path, 1, 1),
evidence: "defined constants: #{defined.empty? ? "(none)" : defined.join(", ")}"
)
end
end
|