Repository: corona-warn-app/cwa-app-android
File: Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/CWAConfigMapper.kt (Kotlin)

Code before:
                ?.takeIf { it >= 0 }
                ?: DCC_PERSON_COUNT_MAX
        } catch (e: Exception) {
            Timber.e(e, "Failed to find `dcc-person-count-max` from %s", this)
            DCC_PERSON_COUNT_MAX
        }
    }

    private fun ApplicationConfigurationAndroid.dccAdmissionCheckScenariosDisabled() = findBoolean(
        labelValue = "dcc-admission-check-scenarios-disabled",
        defaultValue = DCC_ADMISSION_CHECK_SCENARIOS_DISABLED
    )

    private fun ApplicationConfigurationAndroid.findBoolean(labelValue: String, defaultValue: Boolean): Boolean {
        if (!hasAppFeatures()) return defaultValue

        return try {
            val value = (0 until appFeatures.appFeaturesCount)
                .map { appFeatures.getAppFeatures(it) }
                .firstOrNull { it.label == labelValue }
                ?.value

            return when (value) {
                null -> defaultValue // no item found
                1 -> true // found item has value '1'
                else -> defaultValue // found item has value different to '1'
            }
        } catch (e: Exception) {
            Timber.e(e, "Failed to find `%s` from %s", labelValue, this)
            defaultValue
        }
    }

    data class CWAConfigContainer(
        override val latestVersionCode: Long,
        override val minVersionCode: Long,
        override val supportedCountries: List<String>,
        override val isDeviceTimeCheckEnabled: Boolean,
        override val isUnencryptedCheckInsEnabled: Boolean,
        override val validationServiceMinVersion: Int,
        override val dccPersonWarnThreshold: Int,
        override val dccPersonCountMax: Int,
        override val admissionScenariosEnabled: Boolean,
    ) : CWAConfig

    companion object {
        private val VALID_CC = "^([A-Z]{2,3})$".toRegex()
        private const val DEFAULT_VALIDATION_SERVICE_MIN_VERSION = 0

        private const val DCC_PERSON_WARN_THRESHOLD: Int = 10
        private const val DCC_PERSON_COUNT_MAX: Int = 20

Review comment (suggestion):
I think this was/can be  covered by 
```kotlin 
 ?.let { it.value == 1 } ?: defaultValue
```

Code after:
        } catch (e: Exception) {
            Timber.e(e, "Failed to find `dcc-person-count-max` from %s", this)
            DCC_PERSON_COUNT_MAX
        }
    }

    private fun ApplicationConfigurationAndroid.dccAdmissionCheckScenariosDisabled() = findBoolean(
        labelValue = "dcc-admission-check-scenarios-disabled"
    )

    private fun ApplicationConfigurationAndroid.findBoolean(
        labelValue: String,
        defaultValue: Boolean = false
    ): Boolean {
        if (!hasAppFeatures()) return defaultValue

        return try {
            val value = (0 until appFeatures.appFeaturesCount)
                .map { appFeatures.getAppFeatures(it) }
                .firstOrNull { it.label == labelValue }
                ?.value

            return when (value) {
                null -> defaultValue // no item found
                1 -> true // found item has value '1'
                else -> defaultValue // found item has value different to '1'
            }
        } catch (e: Exception) {
            Timber.e(e, "Failed to find `%s` from %s", labelValue, this)
            defaultValue
        }
    }

    data class CWAConfigContainer(
        override val latestVersionCode: Long,
        override val minVersionCode: Long,
        override val supportedCountries: List<String>,
        override val isDeviceTimeCheckEnabled: Boolean,
        override val isUnencryptedCheckInsEnabled: Boolean,
        override val validationServiceMinVersion: Int,
        override val dccPersonWarnThreshold: Int,
        override val dccPersonCountMax: Int,
        override val admissionScenariosEnabled: Boolean,
    ) : CWAConfig

    companion object {
        private val VALID_CC = "^([A-Z]{2,3})$".toRegex()
        private const val DEFAULT_VALIDATION_SERVICE_MIN_VERSION = 0

        private const val DCC_PERSON_WARN_THRESHOLD: Int = 10
        private const val DCC_PERSON_COUNT_MAX: Int = 20