Skip to content

Commit 38a41d6

Browse files
nnobelismnonnenmacher
authored andcommitted
chore(model): move a condition to filterExcludedPackages
Signed-off-by: Nicolas Nobelis <nicolas.nobelis@bosch.com>
1 parent 4f7a99f commit 38a41d6

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

model/src/main/kotlin/utils/DependencyGraphConverter.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ object DependencyGraphConverter {
6060
val graphs = buildDependencyGraphs(projectsToConvert, excludes, includes)
6161
val allGraphs = result.dependencyGraphs + graphs
6262

63-
val filteredPackages = if (includes.scopes.isEmpty() && excludes.scopes.isEmpty()) {
64-
result.packages
65-
} else {
66-
filterExcludedPackages(allGraphs.values, result.packages)
67-
}
63+
val filteredPackages = filterExcludedPackages(allGraphs.values, result.packages, excludes, includes)
6864

6965
return result.copy(
7066
dependencyGraphs = allGraphs,
@@ -106,11 +102,18 @@ object DependencyGraphConverter {
106102
/**
107103
* Filter out all [packages] that are no longer referenced by one of the given [dependency graphs][graphs]. These
108104
* packages have been subject of scope excludes or not included by scope includes.
105+
* If no scope [includes] and no scope [excludes] are defined, the original set of [packages] is returned as is.
109106
*/
110107
private fun filterExcludedPackages(
111108
graphs: Collection<DependencyGraph>,
112-
packages: Collection<Package>
109+
packages: Set<Package>,
110+
excludes: Excludes,
111+
includes: Includes
113112
): Set<Package> {
113+
if (includes.scopes.isEmpty() && excludes.scopes.isEmpty()) {
114+
return packages
115+
}
116+
114117
val includedPackages = graphs.flatMapTo(mutableSetOf()) { it.packages }
115118
return packages.filterTo(mutableSetOf()) { it.id in includedPackages }
116119
}

0 commit comments

Comments
 (0)