Skip to content

Commit

Permalink
refactor(model): Make a function signature a bit more speaking
Browse files Browse the repository at this point in the history
From the signature it's been unclear what the `String` property is
about.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Dec 13, 2023
1 parent 221cad8 commit c04c3ee
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions model/src/main/kotlin/licenses/DefaultLicenseInfoProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,36 +90,39 @@ class DefaultLicenseInfoProvider(
// turn around time / without re-scanning.
it.filterByVcsPath(ortResult.getPackage(id)?.metadata?.vcsProcessed?.path.orEmpty())
}.forEach { (provenance, _, summary, _) ->
val (licenseFindingCurations, pathExcludes, relativeFindingsPath) = getConfiguration(id, provenance)
val config = getConfiguration(id, provenance)

findings += Findings(
provenance = provenance,
licenses = summary.licenseFindings,
copyrights = summary.copyrightFindings,
licenseFindingCurations = licenseFindingCurations,
pathExcludes = pathExcludes,
relativeFindingsPath = relativeFindingsPath
licenseFindingCurations = config.licenseFindingCurations,
pathExcludes = config.pathExcludes,
relativeFindingsPath = config.relativeFindingsPath
)
}

return DetectedLicenseInfo(findings)
}

private fun getConfiguration(
id: Identifier,
provenance: Provenance
): Triple<List<LicenseFindingCuration>, List<PathExclude>, String> =
private fun getConfiguration(id: Identifier, provenance: Provenance): Configuration =
ortResult.getProject(id)?.let { project ->
Triple(
Configuration(
ortResult.repository.config.curations.licenseFindings,
ortResult.repository.config.excludes.paths,
ortResult.repository.getRelativePath(project.vcsProcessed).orEmpty()
)
} ?: packageConfigurationProvider.getPackageConfigurations(id, provenance).let { packageConfigurations ->
Triple(
Configuration(
packageConfigurations.flatMap { it.licenseFindingCurations },
packageConfigurations.flatMap { it.pathExcludes },
""
)
}
}

private data class Configuration(
val licenseFindingCurations: List<LicenseFindingCuration>,
val pathExcludes: List<PathExclude>,
val relativeFindingsPath: String
)

0 comments on commit c04c3ee

Please sign in to comment.