Enable detekt rules DataClassShouldBeImmutable and fix existing issues.

This commit is contained in:
Benoit Marty 2023-07-26 11:15:52 +02:00 committed by Benoit Marty
parent d433c3cbaa
commit 8458a9e937
6 changed files with 20 additions and 21 deletions

View file

@ -23,17 +23,15 @@ import io.element.android.libraries.matrix.api.core.SessionId
* Data class to hold information about a group of notifications for a room. * Data class to hold information about a group of notifications for a room.
*/ */
data class RoomEventGroupInfo( data class RoomEventGroupInfo(
val sessionId: SessionId, val sessionId: SessionId,
val roomId: RoomId, val roomId: RoomId,
val roomDisplayName: String, val roomDisplayName: String,
val isDirect: Boolean = false val isDirect: Boolean = false,
) {
// An event in the list has not yet been display // An event in the list has not yet been display
var hasNewEvent: Boolean = false val hasNewEvent: Boolean = false,
// true if at least one on the not yet displayed event is noisy // true if at least one on the not yet displayed event is noisy
var shouldBing: Boolean = false val shouldBing: Boolean = false,
var customSound: String? = null val customSound: String? = null,
var hasSmartReplyError: Boolean = false val hasSmartReplyError: Boolean = false,
var isUpdated: Boolean = false val isUpdated: Boolean = false,
} )

View file

@ -85,12 +85,11 @@ class RoomGroupMessageCreator @Inject constructor(
roomId = roomId, roomId = roomId,
roomDisplayName = roomName, roomDisplayName = roomName,
isDirect = !roomIsGroup, isDirect = !roomIsGroup,
).also { hasSmartReplyError = smartReplyErrors.isNotEmpty(),
it.hasSmartReplyError = smartReplyErrors.isNotEmpty() shouldBing = meta.shouldBing,
it.shouldBing = meta.shouldBing customSound = events.last().soundName,
it.customSound = events.last().soundName isUpdated = events.last().isUpdated,
it.isUpdated = events.last().isUpdated ),
},
threadId = lastKnownRoomEvent.threadId, threadId = lastKnownRoomEvent.threadId,
largeIcon = largeBitmap, largeIcon = largeBitmap,
lastMessageTimestamp, lastMessageTimestamp,

View file

@ -30,7 +30,7 @@ data class SimpleNotifiableEvent(
val type: String?, val type: String?,
val timestamp: Long, val timestamp: Long,
val soundName: String?, val soundName: String?,
override var canBeReplaced: Boolean, override val canBeReplaced: Boolean,
override val isRedacted: Boolean = false, override val isRedacted: Boolean = false,
override val isUpdated: Boolean = false override val isUpdated: Boolean = false
) : NotifiableEvent ) : NotifiableEvent

View file

@ -36,7 +36,7 @@ import io.element.android.libraries.pushproviders.api.PushData
data class PushDataFirebase( data class PushDataFirebase(
val eventId: String?, val eventId: String?,
val roomId: String?, val roomId: String?,
var unread: Int?, val unread: Int?,
val clientSecret: String? val clientSecret: String?
) )

View file

@ -47,7 +47,7 @@ data class PushDataUnifiedPush(
data class PushDataUnifiedPushNotification( data class PushDataUnifiedPushNotification(
@SerialName("event_id") val eventId: String? = null, @SerialName("event_id") val eventId: String? = null,
@SerialName("room_id") val roomId: String? = null, @SerialName("room_id") val roomId: String? = null,
@SerialName("counts") var counts: PushDataUnifiedPushCounts? = null, @SerialName("counts") val counts: PushDataUnifiedPushCounts? = null,
) )
@Serializable @Serializable

View file

@ -6,6 +6,8 @@ style:
CascadingCallWrapping: CascadingCallWrapping:
active: true active: true
includeElvis: true includeElvis: true
DataClassShouldBeImmutable:
active: true
MaxLineLength: MaxLineLength:
# Default is 120 # Default is 120
maxLineLength: 160 maxLineLength: 160