Skip to content

Commit e78f0db

Browse files
committed
refactor(tools/curations): Factor out addExtraCategories()
Enable re-use in an upcoming change. Signed-off-by: Frank Viernau <[email protected]>
1 parent 231d4c7 commit e78f0db

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,20 @@ private fun LicenseDetails.getCategories(): Set<String> {
154154
else -> category.replace(' ', '-').lowercase()
155155
}
156156

157-
return setOfNotNull(
158-
mappedCategory,
157+
return addExtraCategories(mappedCategory) + mappedCategory
158+
}
159+
160+
private fun addExtraCategories(category: String): Set<String> =
161+
setOfNotNull(
162+
category,
159163
// Include all licenses into the notice file to ensure there is no under-reporting by default.
160164
"include-in-notice-file".takeUnless {
161-
mappedCategory in setOf(CATEGORY_UNKNOWN, CATEGORY_GENERIC, CATEGORY_CLA)
165+
category in setOf(CATEGORY_UNKNOWN, CATEGORY_GENERIC, CATEGORY_CLA)
162166
},
163167
// The FSF has stated that a source code offer is required for Copyleft (limited) licences, so
164168
// include only these to not cause unnecessary effort by default.
165-
"include-source-code-offer-in-notice-file".takeIf { mappedCategory in setOf("copyleft", "copyleft-limited") }
169+
"include-source-code-offer-in-notice-file".takeIf { category in setOf("copyleft", "copyleft-limited") }
166170
)
167-
}
168171

169172
private fun getLicenseClassifications(licenseDetails: Collection<LicenseDetails>): LicenseClassifications {
170173
val categories = licenseDetails.flatMap { details ->

0 commit comments

Comments
 (0)