detekt fix

This commit is contained in:
Valere 2023-10-10 16:25:03 +02:00
parent 25ecd599f3
commit e27916f85e
8 changed files with 25 additions and 35 deletions

View file

@ -100,10 +100,10 @@ internal class PrepareToEncryptUseCase @Inject constructor(
var sharedKey = false
val info = cryptoStore.getRoomCryptoInfo(roomId)
?: throw java.lang.IllegalArgumentException("Encryption not configured in this room")
?: throw java.lang.UnsupportedOperationException("Encryption not configured in this room")
// how to react if this is null??
if (info.algorithm != MXCRYPTO_ALGORITHM_MEGOLM) {
throw java.lang.IllegalArgumentException("Unsupported algorithm ${info.algorithm}")
throw java.lang.UnsupportedOperationException("Unsupported algorithm ${info.algorithm}")
}
val settings = EncryptionSettings(
algorithm = EventEncryptionAlgorithm.MEGOLM_V1_AES_SHA2,

View file

@ -225,7 +225,7 @@ internal class RustCryptoService @Inject constructor(
}
/**
* Tell if the MXCrypto is started
* Tell if the MXCrypto is started.
*
* @return true if the crypto is started
*/
@ -288,7 +288,7 @@ internal class RustCryptoService @Inject constructor(
}
/**
* Close the crypto
* Close the crypto.
*/
override fun close() {
cryptoCoroutineScope.coroutineContext.cancelChildren(CancellationException("Closing crypto module"))
@ -315,7 +315,7 @@ internal class RustCryptoService @Inject constructor(
override fun crossSigningService() = crossSigningService
/**
* A sync response has been received
* A sync response has been received.
*/
override suspend fun onSyncCompleted(syncResponse: SyncResponse, cryptoStoreAggregator: CryptoStoreAggregator) {
if (isStarted()) {
@ -335,7 +335,7 @@ internal class RustCryptoService @Inject constructor(
}
/**
* Provides the device information for a user id and a device Id
* Provides the device information for a user id and a device Id.
*
* @param userId the user id
* @param deviceId the device id
@ -387,7 +387,7 @@ internal class RustCryptoService @Inject constructor(
* Configure a room to use encryption.
*
* @param roomId the room id to enable encryption in.
* @param algorithm the encryption config for the room.
* @param info the encryption config for the room.
* @param membersId list of members to start tracking their devices
* @return true if the operation succeeds.
*/
@ -430,7 +430,7 @@ internal class RustCryptoService @Inject constructor(
}
/**
* Tells if a room is encrypted with MXCRYPTO_ALGORITHM_MEGOLM
* Tells if a room is encrypted with MXCRYPTO_ALGORITHM_MEGOLM.
*
* @param roomId the room id
* @return true if the room is encrypted with algorithm MXCRYPTO_ALGORITHM_MEGOLM
@ -486,7 +486,7 @@ internal class RustCryptoService @Inject constructor(
}
/**
* Decrypt an event
* Decrypt an event.
*
* @param event the raw event.
* @param timeline the id of the timeline where the event is decrypted. It is used to prevent replay attack.
@ -500,6 +500,7 @@ internal class RustCryptoService @Inject constructor(
/**
* Handle an m.room.encryption event.
*
* @param roomId the roomId.
* @param event the encryption event.
*/
private suspend fun onRoomEncryptionEvent(roomId: String, event: Event) {
@ -544,6 +545,7 @@ internal class RustCryptoService @Inject constructor(
/**
* Handle a change in the membership state of a member of a room.
*
* @param roomId the roomId
* @param event the membership event causing the change
*/
private suspend fun onRoomMembershipEvent(roomId: String, event: Event) {
@ -622,7 +624,8 @@ internal class RustCryptoService @Inject constructor(
// Notify the our listeners about room keys so decryption is retried.
toDeviceEvents.events.orEmpty().forEach { event ->
Timber.tag(loggerTag.value).d("[${myUserId.take(7)}|${deviceId}] Processed ToDevice event msgid:${event.toDeviceTracingId()} id:${event.eventId} type:${event.type}")
Timber.tag(loggerTag.value)
.d("[${myUserId.take(7)}|${deviceId}] Processed ToDevice event msgid:${event.toDeviceTracingId()} id:${event.eventId} type:${event.type}")
if (event.getClearType() == EventType.ENCRYPTED) {
// rust failed to decrypt it
@ -664,7 +667,7 @@ internal class RustCryptoService @Inject constructor(
}
/**
* Export the crypto keys
* Export the crypto keys.
*
* @param password the password
* @return the exported keys
@ -679,7 +682,7 @@ internal class RustCryptoService @Inject constructor(
}
/**
* Import the room keys
* Import the room keys.
*
* @param roomKeysAsArray the room keys as array.
* @param password the password

View file

@ -466,7 +466,7 @@ internal class RustKeyBackupService @Inject constructor(
/**
* Same method as [RoomKeysRestClient.getRoomKey] except that it accepts nullable
* parameters and always returns a KeysBackupData object through the Callback
* parameters and always returns a KeysBackupData object through the Callback.
*/
private suspend fun getKeys(sessionId: String?, roomId: String?, version: String): KeysBackupData {
return when {

View file

@ -23,7 +23,7 @@ import org.matrix.android.sdk.internal.util.database.RealmMigrator
import java.io.File
/**
* This migration creates the rust database and migrates from legacy crypto
* This migration creates the rust database and migrates from legacy crypto.
*/
internal class MigrateCryptoTo022(
realm: DynamicRealm,

View file

@ -134,7 +134,7 @@ internal class RustVerificationService @Inject constructor(
}
}
/** Dispatch updates after a verification event has been received */
/** Dispatch updates after a verification event has been received. */
private suspend fun onUpdate(event: Event) {
Timber.v("[${olmMachine.userId().take(6)}] Verification on event ${event.getClearType()}")
val sender = event.senderId ?: return
@ -320,7 +320,7 @@ internal class RustVerificationService @Inject constructor(
override suspend fun startKeyVerification(method: VerificationMethod, otherUserId: String, requestId: String): String? {
return if (method == VerificationMethod.SAS) {
val request = olmMachine.getVerificationRequest(otherUserId, requestId)
?: throw IllegalArgumentException("Unknown request with id: $requestId")
?: throw UnsupportedOperationException("Unknown request with id: $requestId")
val sas = request.startSasVerification()
@ -335,7 +335,7 @@ internal class RustVerificationService @Inject constructor(
null
}
} else {
throw IllegalArgumentException("Unknown verification method")
throw UnsupportedOperationException("Unknown verification method")
}
}

View file

@ -133,7 +133,7 @@ internal class SasVerification @AssistedInject constructor(
override val method: VerificationMethod
get() = VerificationMethod.QR_CODE_SCAN
/** Is this verification happening over to-device messages */
/** Is this verification happening over to-device messages. */
override fun isToDeviceTransport(): Boolean = inner.roomId() == null
// /** Does the verification flow support showing emojis as the short auth string */
@ -224,19 +224,6 @@ internal class SasVerification @AssistedInject constructor(
verificationListenersHolder.dispatchTxUpdated(this@SasVerification)
}
/** Fetch fresh data from the Rust side for our verification flow */
// private fun refreshData() {
// when (val verification = innerMachine.getVerification(inner.otherUserId, inner.flowId)) {
// is Verification.SasV1 -> {
// inner = verification.sas
// }
// else -> {
// }
// }
//
// return
// }
override fun onChange(state: SasState) {
innerState = state
verificationListenersHolder.dispatchTxUpdated(this)

View file

@ -103,7 +103,7 @@ internal class VerificationRequest @AssistedInject constructor(
fun innerState() = innerVerificationRequest.state()
/** The user ID of the other user that is participating in this verification flow */
/** The user ID of the other user that is participating in this verification flow. */
internal fun otherUser(): String {
return innerVerificationRequest.otherUserId()
}
@ -117,7 +117,7 @@ internal class VerificationRequest @AssistedInject constructor(
return innerVerificationRequest.otherDeviceId()
}
/** Did we initiate this verification flow */
/** Did we initiate this verification flow. */
internal fun weStarted(): Boolean {
return innerVerificationRequest.weStarted()
}
@ -140,7 +140,7 @@ internal class VerificationRequest @AssistedInject constructor(
// return innerVerificationRequest.isReady()
// }
/** Did we advertise that we're able to scan QR codes */
/** Did we advertise that we're able to scan QR codes. */
internal fun canScanQrCodes(): Boolean {
return innerVerificationRequest.ourSupportedMethods()?.contains(VERIFICATION_METHOD_QR_CODE_SCAN) ?: false
}

View file

@ -36,7 +36,7 @@ internal class VerificationsProvider @Inject constructor(
return innerMachine.getVerificationRequests(userId).map(verificationRequestFactory::create)
}
/** Get a verification request for the given user with the given flow ID */
/** Get a verification request for the given user with the given flow ID. */
fun getVerificationRequest(userId: String, flowId: String): VerificationRequest? {
return innerMachine.getVerificationRequest(userId, flowId)?.let { innerVerificationRequest ->
verificationRequestFactory.create(innerVerificationRequest)