Skip to content

Commit

Permalink
Use maxBy instead of maxByOrNull to avoid a not-null assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
sschuberth authored and ajalt committed Jul 25, 2023
1 parent 5df6364 commit 1086b7f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ internal fun inferOptionNames(names: Set<String>, propertyName: String): Set<Str
internal fun inferEnvvar(names: Set<String>, envvar: String?, autoEnvvarPrefix: String?): String? {
if (envvar != null) return envvar
if (names.isEmpty() || autoEnvvarPrefix == null) return null
val name = splitOptionPrefix(names.maxByOrNull { it.length }!!).second
val name = splitOptionPrefix(names.maxBy { it.length }).second
if (name.isEmpty()) return null
return autoEnvvarPrefix + "_" + name.replace(Regex("\\W"), "_").uppercase()
}
Expand Down

0 comments on commit 1086b7f

Please sign in to comment.