Class: Ea::Lint::Rules::CyclicGeneralizationRule

Inherits:
LintRule
  • Object
show all
Defined in:
lib/ea/lint/rules/cyclic_generalization.rb

Overview

Detects cyclic generalization chains (A → B → A).

Instance Method Summary collapse

Methods inherited from LintRule

name

Instance Method Details

#check(model) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/ea/lint/rules/cyclic_generalization.rb', line 10

def check(model)
  graph = build_graph(model)
  cycles = find_cycles(graph)
  cycles.map do |cycle|
    offense(entity_id: cycle.first,
            entity_name: cycle.join(""),
            message: "Cyclic generalization: #{cycle.join('')}#{cycle.first}")
  end
end