refactor(sonar): replace if/throw with require/error
Sonar — replace hand-rolled 'throw IllegalArgumentException' / 'throw
IllegalStateException' with the idiomatic 'require { msg }' / 'error(msg)'.
Exception types preserved exactly (require throws IAE, error throws ISE).
This commit is contained in:
+1
-3
@@ -200,9 +200,7 @@ class OwnedEmojiPacksState(
|
||||
isPrivate: Boolean,
|
||||
account: Account,
|
||||
) {
|
||||
if (!EmojiUrlTag.isValidShortcode(emojiTag.code)) {
|
||||
throw IllegalArgumentException("Invalid emoji shortcode: ${emojiTag.code}")
|
||||
}
|
||||
require(EmojiUrlTag.isValidShortcode(emojiTag.code)) { "Invalid emoji shortcode: ${emojiTag.code}" }
|
||||
|
||||
val packEvent = getOwnedEmojiPackEvent(dTag) ?: return
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ tailrec fun Context.getActivity(): ComponentActivity =
|
||||
when (this) {
|
||||
is ComponentActivity -> this
|
||||
is ContextWrapper -> baseContext.getActivity()
|
||||
else -> throw IllegalStateException("Requires a ComponentActivity to run")
|
||||
else -> error("Requires a ComponentActivity to run")
|
||||
}
|
||||
|
||||
fun Context.getActivityOrNull(): ComponentActivity? =
|
||||
|
||||
Reference in New Issue
Block a user