From c04c3ee8110ffcdb52c3fa77d3045931437f05b3 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Wed, 13 Dec 2023 12:21:41 +0100 Subject: [PATCH] refactor(model): Make a function signature a bit more speaking From the signature it's been unclear what the `String` property is about. Signed-off-by: Frank Viernau --- .../licenses/DefaultLicenseInfoProvider.kt | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/model/src/main/kotlin/licenses/DefaultLicenseInfoProvider.kt b/model/src/main/kotlin/licenses/DefaultLicenseInfoProvider.kt index 8430407735aac..04951bbb899cf 100644 --- a/model/src/main/kotlin/licenses/DefaultLicenseInfoProvider.kt +++ b/model/src/main/kotlin/licenses/DefaultLicenseInfoProvider.kt @@ -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, 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, + val pathExcludes: List, + val relativeFindingsPath: String +)