cycles method

List<List<String>> cycles()

Every group of files that depend on each other, directly or through others — the strongly connected components with more than one member. Each group is sorted; groups come largest first.

A group is the right unit for "these files cannot be separated", but it is not itself a path: see cycleWalk for arrows that follow real edges.

Dart allows import cycles, so nothing in the toolchain surfaces them — but two files in one cannot be understood, tested or moved apart.

Implementation

List<List<String>> cycles() {
  final found = _stronglyConnected().where((c) => c.length > 1).toList()
    ..forEach((c) => c.sort())
    ..sort((a, b) {
      final bySize = b.length.compareTo(a.length);
      return bySize != 0 ? bySize : a.first.compareTo(b.first);
    });
  return found;
}