Skip to content

Commit

Permalink
refactor: Adjust KnownProvenance conditional cases
Browse files Browse the repository at this point in the history
Functions accepting a `KnownProvenance` often only
handle the two explicit cases of `Artifact` or
`RepositoryProvenance`.
Appropriate else cases were added to conditional
`when`s.

Signed-off-by: Jens Keim <jens.keim@forvia.com>
  • Loading branch information
pepper-jk committed Nov 20, 2024
1 parent dfc74ab commit 39d170a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions model/src/main/kotlin/config/PackageConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ data class PackageConfiguration(
is UnknownProvenance -> false
is ArtifactProvenance -> sourceArtifactUrl != null && sourceArtifactUrl == provenance.sourceArtifact.url
is RepositoryProvenance -> vcs != null && vcs.matches(provenance)
else -> false
}
}
}
Expand Down
1 change: 1 addition & 0 deletions model/src/main/kotlin/licenses/LicenseInfoResolver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ class LicenseInfoResolver(
when (provenance) {
is UnknownProvenance -> return@forEach
is RemoteProvenance -> if (!archiver.unarchive(archiveDir, provenance)) return@forEach
else -> return@forEach
}

val directory = (provenance as? RepositoryProvenance)?.vcsInfo?.path.orEmpty()
Expand Down
2 changes: 2 additions & 0 deletions model/src/main/kotlin/utils/PurlExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ fun Provenance.toPurlExtras(): PurlExtras =
}

is UnknownProvenance -> PurlExtras()

else -> PurlExtras()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class DefaultNestedProvenanceResolver(
return when (provenance) {
is ArtifactProvenance -> NestedProvenance(root = provenance, subRepositories = emptyMap())
is RepositoryProvenance -> resolveNestedRepository(provenance)
else -> NestedProvenance(root = provenance, subRepositories = emptyMap())
}
}

Expand Down

0 comments on commit 39d170a

Please sign in to comment.