From c9d5ba988718cc5fe934ccdde87672449306da8a Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 30 Oct 2024 09:36:23 +0100 Subject: [PATCH] reduce code complexity Signed-off-by: Pablo --- .../kotlin/org/hisp/dhis/rules/models/RuleVariable.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/commonMain/kotlin/org/hisp/dhis/rules/models/RuleVariable.kt b/src/commonMain/kotlin/org/hisp/dhis/rules/models/RuleVariable.kt index 651decba..e12ab29b 100644 --- a/src/commonMain/kotlin/org/hisp/dhis/rules/models/RuleVariable.kt +++ b/src/commonMain/kotlin/org/hisp/dhis/rules/models/RuleVariable.kt @@ -16,10 +16,7 @@ interface RuleVariable { ): RuleVariableValue fun getOptionName(value: String): String { - // if no option found then existing value in the context will be used return options - .filter { (_, code): Option -> value == code } - .map(Option::name) - .getOrElse(0) { _ -> value } + .find { (_, code): Option -> value == code }?.name ?: value } }