Update plugin ktlint to v12.1.0 (#2200)

* Update plugin ktlint to v12.1.0

* Run `./gradlew ktlintFormat` and fix some issues manually.

* Fix other issues reproted by Ktlint

* Limit false positives, KtLint removes unnecessary curly brace in String templates.

* Remove useless Unit

* Minor improvements over ktlint changes

* Restore `AlertDialogContent` behaviour

* Update screenshots

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benoit Marty <benoit@matrix.org>
Co-authored-by: Jorge Martín <jorgem@element.io>
Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
renovate[bot] 2024-01-10 16:22:24 +01:00 committed by GitHub
parent 675cc525cf
commit 7e9cda3aa9
442 changed files with 1091 additions and 1081 deletions

View file

@ -24,4 +24,4 @@ data class MatrixHomeServerDetails(
val url: String,
val supportsPasswordLogin: Boolean,
val supportsOidcLogin: Boolean,
): Parcelable
) : Parcelable

View file

@ -25,8 +25,8 @@ value class SpaceId(val value: String) : Serializable {
if (BuildConfig.DEBUG && !MatrixPatterns.isSpaceId(value)) {
error(
"`$value` is not a valid space id.\n" +
"Space ids are the same as room ids.\n" +
"Example space id: `!space_id:domain`."
"Space ids are the same as room ids.\n" +
"Example space id: `!space_id:domain`."
)
}
}

View file

@ -25,8 +25,8 @@ value class ThreadId(val value: String) : Serializable {
if (BuildConfig.DEBUG && !MatrixPatterns.isThreadId(value)) {
error(
"`$value` is not a valid thread id.\n" +
"Thread ids are the same as event ids.\n" +
"Example thread id: `\$Rqnc-F-dvnEYJTyHq_iKxU2bZ1CI92-kuZq3a5lr5Zg`."
"Thread ids are the same as event ids.\n" +
"Example thread id: `\$Rqnc-F-dvnEYJTyHq_iKxU2bZ1CI92-kuZq3a5lr5Zg`."
)
}
}

View file

@ -31,5 +31,5 @@ enum class BackupState {
RESUMING,
ENABLED,
DOWNLOADING,
DISABLING;
DISABLING
}

View file

@ -26,7 +26,7 @@ interface NotificationSettingsService {
/**
* State of the current room notification settings flow ([MatrixRoomNotificationSettingsState.Unknown] if not started).
*/
val notificationSettingsChangeFlow : SharedFlow<Unit>
val notificationSettingsChangeFlow: SharedFlow<Unit>
suspend fun getRoomNotificationSettings(roomId: RoomId, isEncrypted: Boolean, isOneToOne: Boolean): Result<RoomNotificationSettings>
suspend fun getDefaultRoomNotificationMode(isEncrypted: Boolean, isOneToOne: Boolean): Result<RoomNotificationMode>
suspend fun setDefaultRoomNotificationMode(isEncrypted: Boolean, mode: RoomNotificationMode, isOneToOne: Boolean): Result<Unit>

View file

@ -130,7 +130,9 @@ object PermalinkParser {
val splitNameValue = it.split("=")
if (splitNameValue.size == 2) {
Pair(splitNameValue[0], URLDecoder.decode(splitNameValue[1], "UTF-8"))
} else null
} else {
null
}
}
private fun String.getViaParameters(): List<String> {

View file

@ -35,5 +35,3 @@ fun MatrixRoomMembersState.roomMembers(): List<RoomMember>? {
else -> null
}
}

View file

@ -20,7 +20,7 @@ import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.core.UserId
sealed interface Mention {
data class User(val userId: UserId): Mention
data object AtRoom: Mention
data class Room(val roomId: RoomId?, val roomAlias: String?): Mention
data class User(val userId: UserId) : Mention
data object AtRoom : Mention
data class Room(val roomId: RoomId?, val roomAlias: String?) : Mention
}

View file

@ -38,5 +38,5 @@ enum class StateEventType {
ROOM_TOMBSTONE,
ROOM_TOPIC,
SPACE_CHILD,
SPACE_PARENT;
SPACE_PARENT
}

View file

@ -39,4 +39,3 @@ suspend fun MatrixRoom.canSendMessage(type: MessageEventType): Result<Boolean> =
* Shortcut for calling [MatrixRoom.canUserRedact] with our own user.
*/
suspend fun MatrixRoom.canRedact(): Result<Boolean> = canUserRedact(sessionId)

View file

@ -30,4 +30,3 @@ sealed interface MatrixTimelineItem {
data class Virtual(val uniqueId: String, val virtual: VirtualTimelineItem) : MatrixTimelineItem
data object Other : MatrixTimelineItem
}

View file

@ -19,5 +19,5 @@ package io.element.android.libraries.matrix.api.timeline
enum class ReceiptType {
READ,
READ_PRIVATE,
FULLY_READ;
FULLY_READ
}

View file

@ -88,12 +88,12 @@ object EventType {
fun isCallEvent(type: String): Boolean {
return type == CALL_INVITE ||
type == CALL_CANDIDATES ||
type == CALL_ANSWER ||
type == CALL_HANGUP ||
type == CALL_SELECT_ANSWER ||
type == CALL_NEGOTIATE ||
type == CALL_REJECT ||
type == CALL_REPLACES
type == CALL_CANDIDATES ||
type == CALL_ANSWER ||
type == CALL_HANGUP ||
type == CALL_SELECT_ANSWER ||
type == CALL_NEGOTIATE ||
type == CALL_REJECT ||
type == CALL_REPLACES
}
}

View file

@ -33,5 +33,5 @@ enum class MembershipChange {
KNOCK_ACCEPTED,
KNOCK_RETRACTED,
KNOCK_DENIED,
NOT_IMPLEMENTED;
NOT_IMPLEMENTED
}

View file

@ -28,4 +28,3 @@ data class ReactionSender(
val senderId: UserId,
val timestamp: Long
)

View file

@ -17,5 +17,5 @@
package io.element.android.libraries.matrix.api.timeline.item.event
enum class TimelineItemEventOrigin {
LOCAL, SYNC, PAGINATION;
LOCAL, SYNC, PAGINATION
}

View file

@ -44,5 +44,4 @@ class AuthErrorCodeTest {
val error = AuthenticationException.Generic("Some other error")
assertThat(error.errorCode).isEqualTo(AuthErrorCode.UNKNOWN)
}
}

View file

@ -54,5 +54,4 @@ class MatrixToConverterTest {
val url = Uri.parse("https://element.io/")
assertThat(MatrixToConverter.convert(url)).isNull()
}
}

View file

@ -25,10 +25,10 @@ class PermalinkDataTest {
@Test
fun `getRoomId() returns value when isRoomAlias is false`() {
val permalinkData = PermalinkData.RoomLink(
roomIdOrAlias = "!abcdef123456:matrix.org",
isRoomAlias = false,
eventId = null,
viaParameters = persistentListOf(),
roomIdOrAlias = "!abcdef123456:matrix.org",
isRoomAlias = false,
eventId = null,
viaParameters = persistentListOf(),
)
assertThat(permalinkData.getRoomId()).isNotNull()
assertThat(permalinkData.getRoomAlias()).isNull()
@ -45,5 +45,4 @@ class PermalinkDataTest {
assertThat(permalinkData.getRoomId()).isNull()
assertThat(permalinkData.getRoomAlias()).isNotNull()
}
}

View file

@ -53,9 +53,9 @@ class PermalinkParserTest {
fun `parsing a valid user url returns a user link`() {
val url = "https://app.element.io/#/user/@test:matrix.org"
assertThat(PermalinkParser.parse(url)).isEqualTo(
PermalinkData.UserLink(
userId = "@test:matrix.org"
)
PermalinkData.UserLink(
userId = "@test:matrix.org"
)
)
}
@ -115,12 +115,12 @@ class PermalinkParserTest {
fun `parsing a valid room alias url returns a room link`() {
val url = "https://app.element.io/#/room/#element-android:matrix.org"
assertThat(PermalinkParser.parse(url)).isEqualTo(
PermalinkData.RoomLink(
roomIdOrAlias = "#element-android:matrix.org",
isRoomAlias = true,
eventId = null,
viaParameters = persistentListOf(),
)
PermalinkData.RoomLink(
roomIdOrAlias = "#element-android:matrix.org",
isRoomAlias = true,
eventId = null,
viaParameters = persistentListOf(),
)
)
}

View file

@ -105,7 +105,7 @@ class RustMatrixClient(
override val sessionId: UserId = UserId(client.userId())
private val innerRoomListService = syncService.roomListService()
private val sessionDispatcher = dispatchers.io.limitedParallelism(64)
private val sessionCoroutineScope = appCoroutineScope.childScope(dispatchers.main, "Session-${sessionId}")
private val sessionCoroutineScope = appCoroutineScope.childScope(dispatchers.main, "Session-$sessionId")
private val rustSyncService = RustSyncService(syncService, sessionCoroutineScope)
private val verificationService = RustSessionVerificationService(rustSyncService, sessionCoroutineScope)
private val pushersService = RustPushersService(
@ -137,7 +137,7 @@ class RustMatrixClient(
Timber.w("didReceiveAuthError(isSoftLogout=$isSoftLogout)")
if (isLoggingOut.getAndSet(true).not()) {
Timber.v("didReceiveAuthError -> do the cleanup")
//TODO handle isSoftLogout parameter.
// TODO handle isSoftLogout parameter.
appCoroutineScope.launch {
val existingData = sessionStore.getSession(client.userId())
if (existingData != null) {
@ -204,7 +204,7 @@ class RustMatrixClient(
// Check if already in memory...
var cachedPairOfRoom = pairOfRoom(roomId)
if (cachedPairOfRoom == null) {
//... otherwise, lets wait for the SS to load all rooms and check again.
// ... otherwise, lets wait for the SS to load all rooms and check again.
roomListService.allRooms.awaitLoaded()
cachedPairOfRoom = pairOfRoom(roomId)
}

View file

@ -29,7 +29,7 @@ class MediaUploadHandlerImpl(
runCatching {
sendAttachmentJoinHandle.join()
}
.also { cleanUpFiles() }
.also { cleanUpFiles() }
override fun cancel() {
sendAttachmentJoinHandle.cancel()

View file

@ -43,7 +43,7 @@ class MatrixRoomInfoMapper(
canonicalAlias = it.canonicalAlias,
alternativeAliases = it.alternativeAliases.toImmutableList(),
currentUserMembership = it.membership.map(),
latestEvent = it.latestEvent?.use (timelineItemMapper::map),
latestEvent = it.latestEvent?.use(timelineItemMapper::map),
inviter = it.inviter?.use(RoomMemberMapper::map),
activeMembersCount = it.activeMembersCount.toLong(),
invitedMembersCount = it.invitedMembersCount.toLong(),
@ -57,13 +57,13 @@ class MatrixRoomInfoMapper(
}
}
fun RustMembership.map(): CurrentUserMembership = when(this) {
fun RustMembership.map(): CurrentUserMembership = when (this) {
RustMembership.INVITED -> CurrentUserMembership.INVITED
RustMembership.JOINED -> CurrentUserMembership.JOINED
RustMembership.LEFT -> CurrentUserMembership.LEFT
}
fun RustRoomNotificationMode.map(): RoomNotificationMode = when(this) {
fun RustRoomNotificationMode.map(): RoomNotificationMode = when (this) {
RustRoomNotificationMode.ALL_MESSAGES -> RoomNotificationMode.ALL_MESSAGES
RustRoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY -> RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY
RustRoomNotificationMode.MUTE -> RoomNotificationMode.MUTE

View file

@ -122,7 +122,7 @@ class RustMatrixRoom(
// Create a dispatcher for all room methods...
private val roomDispatcher = coroutineDispatchers.io.limitedParallelism(32)
//...except getMember methods as it could quickly fill the roomDispatcher...
// ...except getMember methods as it could quickly fill the roomDispatcher...
private val roomMembersDispatcher = coroutineDispatchers.io.limitedParallelism(8)
private val roomCoroutineScope = sessionCoroutineScope.childScope(coroutineDispatchers.main, "RoomScope-$roomId")

View file

@ -135,4 +135,3 @@ private fun DynamicRoomList.Filter.toRustFilter(): RoomListEntriesDynamicFilterK
DynamicRoomList.Filter.AllNonLeft -> RoomListEntriesDynamicFilterKind.AllNonLeft
}
}

View file

@ -45,4 +45,3 @@ class RoomSummaryDetailsFactory(private val roomMessageFactory: RoomMessageFacto
)
}
}

View file

@ -257,7 +257,7 @@ class RustMatrixTimeline(
private fun List<MatrixTimelineItem>.hasEncryptionHistoryBanner(): Boolean {
val firstItem = firstOrNull()
return firstItem is MatrixTimelineItem.Virtual
&& firstItem.virtual is VirtualTimelineItem.EncryptedHistoryBanner
return firstItem is MatrixTimelineItem.Virtual &&
firstItem.virtual is VirtualTimelineItem.EncryptedHistoryBanner
}
}

View file

@ -100,11 +100,11 @@ private fun List<Reaction>?.map(): ImmutableList<EventReaction> {
private fun Map<String, RustReceipt>.map(): ImmutableList<Receipt> {
return map {
Receipt(
userId = UserId(it.key),
timestamp = it.value.timestamp?.toLong() ?: 0
)
}
Receipt(
userId = UserId(it.key),
timestamp = it.value.timestamp?.toLong() ?: 0
)
}
.sortedByDescending { it.timestamp }
.toImmutableList()
}

View file

@ -147,7 +147,7 @@ private fun RustMembershipChange.map(): MembershipChange {
}
}
//TODO extract state events?
// TODO extract state events?
private fun RustOtherState.map(): OtherState {
return when (this) {
is RustOtherState.Custom -> OtherState.Custom(eventType)

View file

@ -34,7 +34,7 @@ class RustWidgetDriver(
widgetSettings: MatrixWidgetSettings,
private val room: Room,
private val widgetCapabilitiesProvider: WidgetCapabilitiesProvider,
): MatrixWidgetDriver {
) : MatrixWidgetDriver {
// It's important to have extra capacity here to make sure we don't drop any messages
override val incomingMessages = MutableSharedFlow<String>(extraBufferCapacity = 10)

View file

@ -41,12 +41,12 @@ class AuthenticationExceptionMappingTest {
@Test
fun `mapping specific exceptions map to their kotlin counterparts`() {
assertThat(RustAuthenticationException.ClientMissing("Client missing").mapAuthenticationException())
.isException<AuthenticationException.ClientMissing>("Client missing")
.isException<AuthenticationException.ClientMissing>("Client missing")
assertThat(RustAuthenticationException.Generic("Generic").mapAuthenticationException()).isException<AuthenticationException.Generic>("Generic")
assertThat(RustAuthenticationException.InvalidServerName("Invalid server name").mapAuthenticationException())
.isException<AuthenticationException.InvalidServerName>("Invalid server name")
.isException<AuthenticationException.InvalidServerName>("Invalid server name")
assertThat(RustAuthenticationException.SessionMissing("Session missing").mapAuthenticationException())
.isException<AuthenticationException.SessionMissing>("Session missing")

View file

@ -33,7 +33,7 @@ data class SimplePagedRoomList(
override val loadedPages = MutableStateFlow(1)
override suspend fun loadMore() {
//No-op
// No-op
loadedPages.getAndUpdate { it + 1 }
}
@ -46,6 +46,6 @@ data class SimplePagedRoomList(
}
override suspend fun rebuildSummaries() {
//No-op
// No-op
}
}

View file

@ -119,7 +119,9 @@ fun aTimelineItemDebugInfo(
originalJson: String? = null,
latestEditedJson: String? = null,
) = TimelineItemDebugInfo(
model, originalJson, latestEditedJson
model,
originalJson,
latestEditedJson
)
fun aPollContent(