Skip to content

Commit

Permalink
Merge pull request #133 from xuwei-k/return
Browse files Browse the repository at this point in the history
avoid `return`
  • Loading branch information
eed3si9n authored Oct 14, 2024
2 parents 425fcae + 5c55005 commit 74d10fb
Showing 1 changed file with 15 additions and 12 deletions.
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

0 comments on commit 74d10fb

Please sign in to comment.