Skip to content

Commit

Permalink
fix: break infinite recursion in renderTreeNode (#33)
Browse files Browse the repository at this point in the history
* can be reproduced with
  libraryDependencies += "io.grpc" % "grpc-core" % "1.58.0"
* break cycle by tracking parents
  • Loading branch information
patriknw authored Oct 17, 2023
1 parent fa6dc01 commit a0b8f9d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ project/plugins/project/
.history
.cache
.lib/
.bsp

### Scala template
*.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
r <- graph.roots
d <- children(graph, r)
}
renderTreeNode(p, graph, d)
renderTreeNode(p, graph, d, Set.empty)
p.print("</pre></dd>").println()
}

private def renderTreeNode(p: Printer, graph: ModuleGraph, n: Module): Unit =
if (n.evictedByVersion.isEmpty) {
private def renderTreeNode(p: Printer, graph: ModuleGraph, n: Module, parents: Set[Module]): Unit =
// avoid cycles by checking if in parents
if (n.evictedByVersion.isEmpty && !parents.contains(n)) {
val moduleId = n.id
val name = moduleId.name
p.println()
Expand All @@ -99,7 +100,7 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
n.license.foreach(l => p.print(" ").print(l))
if (children(graph, n).nonEmpty) {
p.indent(4)
children(graph, n).foreach(renderTreeNode(p, graph, _))
children(graph, n).foreach(renderTreeNode(p, graph, _, parents + n))
p.indent(-4)
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/sbt-test/dependencies/happy-path/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
enablePlugins(ParadoxPlugin)
paradoxTheme := None

libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.5.17"
//libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.5.17"

libraryDependencies += "io.grpc" % "grpc-core" % "1.58.0"

0 comments on commit a0b8f9d

Please sign in to comment.