Skip to content

Commit 3309b35

Browse files
committed
refactor(tools/curations): Extract two variables
Reduce the diff of an upcoming change. While at it, use more speaking names for `it`. Signed-off-by: Frank Viernau <[email protected]>
1 parent 115a106 commit 3309b35

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

tools/curations/buildSrc/src/main/kotlin/ScanCodeLicenseDbClassifications.kt

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,25 @@ private fun LicenseDetails.getCategories(): Set<String> {
162162
)
163163
}
164164

165-
private fun getLicenseClassifications(licenseDetails: Collection<LicenseDetails>) =
166-
LicenseClassifications(
167-
categories = licenseDetails.flatMap { it.getCategories() }.distinct().map {
168-
LicenseCategory(it)
169-
}.sortedBy { it.name },
170-
categorizations = licenseDetails.map {
171-
LicenseCategorization(
172-
id = it.getLicenseId(),
173-
categories = it.getCategories()
174-
)
175-
}.sortedBy { it.id.toString() }
165+
private fun getLicenseClassifications(licenseDetails: Collection<LicenseDetails>): LicenseClassifications {
166+
val categories = licenseDetails.flatMap { details ->
167+
details.getCategories()
168+
}.distinct().map { category ->
169+
LicenseCategory(category)
170+
}
171+
172+
val categorizations = licenseDetails.map { details ->
173+
LicenseCategorization(
174+
id = details.getLicenseId(),
175+
categories = details.getCategories()
176+
)
177+
}
178+
179+
return LicenseClassifications(
180+
categories = categories.sortedBy { it.name },
181+
categorizations = categorizations.sortedBy { it.id.toString() }
176182
)
183+
}
177184

178185
/**
179186
* Generate license classifications from ScanCode's license categories.

0 commit comments

Comments
 (0)