Skip to content

Commit

Permalink
refactor(model): Use named arguments in a couple of constructor calls
Browse files Browse the repository at this point in the history
Improve readability, and while at it make use of the default value for
scope roots in two of the calls.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed May 27, 2024
1 parent 3f2a0eb commit 87fd707
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
23 changes: 11 additions & 12 deletions analyzer/src/test/kotlin/AnalyzerResultBuilderTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,17 @@ class AnalyzerResultBuilderTest : WordSpec() {
DependencyGraph.qualifyScope(project2, "scope-3") to listOf(RootDependencyIndex(0))
)

private val graph1 =
DependencyGraph(
dependencies1,
sortedSetOf(DependencyGraph.DEPENDENCY_REFERENCE_COMPARATOR, depRef1, depRef2),
scopeMapping1
)
private val graph2 =
DependencyGraph(
dependencies2,
sortedSetOf(DependencyGraph.DEPENDENCY_REFERENCE_COMPARATOR, depRef3),
scopeMapping2
)
private val graph1 = DependencyGraph(
packages = dependencies1,
scopeRoots = sortedSetOf(DependencyGraph.DEPENDENCY_REFERENCE_COMPARATOR, depRef1, depRef2),
scopes = scopeMapping1
)

private val graph2 = DependencyGraph(
packages = dependencies2,
scopeRoots = sortedSetOf(DependencyGraph.DEPENDENCY_REFERENCE_COMPARATOR, depRef3),
scopes = scopeMapping2
)

private val analyzerResult1 = ProjectAnalyzerResult(
project1, setOf(package1), listOf(issue3, issue4)
Expand Down
9 changes: 4 additions & 5 deletions model/src/main/kotlin/utils/DependencyGraphBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,10 @@ class DependencyGraphBuilder<D>(
val (nodes, edges) = references.toGraph(indexMapping)

return DependencyGraph(
sortedDependencyIds,
sortedSetOf(),
constructSortedScopeMappings(scopeMapping, indexMapping),
nodes,
edges.removeCycles()
packages = sortedDependencyIds,
scopes = constructSortedScopeMappings(scopeMapping, indexMapping),
nodes = nodes,
edges = edges.removeCycles()
)
}

Expand Down
7 changes: 6 additions & 1 deletion model/src/test/kotlin/DependencyGraphTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ class DependencyGraphTest : WordSpec({
"s2" to listOf(RootDependencyIndex(2, fragment = 1))
)

val graph = DependencyGraph(ids, sortedSetOf(), scopeMap, nodes, edges)
val graph = DependencyGraph(
packages = ids,
scopes = scopeMap,
nodes = nodes,
edges = edges
)
val scopes = graph.createScopes()

scopeDependencies(scopes, "s1") shouldBe "${ids[2]}<${ids[1]}${ids[0]}>"
Expand Down
6 changes: 5 additions & 1 deletion model/src/test/kotlin/ProjectTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ private fun createDependencyGraph(qualified: Boolean = false): DependencyGraph {
plainScopeMapping
}

return DependencyGraph(dependencies, sortedSetOf(exampleRef, csvRef), scopeMapping)
return DependencyGraph(
packages = dependencies,
scopeRoots = sortedSetOf(exampleRef, csvRef),
scopes = scopeMapping
)
}

class ProjectTest : WordSpec({
Expand Down

0 comments on commit 87fd707

Please sign in to comment.