Fix moar ktlint issues

This commit is contained in:
Benoit Marty 2024-01-11 09:41:14 +01:00 committed by Benoit Marty
parent a831f05f6e
commit 5d086ad82d
528 changed files with 146 additions and 629 deletions

View file

@ -101,7 +101,6 @@ class RustMatrixClient(
baseCacheDirectory: File,
private val clock: SystemClock,
) : MatrixClient {
override val sessionId: UserId = UserId(client.userId())
private val innerRoomListService = syncService.roomListService()
private val sessionDispatcher = dispatchers.io.limitedParallelism(64)

View file

@ -39,7 +39,6 @@ class RustMatrixClientFactory @Inject constructor(
private val userAgentProvider: UserAgentProvider,
private val clock: SystemClock,
) {
suspend fun create(sessionData: SessionData): RustMatrixClient = withContext(coroutineDispatchers.io) {
val client = ClientBuilder()
.basePath(baseDirectory.absolutePath)

View file

@ -52,7 +52,6 @@ class RustMatrixAuthenticationService @Inject constructor(
userAgentProvider: UserAgentProvider,
private val rustMatrixClientFactory: RustMatrixClientFactory,
) : MatrixAuthenticationService {
private val authService: RustAuthenticationService = RustAuthenticationService(
basePath = baseDirectory.absolutePath,
passphrase = null,

View file

@ -52,7 +52,6 @@ internal class RustEncryptionService(
sessionCoroutineScope: CoroutineScope,
private val dispatchers: CoroutineDispatchers,
) : EncryptionService {
private val service: Encryption = client.encryption()
private val backupStateMapper = BackupStateMapper()

View file

@ -20,7 +20,6 @@ import io.element.android.libraries.matrix.api.media.MediaFile
import org.matrix.rustcomponents.sdk.MediaFileHandle
class RustMediaFile(private val inner: MediaFileHandle) : MediaFile {
override fun path(): String {
return inner.path()
}

View file

@ -34,7 +34,6 @@ class RustMediaLoader(
dispatchers: CoroutineDispatchers,
private val innerClient: Client,
) : MatrixMediaLoader {
@OptIn(ExperimentalCoroutinesApi::class)
private val mediaDispatcher = dispatchers.io.limitedParallelism(32)
private val cacheDirectory

View file

@ -28,7 +28,6 @@ import org.matrix.rustcomponents.sdk.use
import javax.inject.Inject
class TimelineEventToNotificationContentMapper @Inject constructor() {
fun map(timelineEvent: TimelineEvent): NotificationContent {
return timelineEvent.use {
timelineEvent.eventType().use { eventType ->

View file

@ -29,7 +29,6 @@ import org.matrix.rustcomponents.sdk.RoomNotificationMode as RustRoomNotificatio
class MatrixRoomInfoMapper(
private val timelineItemMapper: EventTimelineItemMapper = EventTimelineItemMapper(),
) {
fun map(rustRoomInfo: RustRoomInfo): MatrixRoomInfo = rustRoomInfo.use {
return MatrixRoomInfo(
id = it.id,

View file

@ -35,7 +35,6 @@ import kotlin.time.Duration.Companion.milliseconds
class RoomContentForwarder(
private val roomListService: RoomListService,
) {
/**
* Forwards the event with the given [eventId] from the [fromTimeline] to the given [toRoomIds].
* @param fromTimeline the room to forward the event from

View file

@ -23,7 +23,6 @@ import org.matrix.rustcomponents.sdk.MembershipState as RustMembershipState
import org.matrix.rustcomponents.sdk.RoomMember as RustRoomMember
object RoomMemberMapper {
fun map(roomMember: RustRoomMember): RoomMember = roomMember.use {
RoomMember(
UserId(it.userId()),

View file

@ -31,7 +31,6 @@ class RoomSyncSubscriber(
private val roomListService: RoomListService,
private val dispatchers: CoroutineDispatchers,
) {
private val subscriptionCounts = HashMap<RoomId, Int>()
private val mutex = Mutex()

View file

@ -104,7 +104,6 @@ class RustMatrixRoom(
private val roomSyncSubscriber: RoomSyncSubscriber,
private val matrixRoomInfoMapper: MatrixRoomInfoMapper,
) : MatrixRoom {
override val roomId = RoomId(innerRoom.id())
override val roomInfoFlow: Flow<MatrixRoomInfo> = mxCallbackFlow {

View file

@ -39,7 +39,6 @@ internal class RoomListFactory(
private val dispatcher: CoroutineDispatcher,
private val roomSummaryDetailsFactory: RoomSummaryDetailsFactory = RoomSummaryDetailsFactory(),
) {
/**
* Creates a room list that can be used to load more rooms and filter them dynamically.
*/
@ -98,7 +97,6 @@ private class RustDynamicRoomList(
private val processor: RoomSummaryListProcessor,
override val pageSize: Int,
) : DynamicRoomList {
override suspend fun rebuildSummaries() {
processor.rebuildRoomSummaries()
}

View file

@ -25,7 +25,6 @@ import org.matrix.rustcomponents.sdk.RoomInfo
import org.matrix.rustcomponents.sdk.use
class RoomSummaryDetailsFactory(private val roomMessageFactory: RoomMessageFactory = RoomMessageFactory()) {
fun create(roomInfo: RoomInfo): RoomSummaryDetails {
val latestRoomMessage = roomInfo.latestEvent?.use {
roomMessageFactory.create(it)

View file

@ -35,7 +35,6 @@ class RoomSummaryListProcessor(
private val dispatcher: CoroutineDispatcher,
private val roomSummaryDetailsFactory: RoomSummaryDetailsFactory = RoomSummaryDetailsFactory(),
) {
private val roomSummariesByIdentifier = HashMap<String, RoomSummary>()
private val mutex = Mutex()

View file

@ -43,7 +43,6 @@ internal class RustRoomListService(
private val sessionCoroutineScope: CoroutineScope,
roomListFactory: RoomListFactory,
) : RoomListService {
override val allRooms: DynamicRoomList = roomListFactory.createRoomList(
pageSize = DEFAULT_PAGE_SIZE,
initialFilter = DynamicRoomList.Filter.AllNonLeft,

View file

@ -33,7 +33,6 @@ class RustSyncService(
private val innerSyncService: SyncServiceInterface,
sessionCoroutineScope: CoroutineScope
) : SyncService {
override suspend fun startSync() = runCatching {
Timber.i("Start sync")
innerSyncService.start()

View file

@ -43,7 +43,6 @@ class AsyncMatrixTimeline(
dispatcher: CoroutineDispatcher,
private val timelineProvider: suspend () -> MatrixTimeline
) : MatrixTimeline {
private val _timelineItems: MutableStateFlow<List<MatrixTimelineItem>> =
MutableStateFlow(emptyList())

View file

@ -29,7 +29,6 @@ internal class MatrixTimelineDiffProcessor(
private val timelineItems: MutableStateFlow<List<MatrixTimelineItem>>,
private val timelineItemFactory: MatrixTimelineItemMapper,
) {
private val mutex = Mutex()
suspend fun postItems(items: List<TimelineItem>) {

View file

@ -30,7 +30,6 @@ class MatrixTimelineItemMapper(
private val virtualTimelineItemMapper: VirtualTimelineItemMapper = VirtualTimelineItemMapper(),
private val eventTimelineItemMapper: EventTimelineItemMapper = EventTimelineItemMapper(),
) {
fun map(timelineItem: TimelineItem): MatrixTimelineItem = timelineItem.use {
val uniqueId = timelineItem.uniqueId().toString()
val asEvent = it.asEvent()

View file

@ -65,7 +65,6 @@ class RustMatrixTimeline(
lastLoginTimestamp: Date?,
private val onNewSyncedEvent: () -> Unit,
) : MatrixTimeline {
private val initLatch = CompletableDeferred<Unit>()
private val isInit = AtomicBoolean(false)

View file

@ -43,7 +43,6 @@ import org.matrix.rustcomponents.sdk.MessageFormat as RustMessageFormat
import org.matrix.rustcomponents.sdk.MessageType as RustMessageType
class EventMessageMapper {
private val timelineEventContentMapper by lazy { TimelineEventContentMapper() }
fun map(message: Message): MessageContent = message.use {

View file

@ -39,7 +39,6 @@ import org.matrix.rustcomponents.sdk.ProfileDetails as RustProfileDetails
import org.matrix.rustcomponents.sdk.Receipt as RustReceipt
class EventTimelineItemMapper(private val contentMapper: TimelineEventContentMapper = TimelineEventContentMapper()) {
fun map(eventTimelineItem: RustEventTimelineItem): EventTimelineItem = eventTimelineItem.use {
EventTimelineItem(
eventId = it.eventId()?.let(::EventId),

View file

@ -42,7 +42,6 @@ import org.matrix.rustcomponents.sdk.MembershipChange as RustMembershipChange
import org.matrix.rustcomponents.sdk.OtherState as RustOtherState
class TimelineEventContentMapper(private val eventMessageMapper: EventMessageMapper = EventMessageMapper()) {
fun map(content: TimelineItemContent): EventContent {
return content.use {
content.kind().use { kind ->

View file

@ -20,7 +20,6 @@ import io.element.android.libraries.matrix.api.timeline.item.virtual.VirtualTime
import org.matrix.rustcomponents.sdk.VirtualTimelineItem as RustVirtualTimelineItem
class VirtualTimelineItemMapper {
fun map(virtualTimelineItem: RustVirtualTimelineItem): VirtualTimelineItem {
return when (virtualTimelineItem) {
is RustVirtualTimelineItem.DayDivider -> VirtualTimelineItem.DayDivider(virtualTimelineItem.ts.toLong())

View file

@ -29,7 +29,6 @@ class TimelineEncryptedHistoryPostProcessor(
private val isRoomEncrypted: Boolean,
private val isKeyBackupEnabled: Boolean,
) {
suspend fun process(items: List<MatrixTimelineItem>): List<MatrixTimelineItem> = withContext(dispatcher) {
Timber.d("Process on Thread=${Thread.currentThread()}")
if (!isRoomEncrypted || isKeyBackupEnabled || lastLoginTimestamp == null) return@withContext items

View file

@ -24,7 +24,6 @@ data class LogEventLocation(
val file: String,
val line: UInt?,
) {
companion object {
/**
* Create a [LogEventLocation] from a [StackTraceElement].

View file

@ -28,7 +28,6 @@ import javax.inject.Inject
@ContributesBinding(AppScope::class)
class RustTracingService @Inject constructor(private val buildMeta: BuildMeta) : TracingService {
override fun setupTracing(tracingConfiguration: TracingConfiguration) {
val filter = tracingConfiguration.filterConfiguration
val rustTracingConfiguration = org.matrix.rustcomponents.sdk.TracingConfiguration(

View file

@ -36,7 +36,6 @@ private val fqcnIgnore = listOf(
* A Timber tree that passes logs to the Rust SDK.
*/
internal class RustTracingTree(private val retrieveFromStackTrace: Boolean) : Timber.Tree() {
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
val location = if (retrieveFromStackTrace) {
getLogEventLocationFromStackTrace()

View file

@ -21,7 +21,6 @@ import kotlinx.collections.immutable.toImmutableList
import org.matrix.rustcomponents.sdk.SearchUsersResults
object UserSearchResultMapper {
fun map(result: SearchUsersResults): MatrixSearchUserResults {
return MatrixSearchUserResults(
results = result.results.map(UserProfileMapper::map).toImmutableList(),

View file

@ -25,7 +25,6 @@ fun TaskHandle.cancelAndDestroy() {
}
class TaskHandleBag(private val taskHandles: MutableSet<TaskHandle> = CopyOnWriteArraySet()) : Set<TaskHandle> by taskHandles {
operator fun plusAssign(taskHandle: TaskHandle?) {
if (taskHandle == null) return
taskHandles += taskHandle

View file

@ -40,7 +40,6 @@ class RustSessionVerificationService(
private val syncService: RustSyncService,
private val sessionCoroutineScope: CoroutineScope,
) : SessionVerificationService, SessionVerificationControllerDelegate {
var verificationController: SessionVerificationControllerInterface? = null
set(value) {
field = value

View file

@ -35,7 +35,6 @@ class RustWidgetDriver(
private val room: Room,
private val widgetCapabilitiesProvider: WidgetCapabilitiesProvider,
) : 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

@ -23,7 +23,6 @@ import org.junit.Test
import org.matrix.rustcomponents.sdk.AuthenticationException as RustAuthenticationException
class AuthenticationExceptionMappingTest {
@Test
fun `mapping an exception with no message returns 'Unknown error' message`() {
val exception = Exception()

View file

@ -40,7 +40,6 @@ import org.matrix.rustcomponents.sdk.TaskHandle
// NOTE: this class is using a fake implementation of a Rust SDK interface which returns actual Rust objects with pointers.
// Since we don't access the data in those objects, this is fine for our tests, but that's as far as we can test this class.
class RoomSummaryListProcessorTests {
private val summaries = MutableStateFlow<List<RoomSummary>>(emptyList())
@Test

View file

@ -29,7 +29,6 @@ import java.util.Date
private const val FAKE_UNIQUE_ID = "FAKE_UNIQUE_ID"
class TimelineEncryptedHistoryPostProcessorTest {
private val defaultLastLoginTimestamp = Date(1_689_061_264L)
@Test