Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

license-classifications: Improve what gets assigned to the 'include-in-notice-file' category #81

Merged
merged 2 commits into from
Nov 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ private val CONTRIBUTOR_LICENSE_AGREEMENT_IDS = listOf(
"LicenseRef-scancode-square-cla"
).map { SpdxSingleLicenseExpression.parse(it) }.toSet()

private const val CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT = "contributor-license-agreement"
private const val CATEGORY_GENERIC = "generic"
private const val CATEGORY_UNKNOWN = "unknown"
Comment on lines +61 to +62
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The extraction of these constants is unrelated to the commit topic.


private data class License(
val licenseKey: String,
val spdxLicenseKey: String? = null,
Expand Down Expand Up @@ -146,16 +150,18 @@ private fun LicenseDetails.getLicenseId(): SpdxSingleLicenseExpression {

private fun LicenseDetails.getCategories(): Set<String> {
val mappedCategory = when {
isUnknown -> "unknown"
isGeneric -> "generic"
getLicenseId() in CONTRIBUTOR_LICENSE_AGREEMENT_IDS -> "contributor-license-agreement"
isUnknown -> CATEGORY_UNKNOWN
isGeneric -> CATEGORY_GENERIC
getLicenseId() in CONTRIBUTOR_LICENSE_AGREEMENT_IDS -> CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT
else -> category.replace(' ', '-').toLowerCase()
}

return setOfNotNull(
mappedCategory,
// Include all licenses into the notice file to ensure there is no under-reporting by default.
"include-in-notice-file",
"include-in-notice-file".takeUnless {
mappedCategory in setOf(CATEGORY_UNKNOWN, CATEGORY_GENERIC, CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT)
},
// The FSF has stated that a source code offer is required for Copyleft (limited) licences, so
// include only these to not cause unnecessary effort by default.
"include-source-code-offer-in-notice-file".takeIf { mappedCategory in setOf("copyleft", "copyleft-limited") }
Expand Down