Skip to content

Commit

Permalink
refactor(bower): Turn parseDependencyTree() into an expression
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Jul 23, 2024
1 parent 269df54 commit 95fe15b
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions plugins/package-managers/bower/src/main/kotlin/Bower.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,8 @@ private fun parseDependencyTree(
info: PackageInfo,
scopeName: String,
packageInfoForName: Map<String, PackageInfo>
): Set<PackageReference> {
val result = mutableSetOf<PackageReference>()

info.getScopeDependencies(scopeName).forEach { name ->
): Set<PackageReference> =
info.getScopeDependencies(scopeName).mapTo(mutableSetOf()) { name ->
// Bower leaves out a dependency entry for a child if there exists a similar entry to its parent entry
// with the exact same name and resolved target. This makes it necessary to retrieve the information
// about the subtree rooted at the parent from that other entry containing the full dependency
Expand All @@ -187,12 +185,9 @@ private fun parseDependencyTree(
val childInfo = info.dependencies[name] ?: packageInfoForName.getValue(name)
val childScope = SCOPE_NAME_DEPENDENCIES
val childDependencies = parseDependencyTree(childInfo, childScope, packageInfoForName)
val packageReference = PackageReference(

PackageReference(
id = childInfo.toId(),
dependencies = childDependencies
)
result += packageReference
}

return result
}

0 comments on commit 95fe15b

Please sign in to comment.