Detekt: enable rule exceptions.SwallowedException and fix existing issue.
This commit is contained in:
@@ -71,7 +71,7 @@ class DefaultPinCodeManager(
|
||||
lockScreenStore.onWrongPin()
|
||||
}
|
||||
}
|
||||
} catch (failure: Throwable) {
|
||||
} catch (_: Throwable) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ fun EventDebugInfoView(
|
||||
private fun prettyJSON(maybeJSON: String): String {
|
||||
return try {
|
||||
JSONObject(maybeJSON).toString(2)
|
||||
} catch (e: JSONException) {
|
||||
} catch (_: JSONException) {
|
||||
// Prefer not pretty-printing over crashing if the data is not actually JSON
|
||||
maybeJSON
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ fun Activity.openUrlInChromeCustomTab(
|
||||
})
|
||||
}
|
||||
.launchUrl(this, url.toUri())
|
||||
} catch (activityNotFoundException: ActivityNotFoundException) {
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
openUrlInExternalApp(url)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ fun String.hash() = try {
|
||||
digest.digest()
|
||||
.joinToString("") { String.format(Locale.ROOT, "%02X", it) }
|
||||
.lowercase(Locale.ROOT)
|
||||
} catch (exc: Exception) {
|
||||
} catch (_: Exception) {
|
||||
// Should not happen, but just in case
|
||||
hashCode().toString()
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ fun Context.getApplicationLabel(packageName: String): String {
|
||||
return try {
|
||||
val ai = packageManager.getApplicationInfoCompat(packageName, 0)
|
||||
packageManager.getApplicationLabel(ai).toString()
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
} catch (_: PackageManager.NameNotFoundException) {
|
||||
packageName
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ fun Context.startNotificationSettingsIntent(
|
||||
} else {
|
||||
startActivity(intent)
|
||||
}
|
||||
} catch (activityNotFoundException: ActivityNotFoundException) {
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
toast(noActivityFoundMessage)
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ fun Context.openAppSettingsPage(
|
||||
data = Uri.fromParts("package", packageName, null)
|
||||
}
|
||||
)
|
||||
} catch (activityNotFoundException: ActivityNotFoundException) {
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
toast(noActivityFoundMessage)
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ fun Context.startInstallFromSourceIntent(
|
||||
.setData("package:$packageName".toUri())
|
||||
try {
|
||||
activityResultLauncher.launch(intent)
|
||||
} catch (activityNotFoundException: ActivityNotFoundException) {
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
toast(noActivityFoundMessage)
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ fun Context.startSharePlainTextIntent(
|
||||
} else {
|
||||
startActivity(intent)
|
||||
}
|
||||
} catch (activityNotFoundException: ActivityNotFoundException) {
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
toast(noActivityFoundMessage)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ fun String.md5() = try {
|
||||
digest.digest()
|
||||
.joinToString("") { String.format(locale, "%02X", it) }
|
||||
.lowercase(locale)
|
||||
} catch (exc: Exception) {
|
||||
} catch (_: Exception) {
|
||||
// Should not happen, but just in case
|
||||
hashCode().toString()
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ fun String.isValidUrl(): Boolean {
|
||||
return try {
|
||||
URI(this).toURL()
|
||||
true
|
||||
} catch (t: Throwable) {
|
||||
} catch (_: Throwable) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class FullScreenIntentPermissionsPresenter(
|
||||
"package:${buildMeta.applicationId}".toUri()
|
||||
)
|
||||
externalIntentLauncher.launch(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
val intent = Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
|
||||
.putExtra(Settings.EXTRA_APP_PACKAGE, buildMeta.applicationId)
|
||||
externalIntentLauncher.launch(intent)
|
||||
|
||||
@@ -65,7 +65,7 @@ suspend fun RoomList.awaitLoaded(timeout: Duration = Duration.INFINITE) {
|
||||
it is RoomList.LoadingState.Loaded
|
||||
}
|
||||
}
|
||||
} catch (timeoutException: TimeoutCancellationException) {
|
||||
} catch (_: TimeoutCancellationException) {
|
||||
Timber.d("awaitAllRoomsAreLoaded: no response after $timeout")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class RoomSyncSubscriber(
|
||||
}
|
||||
subscribedRoomIds.add(roomId)
|
||||
} catch (exception: Exception) {
|
||||
Timber.e("Failed to subscribe to room $roomId")
|
||||
Timber.e(exception, "Failed to subscribe to room $roomId")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ fun RoomListInterface.loadingStateFlow(): Flow<RoomListLoadingState> =
|
||||
try {
|
||||
send(result.state)
|
||||
} catch (exception: Exception) {
|
||||
Timber.d("loadingStateFlow() initialState failed.")
|
||||
Timber.d(exception, "loadingStateFlow() initialState failed.")
|
||||
}
|
||||
result.stateStream
|
||||
}.catch {
|
||||
|
||||
@@ -62,7 +62,7 @@ class RustWidgetDriver(
|
||||
override suspend fun send(message: String) {
|
||||
try {
|
||||
driverAndHandle.handle.send(message)
|
||||
} catch (e: IllegalStateException) {
|
||||
} catch (_: IllegalStateException) {
|
||||
// The handle is closed, ignore
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class PushLoopbackTest(
|
||||
}
|
||||
val testPushResult = try {
|
||||
pushService.testPush(sessionId)
|
||||
} catch (pusherRejected: PushGatewayFailure.PusherRejected) {
|
||||
} catch (_: PushGatewayFailure.PusherRejected) {
|
||||
val hasQuickFix = pushService.getCurrentPushProvider(sessionId)?.canRotateToken() == true
|
||||
delegate.updateState(
|
||||
description = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_failure_1),
|
||||
|
||||
@@ -40,7 +40,7 @@ class SharedPreferencesFirebaseStore(
|
||||
if (k == PREFS_KEY_FCM_TOKEN) {
|
||||
try {
|
||||
flow.value = getFcmToken()
|
||||
} catch (e: Exception) {
|
||||
} catch (_: Exception) {
|
||||
flow.value = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ suspend fun awaitWithLatch(timeout: Duration = 300.milliseconds, block: (Complet
|
||||
withTimeout(timeout) {
|
||||
latch.also(block).await()
|
||||
}
|
||||
} catch (exception: TimeoutCancellationException) {
|
||||
} catch (_: TimeoutCancellationException) {
|
||||
latch.complete(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ exceptions:
|
||||
TooGenericExceptionCaught:
|
||||
active: false
|
||||
SwallowedException:
|
||||
active: false
|
||||
active: true
|
||||
ThrowingExceptionsWithoutMessageOrCause:
|
||||
active: true
|
||||
TooGenericExceptionThrown:
|
||||
|
||||
Reference in New Issue
Block a user