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

avoid return #133

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
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
27 changes: 15 additions & 12 deletions src/main/scala/sbtlicensereport/license/LicenseReport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,23 @@ object LicenseReport {
// Even though the url is optional this field seems to always exist
val licensesWithUrls = licenses.collect { case (name, Some(url)) => (name, url) }
if (licensesWithUrls.isEmpty) {
return LicenseInfo(LicenseCategory.NoneSpecified, "", "")
}
// We look for a license matching the category in the order they are defined.
// i.e. the user selects the licenses they prefer to use, in order, if an artifact is dual-licensed (or more)
for (category <- categories) {
for (license <- licensesWithUrls) {
val (name, url) = license
if (category.unapply(name)) {
return LicenseInfo(category, name, url)
LicenseInfo(LicenseCategory.NoneSpecified, "", "")
} else {
// We look for a license matching the category in the order they are defined.
// i.e. the user selects the licenses they prefer to use, in order, if an artifact is dual-licensed (or more)
categories
.flatMap(category =>
licensesWithUrls.collectFirst {
case (name, url) if category.unapply(name) =>
LicenseInfo(category, name, url)
}
)
.headOption
.getOrElse {
val license = licensesWithUrls(0)
LicenseInfo(LicenseCategory.Unrecognized, license._1, license._2)
}
}
}
val license = licensesWithUrls(0)
LicenseInfo(LicenseCategory.Unrecognized, license._1, license._2)
}

/** Picks a single license (or none) for this dependency. */
Expand Down