Module: ArchSpec::Evaluator
Instance Method Summary collapse
Instance Method Details
#evaluate(definition, graph, todo: Todo.empty) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/archspec/evaluator.rb', line 7 def evaluate(definition, graph, todo: Todo.empty) diagnostics = parser_diagnostics(graph) + definition.rules.flat_map { |rule| rule.evaluate(graph) } # Deduplicate before rejecting. One statement can raise several diagnostics # that differ only in evidence, because `include Foo` is both an includes # edge and a constant reference. Todo entries are matched on evidence, so # rejecting first would drop the recorded diagnostic and report its # surviving sibling as new. diagnostics .sort_by { |d| [d.location.path, d.location.line, d.rule, d., d.evidence] } .uniq { |d| [d.rule, d., d.location.path, d.location.line] } .reject { |diagnostic| graph.suppressed?(diagnostic) || todo.include?(diagnostic) } end |