@@ -147,20 +147,23 @@ object LicenseReport {
147147 // Even though the url is optional this field seems to always exist
148148 val licensesWithUrls = licenses.collect { case (name, Some (url)) => (name, url) }
149149 if (licensesWithUrls.isEmpty) {
150- return LicenseInfo (LicenseCategory .NoneSpecified , " " , " " )
151- }
152- // We look for a license matching the category in the order they are defined.
153- // i.e. the user selects the licenses they prefer to use, in order, if an artifact is dual-licensed (or more)
154- for (category <- categories) {
155- for (license <- licensesWithUrls) {
156- val (name, url) = license
157- if (category.unapply(name)) {
158- return LicenseInfo (category, name, url)
150+ LicenseInfo (LicenseCategory .NoneSpecified , " " , " " )
151+ } else {
152+ // We look for a license matching the category in the order they are defined.
153+ // i.e. the user selects the licenses they prefer to use, in order, if an artifact is dual-licensed (or more)
154+ categories
155+ .flatMap(category =>
156+ licensesWithUrls.collectFirst {
157+ case (name, url) if category.unapply(name) =>
158+ LicenseInfo (category, name, url)
159+ }
160+ )
161+ .headOption
162+ .getOrElse {
163+ val license = licensesWithUrls(0 )
164+ LicenseInfo (LicenseCategory .Unrecognized , license._1, license._2)
159165 }
160- }
161166 }
162- val license = licensesWithUrls(0 )
163- LicenseInfo (LicenseCategory .Unrecognized , license._1, license._2)
164167 }
165168
166169 /** Picks a single license (or none) for this dependency. */
0 commit comments