From 1086b7f05632e622ed593b6cacc9cf9f198f0800 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 25 Jul 2023 10:02:58 +0200 Subject: [PATCH] Use `maxBy` instead of `maxByOrNull` to avoid a not-null assertion --- .../kotlin/com/github/ajalt/clikt/parameters/options/Option.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/parameters/options/Option.kt b/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/parameters/options/Option.kt index 00aae509..27a7c206 100644 --- a/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/parameters/options/Option.kt +++ b/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/parameters/options/Option.kt @@ -122,7 +122,7 @@ internal fun inferOptionNames(names: Set, propertyName: String): Set, 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() }