Skip to content

Commit 4e183ff

Browse files
committed
chore(model): Allow the vcsPath receiver to be null
This allows to simplify code a bit. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent fa0a975 commit 4e183ff

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fun TextLocation.prependPath(prefix: String): TextLocation =
4141
/**
4242
* Return the VCS path if this is a [RepositoryProvenance] or else an empty string.
4343
*/
44-
val Provenance.vcsPath: String
44+
val Provenance?.vcsPath: String
4545
get() = (this as? RepositoryProvenance)?.vcsInfo?.path.orEmpty()
4646

4747
/**

scanner/src/main/kotlin/Scanner.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ private fun ScanController.getSubRepositories(id: Identifier): Map<String, VcsIn
803803
private fun ProvenanceResolutionResult.filterByVcsPath(): ProvenanceResolutionResult =
804804
copy(
805805
subRepositories = subRepositories.filter { (path, _) ->
806-
File(path).startsWith(packageProvenance?.vcsPath.orEmpty())
806+
File(path).startsWith(packageProvenance.vcsPath)
807807
}
808808
)
809809

scanner/src/main/kotlin/utils/Utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal fun requireEmptyVcsPath(provenance: Provenance) {
4545
fun getVcsPathsForProvenances(provenances: Set<ProvenanceResolutionResult>) =
4646
buildMap<KnownProvenance, MutableSet<String>> {
4747
provenances.forEach { provenance ->
48-
val packageVcsPath = provenance.packageProvenance?.vcsPath.orEmpty()
48+
val packageVcsPath = provenance.packageProvenance.vcsPath
4949

5050
provenance.getKnownProvenancesWithoutVcsPath().forEach { (repositoryPath, provenance) ->
5151
getVcsPathForRepositoryOrNull(packageVcsPath, repositoryPath)?.let { vcsPath ->

0 commit comments

Comments
 (0)