From 9e3679cbd67b96ebf1807e0aed293c6328cd723b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 26 Jul 2023 10:18:28 +0200 Subject: [PATCH] Enable detekt rule `UseCheckOrError` and fix existing issues (and a potential crash on MapboxMap?). --- .../confirmaccountprovider/ConfirmAccountProviderPresenter.kt | 2 +- .../io/element/android/libraries/maplibre/compose/MapboxMap.kt | 2 +- .../matrix/impl/auth/RustMatrixAuthenticationService.kt | 2 +- tools/detekt/detekt.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/confirmaccountprovider/ConfirmAccountProviderPresenter.kt b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/confirmaccountprovider/ConfirmAccountProviderPresenter.kt index 123d3013c7..1a021ad605 100644 --- a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/confirmaccountprovider/ConfirmAccountProviderPresenter.kt +++ b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/confirmaccountprovider/ConfirmAccountProviderPresenter.kt @@ -92,7 +92,7 @@ class ConfirmAccountProviderPresenter @AssistedInject constructor( } else if (matrixHomeServerDetails.supportsPasswordLogin) { LoginFlow.PasswordLogin } else { - throw IllegalStateException("Unsupported login flow") + error("Unsupported login flow") } }.getOrThrow() }.runCatchingUpdatingState(loginFlowAction, errorTransform = ChangeServerError::from) diff --git a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMap.kt b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMap.kt index c67be52c1c..82b5e1c237 100644 --- a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMap.kt +++ b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMap.kt @@ -236,7 +236,7 @@ private fun MapView.lifecycleObserver(previousState: MutableState { //handled in onDispose } - else -> throw IllegalStateException() + Lifecycle.Event.ON_ANY -> Unit } previousState.value = event } diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationService.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationService.kt index 0bc299d020..71e6e730e5 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationService.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationService.kt @@ -93,7 +93,7 @@ class RustMatrixAuthenticationService @Inject constructor( client.restoreSession(sessionData.toSession()) createMatrixClient(client) } else { - throw IllegalStateException("No session to restore with id $sessionId") + error("No session to restore with id $sessionId") } }.mapFailure { failure -> failure.mapClientException() diff --git a/tools/detekt/detekt.yml b/tools/detekt/detekt.yml index 0ed13accdb..79d8d5fe51 100644 --- a/tools/detekt/detekt.yml +++ b/tools/detekt/detekt.yml @@ -38,7 +38,7 @@ style: ProtectedMemberInFinalClass: active: false UseCheckOrError: - active: false + active: true empty-blocks: EmptyFunctionBlock: