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`.
Add `else` cases to conditional `when`s.

Signed-off-by: Jens Keim <[email protected]>
  • Loading branch information
pepper-jk committed Nov 26, 2024
1 parent 2d70747 commit 7a6f396
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

Check warning on line 80 in model/src/main/kotlin/config/PackageConfiguration.kt

View check run for this annotation

Codecov / codecov/patch

model/src/main/kotlin/config/PackageConfiguration.kt#L80

Added line #L80 was not covered by tests
}
}
}
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

Check warning on line 268 in model/src/main/kotlin/licenses/LicenseInfoResolver.kt

View check run for this annotation

Codecov / codecov/patch

model/src/main/kotlin/licenses/LicenseInfoResolver.kt#L268

Added line #L268 was not covered by tests
}

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())

Check warning on line 53 in scanner/src/main/kotlin/provenance/NestedProvenanceResolver.kt

View check run for this annotation

Codecov / codecov/patch

scanner/src/main/kotlin/provenance/NestedProvenanceResolver.kt#L53

Added line #L53 was not covered by tests
}
}

Expand Down

0 comments on commit 7a6f396

Please sign in to comment.