Detekt: enable rule exceptions.SwallowedException and fix existing issue.

This commit is contained in:
Benoit Marty
2025-12-05 09:45:23 +01:00
parent a9afa59053
commit 72b3decf4c
16 changed files with 20 additions and 20 deletions

View File

@@ -60,7 +60,7 @@ fun Activity.openUrlInChromeCustomTab(
})
}
.launchUrl(this, url.toUri())
} catch (activityNotFoundException: ActivityNotFoundException) {
} catch (_: ActivityNotFoundException) {
openUrlInExternalApp(url)
}
}

View File

@@ -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()
}

View File

@@ -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)
}
}