From 63db06b676d0c0f0022eeb135321d7c11e922d0c Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Mon, 16 Dec 2024 12:09:54 +0100 Subject: [PATCH] chore(opossum): Prefer `add` functions when building collections Avoid any confusion what `this` refers to for these (extension) functions. Signed-off-by: Sebastian Schuberth --- model/src/main/kotlin/utils/SortedCollectionConverters.kt | 8 ++++---- plugins/package-managers/conan/src/main/kotlin/Conan.kt | 2 +- .../reporters/opossum/src/main/kotlin/OpossumReporter.kt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/model/src/main/kotlin/utils/SortedCollectionConverters.kt b/model/src/main/kotlin/utils/SortedCollectionConverters.kt index e2fdfc110d90e..e54f12d5bf74c 100644 --- a/model/src/main/kotlin/utils/SortedCollectionConverters.kt +++ b/model/src/main/kotlin/utils/SortedCollectionConverters.kt @@ -105,16 +105,16 @@ class SnippetFindingSortedSetConverter : StdConverter, Sorte private fun Provenance.getSortKey(): String = buildList { - this += javaClass.canonicalName + add(javaClass.canonicalName) when (this@getSortKey) { is RepositoryProvenance -> { - this += vcsInfo.type.toString() - this += vcsInfo.url + add(vcsInfo.type.toString()) + add(vcsInfo.url) } is ArtifactProvenance -> { - this += sourceArtifact.url + add(sourceArtifact.url) } else -> { diff --git a/plugins/package-managers/conan/src/main/kotlin/Conan.kt b/plugins/package-managers/conan/src/main/kotlin/Conan.kt index 92bbd2a5be439..7d4aeb821943e 100644 --- a/plugins/package-managers/conan/src/main/kotlin/Conan.kt +++ b/plugins/package-managers/conan/src/main/kotlin/Conan.kt @@ -314,7 +314,7 @@ class Conan( val dependencies = parseDependencyTree(pkgInfos, pkgInfo.requires, workingDir) + parseDependencyTree(pkgInfos, pkgInfo.buildRequires, workingDir) - this += PackageReference(id, dependencies = dependencies) + add(PackageReference(id, dependencies = dependencies)) } } } diff --git a/plugins/reporters/opossum/src/main/kotlin/OpossumReporter.kt b/plugins/reporters/opossum/src/main/kotlin/OpossumReporter.kt index 442d9ab31225d..ebf5f1946d5cf 100644 --- a/plugins/reporters/opossum/src/main/kotlin/OpossumReporter.kt +++ b/plugins/reporters/opossum/src/main/kotlin/OpossumReporter.kt @@ -443,6 +443,6 @@ class OpossumReporter( private fun DependencyNode.getDependencies(): List = buildList { visitDependencies { dependencyNodes -> - this += dependencyNodes.map { it.getStableReference() } + addAll(dependencyNodes.map { it.getStableReference() }) } }