Class: Glossarist::Validation::Rules::RelatedConceptCycleRule
- Defined in:
- lib/glossarist/validation/rules/related_concept_cycle_rule.rb
Constant Summary collapse
- DIRECTIONAL =
%w[supersedes deprecates narrower].freeze
Instance Method Summary collapse
- #applicable?(context) ⇒ Boolean
- #category ⇒ Object
- #check(context) ⇒ Object
- #code ⇒ Object
- #scope ⇒ Object
- #severity ⇒ Object
Methods inherited from Base
Instance Method Details
#applicable?(context) ⇒ Boolean
14 15 16 |
# File 'lib/glossarist/validation/rules/related_concept_cycle_rule.rb', line 14 def applicable?(context) context.concepts.any? { |c| c.&.any? } end |
#category ⇒ Object
8 |
# File 'lib/glossarist/validation/rules/related_concept_cycle_rule.rb', line 8 def category = :references |
#check(context) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/glossarist/validation/rules/related_concept_cycle_rule.rb', line 18 def check(context) graph = build_directed_graph(context.concepts) issues = [] cycles = detect_cycles(graph) cycles.each do |cycle| path = cycle.join(" -> ") issues << issue( "Circular relation chain detected: #{path}", location: cycle.first, suggestion: "Break the cycle by removing or redirecting one of the relations", ) end issues end |
#code ⇒ Object
7 |
# File 'lib/glossarist/validation/rules/related_concept_cycle_rule.rb', line 7 def code = "GLS-113" |
#scope ⇒ Object
10 |
# File 'lib/glossarist/validation/rules/related_concept_cycle_rule.rb', line 10 def scope = :collection |
#severity ⇒ Object
9 |
# File 'lib/glossarist/validation/rules/related_concept_cycle_rule.rb', line 9 def severity = "error" |