Detekt: Use require() instead of throwing an IllegalArgumentException. [UseRequire]
This commit is contained in:
parent
3dccad9931
commit
ebbfca4ffd
|
@ -83,9 +83,7 @@ internal class CrossSigningOlm @Inject constructor(
|
|||
val signaturesMadeByMyKey = signatures[myUserID] // Signatures made by me
|
||||
?.get("ed25519:$pubKey")
|
||||
|
||||
if (signaturesMadeByMyKey.isNullOrBlank()) {
|
||||
throw IllegalArgumentException("Not signed with my key $type")
|
||||
}
|
||||
require(signaturesMadeByMyKey.orEmpty().isNotBlank()) { "Not signed with my key $type" }
|
||||
|
||||
// Check that Alice USK signature of Bob MSK is valid
|
||||
olmUtility.verifyEd25519Signature(signaturesMadeByMyKey, pubKey, JsonCanonicalizer.getCanonicalJson(Map::class.java, signable))
|
||||
|
|
|
@ -47,9 +47,8 @@ internal class DefaultEncryptEventTask @Inject constructor(
|
|||
// don't want to wait for any query
|
||||
// if (!params.crypto.isRoomEncrypted(params.roomId)) return params.event
|
||||
val localEvent = params.event
|
||||
if (localEvent.eventId == null || localEvent.type == null) {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
require(localEvent.eventId != null)
|
||||
require(localEvent.type != null)
|
||||
|
||||
localEchoRepository.updateSendState(localEvent.eventId, localEvent.roomId, SendState.ENCRYPTING)
|
||||
|
||||
|
|
|
@ -1140,7 +1140,7 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
override fun beginKeyVerification(method: VerificationMethod, otherUserId: String, otherDeviceId: String, transactionId: String?): String? {
|
||||
val txID = transactionId?.takeIf { it.isNotEmpty() } ?: createUniqueIDForTransaction(otherUserId, otherDeviceId)
|
||||
// should check if already one (and cancel it)
|
||||
if (method == VerificationMethod.SAS) {
|
||||
require(method == VerificationMethod.SAS) { "Unknown verification method" }
|
||||
val tx = DefaultOutgoingSASDefaultVerificationTransaction(
|
||||
setDeviceVerificationAction,
|
||||
userId,
|
||||
|
@ -1159,9 +1159,6 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
|
||||
tx.start()
|
||||
return txID
|
||||
} else {
|
||||
throw IllegalArgumentException("Unknown verification method")
|
||||
}
|
||||
}
|
||||
|
||||
override fun requestKeyVerificationInDMs(
|
||||
|
@ -1343,7 +1340,7 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
otherUserId: String,
|
||||
otherDeviceId: String
|
||||
): String {
|
||||
if (method == VerificationMethod.SAS) {
|
||||
require(method == VerificationMethod.SAS) { "Unknown verification method" }
|
||||
val tx = DefaultOutgoingSASDefaultVerificationTransaction(
|
||||
setDeviceVerificationAction,
|
||||
userId,
|
||||
|
@ -1362,9 +1359,6 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
|
||||
tx.start()
|
||||
return transactionId
|
||||
} else {
|
||||
throw IllegalArgumentException("Unknown verification method")
|
||||
}
|
||||
}
|
||||
|
||||
override fun readyPendingVerificationInDMs(
|
||||
|
|
|
@ -37,9 +37,7 @@ class VectorViewModelFactory @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
if (creator == null) {
|
||||
throw IllegalArgumentException("Unknown model class: $modelClass")
|
||||
}
|
||||
require(creator != null) { "Unknown model class: $modelClass" }
|
||||
try {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return creator.get() as T
|
||||
|
|
Loading…
Reference in New Issue