Method: JsDuck::Process::CircularDeps#check

Defined in:
lib/jsduck/process/circular_deps.rb

#check(cls, names = []) ⇒ Object

Checks class for circular dependencies.

When all OK, returns false.

When circular dependencies found returns a string describing the problematic dependency chain e.g. “Foo extends Bar mixins Foo”.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/jsduck/process/circular_deps.rb', line 30

def check(cls, names = [])
  names += [cls[:name]]

  if cls.parent && chain = track_circular(" extends ", cls.parent, names)
    return chain
  end

  cls.mixins.each do |mixin|
    if chain = track_circular(" mixins ", mixin, names)
      return chain
    end
  end

  false
end