Skip to content

Commit 71d4614

Browse files
committed
refactor(model): Remove the convenience qualifyScope() overload
Inline the function in favor of only keeping the function that takes a project's ID. This makes the symmetry to `unqualifyScope()` clearer. Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
1 parent 397fecc commit 71d4614

File tree

6 files changed

+7
-14
lines changed

6 files changed

+7
-14
lines changed

analyzer/src/test/kotlin/AnalyzerResultBuilderTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ class AnalyzerResultBuilderTest : WordSpec() {
9595
private val depRef3 = DependencyReference(0, issues = listOf(issue5))
9696

9797
private val scopeMapping1 = mapOf(
98-
DependencyGraph.qualifyScope(project1, "scope-1") to listOf(RootDependencyIndex(0)),
99-
DependencyGraph.qualifyScope(project3, "scope-2") to listOf(RootDependencyIndex(1))
98+
DependencyGraph.qualifyScope(project1.id, "scope-1") to listOf(RootDependencyIndex(0)),
99+
DependencyGraph.qualifyScope(project3.id, "scope-2") to listOf(RootDependencyIndex(1))
100100
)
101101
private val scopeMapping2 = mapOf(
102-
DependencyGraph.qualifyScope(project2, "scope-3") to listOf(RootDependencyIndex(0))
102+
DependencyGraph.qualifyScope(project2.id, "scope-3") to listOf(RootDependencyIndex(0))
103103
)
104104

105105
private val graph1 =

model/src/main/kotlin/DependencyGraph.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,6 @@ data class DependencyGraph(
115115
*/
116116
val DEPENDENCY_REFERENCE_COMPARATOR = compareBy<DependencyReference>({ it.pkg }, { it.fragment })
117117

118-
/**
119-
* Return a name for the given [scope][scopeName] that is qualified with parts of the identifier of the given
120-
* [project]. This is used to ensure that the scope names are unique when constructing a dependency graph from
121-
* multiple projects.
122-
*/
123-
fun qualifyScope(project: Project, scopeName: String): String = qualifyScope(project.id, scopeName)
124-
125118
/**
126119
* Return a name for the given [scope][scopeName] that is qualified with parts of the given [projectId]. This
127120
* is used to ensure that the scope names are unique when constructing a dependency graph from multiple

model/src/main/kotlin/DependencyGraphNavigator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class DependencyGraphNavigator(
4747
override fun directDependencies(project: Project, scopeName: String): Sequence<DependencyNode> {
4848
// Collect all root indices for all managers whose graphs have projects of the respective type.
4949
val rootIndicesForGraphs = graphs.mapNotNull { (managerName, graph) ->
50-
graph.scopes[DependencyGraph.qualifyScope(project, scopeName)]?.let { Triple(managerName, graph, it) }
50+
graph.scopes[DependencyGraph.qualifyScope(project.id, scopeName)]?.let { Triple(managerName, graph, it) }
5151
}
5252

5353
if (rootIndicesForGraphs.isEmpty()) return emptySequence()

model/src/main/kotlin/Project.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,5 @@ data class Project(
194194
* extracting the scopes of this project from a shared dependency graph.
195195
*/
196196
private fun qualifiedScopeNames(): Set<String> =
197-
scopeNames.orEmpty().map { DependencyGraph.qualifyScope(this, it) }.toSet()
197+
scopeNames.orEmpty().map { DependencyGraph.qualifyScope(id, it) }.toSet()
198198
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ object DependencyGraphConverter {
8181

8282
projectsForType.forEach { project ->
8383
project.scopes.filterNot { excludes.isScopeExcluded(it.name) }.forEach { scope ->
84-
val scopeName = DependencyGraph.qualifyScope(project, scope.name)
84+
val scopeName = DependencyGraph.qualifyScope(project.id, scope.name)
8585
scope.dependencies.forEach { dependency ->
8686
builder.addDependency(scopeName, dependency)
8787
}

model/src/test/kotlin/DependencyGraphTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class DependencyGraphTest : WordSpec({
201201
vcs = VcsInfo.EMPTY
202202
)
203203

204-
val qualifiedScopeName = DependencyGraph.qualifyScope(project, scopeName)
204+
val qualifiedScopeName = DependencyGraph.qualifyScope(project.id, scopeName)
205205

206206
qualifiedScopeName shouldBe "namespace:name:version:$scopeName"
207207
}

0 commit comments

Comments
 (0)