Enable detekt rules UseLet and fix existing issues.

This commit is contained in:
Benoit Marty
2023-07-26 12:11:52 +02:00
committed by Benoit Marty
parent b8281052b9
commit 495d6020ad
3 changed files with 14 additions and 17 deletions
@@ -57,14 +57,9 @@ fun MatrixRoom.getDirectRoomMember(roomMembersState: MatrixRoomMembersState): St
val roomMembers = roomMembersState.roomMembers() val roomMembers = roomMembersState.roomMembers()
return remember(roomMembersState) { return remember(roomMembersState) {
derivedStateOf { derivedStateOf {
if (roomMembers == null) { roomMembers
null ?.takeIf { it.size == 2 && isDirect && isEncrypted }
} else if (roomMembers.size == 2 && isDirect && isEncrypted) { ?.find { it.userId != sessionId }
roomMembers.find { it.userId != this.sessionId }
} else {
null
} }
} }
} }
}
@@ -100,13 +100,13 @@ class DefaultPushHandler @Inject constructor(
} }
val clientSecret = pushData.clientSecret val clientSecret = pushData.clientSecret
val userId = if (clientSecret == null) { // clientSecret should not be null. If this happens, restore default session
// Should not happen. In this case, restore default session val userId = clientSecret
null ?.let {
} else {
// Get userId from client secret // Get userId from client secret
pushClientSecret.getUserIdFromSecret(clientSecret) pushClientSecret.getUserIdFromSecret(clientSecret)
} ?: run { }
?: run {
matrixAuthenticationService.getLatestSessionId() matrixAuthenticationService.getLatestSessionId()
} }
+2
View File
@@ -63,6 +63,8 @@ style:
UseDataClass: UseDataClass:
active: true active: true
allowVars: false allowVars: false
UseLet:
active: true
coroutines: coroutines:
GlobalCoroutineUsage: GlobalCoroutineUsage: