Skip to content

Commit

Permalink
refactor(Repository): Make vcs and vcsProcessed val using @JsonIg…
Browse files Browse the repository at this point in the history
…nore

Will be squashed later.

Signed-off-by: Jens Keim <jens.keim@forvia.com>
  • Loading branch information
pepper-jk committed Jun 27, 2024
1 parent 5ba7d76 commit ca44715
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion evaluator/src/main/kotlin/ProjectSourceRule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ open class ProjectSourceRule(
/**
* Return the [VcsType] of the project's code repository.
*/
fun projectSourceGetVcsType(): VcsType = ortResult.repository.vcsProcessed().type
fun projectSourceGetVcsType(): VcsType = ortResult.repository.vcsProcessed.type

/**
* Return the file paths matching any of the given [glob expressions][patterns] with its file content matching
Expand Down
2 changes: 1 addition & 1 deletion evaluator/src/main/kotlin/RuleSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fun ruleSet(
licenseInfoResolver: LicenseInfoResolver = ortResult.createLicenseInfoResolver(),
resolutionProvider: ResolutionProvider = DefaultResolutionProvider.create(),
projectSourceResolver: SourceTreeResolver = SourceTreeResolver.forRemoteRepository(
ortResult.repository.vcsProcessed()
ortResult.repository.vcsProcessed
),
configure: RuleSet.() -> Unit = { }
) = RuleSet(ortResult, licenseInfoResolver, resolutionProvider, projectSourceResolver).apply(configure)
2 changes: 1 addition & 1 deletion helper-cli/src/main/kotlin/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ internal fun OrtResult.getScanResultFor(packageConfiguration: PackageConfigurati
* tree.
*/
internal fun OrtResult.getRepositoryPaths(): Map<String, Set<String>> {
val result = mutableMapOf(repository.vcsProcessed().url to mutableSetOf(""))
val result = mutableMapOf(repository.vcsProcessed.url to mutableSetOf(""))

repository.nestedRepositories.mapValues { (path, provenance) ->
if (provenance is RepositoryProvenance) {
Expand Down
17 changes: 11 additions & 6 deletions model/src/main/kotlin/Repository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.ossreviewtoolkit.model

import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonInclude

import org.ossreviewtoolkit.model.config.RepositoryConfiguration
Expand Down Expand Up @@ -57,14 +58,18 @@ data class Repository(
)
}

fun vcs(): VcsInfo {
if (provenance is RepositoryProvenance) { return provenance.vcsInfo }
return VcsInfo.EMPTY
@JsonIgnore
val vcs = if (provenance is RepositoryProvenance) {
provenance.vcsInfo
} else {
VcsInfo.EMPTY
}

fun vcsProcessed(): VcsInfo {
if (provenance is RepositoryProvenance) { return provenance.vcsInfo.normalize() }
return VcsInfo.EMPTY
@JsonIgnore
val vcsProcessed = if (provenance is RepositoryProvenance) {
provenance.vcsInfo.normalize()
} else {
VcsInfo.EMPTY
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class CycloneDxReporter : Reporter {
// distributable), just create a single BOM for all projects in that case for now. As there also is no
// single correct project to pick for adding external references in that case, simply only use the global
// repository VCS information here.
val vcs = input.ortResult.repository.vcsProcessed()
val vcs = input.ortResult.repository.vcsProcessed
bom.addExternalReference(
ExternalReference.Type.VCS,
vcs.url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ class OpossumReporter : Reporter {
internal fun generateOpossumInput(input: ReporterInput, maxDepth: Int = Int.MAX_VALUE): OpossumInput {
val opossumInput = OpossumInput()

opossumInput.addBaseUrl("/", input.ortResult.repository.vcs())
opossumInput.addBaseUrl("/", input.ortResult.repository.vcs)

SpdxLicense.entries.forEach {
val licenseText = input.licenseTextProvider.getLicenseText(it.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal object TablesReportModelMapper {
.sortedBy { it.id }

return TablesReport(
input.ortResult.repository.vcsProcessed(),
input.ortResult.repository.vcsProcessed,
input.ortResult.repository.config,
ruleViolations,
getAnalyzerIssueSummaryTable(input),
Expand Down

0 comments on commit ca44715

Please sign in to comment.