Ktlint for all modules + run it
This commit is contained in:
parent
d00d934aa0
commit
c8b344644b
29 changed files with 80 additions and 95 deletions
|
|
@ -3,7 +3,6 @@ plugins {
|
|||
id("org.jetbrains.kotlin.android")
|
||||
alias(libs.plugins.ksp)
|
||||
id("com.google.firebase.appdistribution") version "3.0.2"
|
||||
id("org.jlleitschuh.gradle.ktlint") version "11.0.0"
|
||||
id("org.jetbrains.kotlinx.knit") version "0.4.0"
|
||||
}
|
||||
|
||||
|
|
@ -109,51 +108,6 @@ android {
|
|||
kotlin.srcDir("build/generated/ksp/test/kotlin")
|
||||
}
|
||||
}
|
||||
|
||||
// See https://github.com/JLLeitschuh/ktlint-gradle#configuration
|
||||
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
|
||||
// See https://github.com/pinterest/ktlint/releases/
|
||||
// TODO 0.47.1 is available
|
||||
version.set("0.45.1")
|
||||
android.set(true)
|
||||
ignoreFailures.set(false)
|
||||
enableExperimentalRules.set(true)
|
||||
// display the corresponding rule
|
||||
verbose.set(true)
|
||||
reporters {
|
||||
reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.PLAIN)
|
||||
// To have XML report for Danger
|
||||
reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.CHECKSTYLE)
|
||||
}
|
||||
filter {
|
||||
exclude { element -> element.file.path.contains("$buildDir/generated/") }
|
||||
}
|
||||
disabledRules.set(
|
||||
setOf(
|
||||
// TODO Re-enable these 4 rules after reformatting project
|
||||
"indent",
|
||||
"experimental:argument-list-wrapping",
|
||||
"max-line-length",
|
||||
"parameter-list-wrapping",
|
||||
|
||||
"spacing-between-declarations-with-comments",
|
||||
"no-multi-spaces",
|
||||
"experimental:spacing-between-declarations-with-annotations",
|
||||
"experimental:annotation",
|
||||
// - Missing newline after "("
|
||||
// - Missing newline before ")"
|
||||
"wrapping",
|
||||
// - Unnecessary trailing comma before ")"
|
||||
"experimental:trailing-comma",
|
||||
// - A block comment in between other elements on the same line is disallowed
|
||||
"experimental:comment-wrapping",
|
||||
// - A KDoc comment after any other element on the same line must be separated by a new line
|
||||
"experimental:kdoc-wrapping",
|
||||
// Ignore error "Redundant curly braces", since we use it to fix false positives, for instance in "elementLogs.${i}.txt"
|
||||
"string-template",
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ plugins {
|
|||
alias(libs.plugins.kotlin.android) apply false
|
||||
alias(libs.plugins.ksp) apply false
|
||||
id("io.gitlab.arturbosch.detekt") version "1.22.0"
|
||||
id("org.jlleitschuh.gradle.ktlint") version "11.0.0"
|
||||
}
|
||||
|
||||
tasks.register<Delete>("clean").configure {
|
||||
|
|
@ -12,6 +13,7 @@ tasks.register<Delete>("clean").configure {
|
|||
}
|
||||
|
||||
allprojects {
|
||||
// Detekt
|
||||
apply {
|
||||
plugin("io.gitlab.arturbosch.detekt")
|
||||
}
|
||||
|
|
@ -26,4 +28,54 @@ allprojects {
|
|||
dependencies {
|
||||
detektPlugins("com.twitter.compose.rules:detekt:0.0.26")
|
||||
}
|
||||
|
||||
// KtLint
|
||||
apply {
|
||||
plugin("org.jlleitschuh.gradle.ktlint")
|
||||
}
|
||||
|
||||
// See https://github.com/JLLeitschuh/ktlint-gradle#configuration
|
||||
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
|
||||
// See https://github.com/pinterest/ktlint/releases/
|
||||
// TODO 0.47.1 is available
|
||||
version.set("0.45.1")
|
||||
android.set(true)
|
||||
ignoreFailures.set(false)
|
||||
enableExperimentalRules.set(true)
|
||||
// display the corresponding rule
|
||||
verbose.set(true)
|
||||
reporters {
|
||||
reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.PLAIN)
|
||||
// To have XML report for Danger
|
||||
reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.CHECKSTYLE)
|
||||
}
|
||||
filter {
|
||||
exclude { element -> element.file.path.contains("$buildDir/generated/") }
|
||||
}
|
||||
disabledRules.set(
|
||||
setOf(
|
||||
// TODO Re-enable these 4 rules after reformatting project
|
||||
"indent",
|
||||
"experimental:argument-list-wrapping",
|
||||
"max-line-length",
|
||||
"parameter-list-wrapping",
|
||||
|
||||
"spacing-between-declarations-with-comments",
|
||||
"no-multi-spaces",
|
||||
"experimental:spacing-between-declarations-with-annotations",
|
||||
"experimental:annotation",
|
||||
// - Missing newline after "("
|
||||
// - Missing newline before ")"
|
||||
"wrapping",
|
||||
// - Unnecessary trailing comma before ")"
|
||||
"experimental:trailing-comma",
|
||||
// - A block comment in between other elements on the same line is disallowed
|
||||
"experimental:comment-wrapping",
|
||||
// - A KDoc comment after any other element on the same line must be separated by a new line
|
||||
"experimental:kdoc-wrapping",
|
||||
// Ignore error "Redundant curly braces", since we use it to fix false positives, for instance in "elementLogs.${i}.txt"
|
||||
"string-template",
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ fun LoginContent(
|
|||
)
|
||||
// Form
|
||||
Column(
|
||||
//modifier = Modifier.weight(1f),
|
||||
// modifier = Modifier.weight(1f),
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ fun ChangeServerContent(
|
|||
state = scrollState,
|
||||
)
|
||||
.padding(horizontal = 16.dp)
|
||||
)
|
||||
{
|
||||
) {
|
||||
val isError = state.changeServerAction is Fail
|
||||
Box(
|
||||
modifier = Modifier
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package io.element.android.x.features.login.error
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import io.element.android.x.core.uri.isValidUrl
|
||||
import io.element.android.x.features.login.LoginFormState
|
||||
import io.element.android.x.element.resources.R as ElementR
|
||||
import io.element.android.x.features.login.LoginFormState
|
||||
|
||||
@Composable
|
||||
fun loginError(
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import io.element.android.x.matrix.MatrixClient
|
|||
import io.element.android.x.matrix.media.MediaResolver
|
||||
import io.element.android.x.matrix.room.MatrixRoom
|
||||
import io.element.android.x.matrix.timeline.MatrixTimelineItem
|
||||
import kotlin.system.measureTimeMillis
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
|
@ -35,7 +36,6 @@ import org.matrix.rustcomponents.sdk.FormattedBody
|
|||
import org.matrix.rustcomponents.sdk.MessageFormat
|
||||
import org.matrix.rustcomponents.sdk.MessageType
|
||||
import timber.log.Timber
|
||||
import kotlin.system.measureTimeMillis
|
||||
|
||||
class MessageTimelineItemStateFactory(
|
||||
private val client: MatrixClient,
|
||||
|
|
@ -198,7 +198,6 @@ class MessageTimelineItemStateFactory(
|
|||
htmlDocument = messageType.content.formatted?.toHtmlDocument()
|
||||
)
|
||||
else -> MessagesTimelineItemUnknownContent
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,13 +101,13 @@ import io.element.android.x.features.messages.textcomposer.MessageComposerViewMo
|
|||
import io.element.android.x.features.messages.textcomposer.MessageComposerViewState
|
||||
import io.element.android.x.textcomposer.MessageComposerMode
|
||||
import io.element.android.x.textcomposer.TextComposer
|
||||
import java.lang.Math.random
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import java.lang.Math.random
|
||||
|
||||
@Composable
|
||||
fun MessagesScreen(
|
||||
|
|
@ -116,7 +116,6 @@ fun MessagesScreen(
|
|||
viewModel: MessagesViewModel = mavericksViewModel(argsFactory = { roomId }),
|
||||
composerViewModel: MessageComposerViewModel = mavericksViewModel(argsFactory = { roomId })
|
||||
) {
|
||||
|
||||
fun onSendMessage(textMessage: String) {
|
||||
viewModel.sendMessage(textMessage)
|
||||
composerViewModel.updateText("")
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ fun TimelineItemActionsScreen(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
ModalBottomSheetLayout(
|
||||
modifier = modifier,
|
||||
sheetState = modalBottomSheetState,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ fun MessagesTimelineItemImageView(
|
|||
.aspectRatio(content.aspectRatio),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
|
||||
var isLoading = rememberSaveable(content.imageMeta) { mutableStateOf(true) }
|
||||
val context = LocalContext.current
|
||||
val model = ImageRequest.Builder(context)
|
||||
|
|
|
|||
|
|
@ -454,7 +454,6 @@ private fun AnnotatedString.Builder.appendInlineChildrenElements(
|
|||
childNodes: List<Node>,
|
||||
colors: ColorScheme
|
||||
) {
|
||||
|
||||
for (node in childNodes) {
|
||||
when (node) {
|
||||
is TextNode -> {
|
||||
|
|
@ -552,4 +551,3 @@ private fun HtmlText(
|
|||
onLongClick = onLongClick
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,3 @@ sealed interface MessagesTimelineItemState {
|
|||
val safeSenderName: String = senderDisplayName ?: senderId
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ package io.element.android.x.features.roomlist
|
|||
|
||||
import android.text.format.DateFormat
|
||||
import android.text.format.DateUtils
|
||||
import java.time.Period
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Locale
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlinx.datetime.Clock
|
||||
import kotlinx.datetime.Instant
|
||||
import kotlinx.datetime.LocalDateTime
|
||||
|
|
@ -10,10 +14,6 @@ import kotlinx.datetime.toInstant
|
|||
import kotlinx.datetime.toJavaLocalDate
|
||||
import kotlinx.datetime.toJavaLocalDateTime
|
||||
import kotlinx.datetime.toLocalDateTime
|
||||
import java.time.Period
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Locale
|
||||
import kotlin.math.absoluteValue
|
||||
|
||||
class LastMessageFormatter(
|
||||
private val clock: Clock = Clock.System,
|
||||
|
|
|
|||
|
|
@ -178,4 +178,3 @@ fun PreviewableDarkRoomListContent() {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ fun RoomListTopBar(
|
|||
onLogoutClicked: () -> Unit,
|
||||
scrollBehavior: TopAppBarScrollBehavior
|
||||
) {
|
||||
|
||||
LogCompositions(tag = "RoomListScreen", msg = "TopBar")
|
||||
var searchWidgetStateIsOpened by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
|
|
|
|||
|
|
@ -23,4 +23,3 @@ object RoomListRoomSummaryPlaceholders {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ android {
|
|||
implementation(libs.accompanist.systemui)
|
||||
ksp(libs.showkase.processor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ private val LightColorScheme = lightColorScheme(
|
|||
onTertiary = Color.White,
|
||||
onBackground = Color(0xFF1C1B1F),
|
||||
onSurface = Color(0xFF1C1B1F),
|
||||
*/
|
||||
*/
|
||||
)
|
||||
@Suppress("CompositionLocalAllowlist")
|
||||
val LocalIsDarkTheme = compositionLocalOf<Boolean> { error("Not defined") }
|
||||
|
|
@ -87,5 +87,3 @@ fun ElementXTheme(
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ val Typography = Typography(
|
|||
lineHeight = 16.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
*/
|
||||
*/
|
||||
)
|
||||
|
||||
object ElementTextStyles {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ fun ClickableLinkText(
|
|||
uriHandler.openUri(linkAnnotations.first().item)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Text(
|
||||
|
|
@ -71,4 +70,3 @@ fun ClickableLinkText(
|
|||
inlineContent = inlineContent
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ fun ConfirmationDialog(
|
|||
onClick = {
|
||||
onDismiss()
|
||||
onSubmitClicked()
|
||||
})
|
||||
{
|
||||
}
|
||||
) {
|
||||
Text(submitText)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ android {
|
|||
|
||||
dependencies {
|
||||
implementation("com.google.android.material:material:1.7.0")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ import io.element.android.x.matrix.media.MediaFetcher
|
|||
import io.element.android.x.matrix.media.MediaKeyer
|
||||
import io.element.android.x.matrix.session.SessionStore
|
||||
import io.element.android.x.matrix.util.logError
|
||||
import java.io.File
|
||||
import java.util.Optional
|
||||
import java.util.concurrent.Executors
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.asCoroutineDispatcher
|
||||
|
|
@ -20,9 +23,6 @@ import org.matrix.rustcomponents.sdk.AuthenticationService
|
|||
import org.matrix.rustcomponents.sdk.Client
|
||||
import org.matrix.rustcomponents.sdk.ClientBuilder
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.util.Optional
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class Matrix(
|
||||
private val coroutineScope: CoroutineScope,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ import io.element.android.x.matrix.room.RoomSummaryDataSource
|
|||
import io.element.android.x.matrix.room.RustRoomSummaryDataSource
|
||||
import io.element.android.x.matrix.session.SessionStore
|
||||
import io.element.android.x.matrix.sync.SlidingSyncObserverProxy
|
||||
import java.io.Closeable
|
||||
import java.io.File
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.matrix.rustcomponents.sdk.Client
|
||||
|
|
@ -19,9 +22,6 @@ import org.matrix.rustcomponents.sdk.SlidingSyncMode
|
|||
import org.matrix.rustcomponents.sdk.SlidingSyncViewBuilder
|
||||
import org.matrix.rustcomponents.sdk.StoppableSpawn
|
||||
import timber.log.Timber
|
||||
import java.io.Closeable
|
||||
import java.io.File
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
class MatrixClient internal constructor(
|
||||
private val client: Client,
|
||||
|
|
@ -62,7 +62,7 @@ class MatrixClient internal constructor(
|
|||
.slidingSync()
|
||||
.homeserver("https://slidingsync.lab.element.dev")
|
||||
.withCommonExtensions()
|
||||
//.coldCache("ElementX")
|
||||
// .coldCache("ElementX")
|
||||
.addView(slidingSyncView)
|
||||
.build()
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package io.element.android.x.matrix.permalink
|
|||
import android.net.Uri
|
||||
import android.net.UrlQuerySanitizer
|
||||
import io.element.android.x.matrix.core.MatrixPatterns
|
||||
import timber.log.Timber
|
||||
import java.net.URLDecoder
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* This class turns a uri to a [PermalinkData].
|
||||
|
|
|
|||
|
|
@ -21,6 +21,4 @@ fun Room.timelineDiff(scope: CoroutineScope): Flow<TimelineDiff> = callbackFlow
|
|||
awaitClose {
|
||||
removeTimeline()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ package io.element.android.x.matrix.room
|
|||
import io.element.android.x.core.coroutine.CoroutineDispatchers
|
||||
import io.element.android.x.matrix.sync.roomListDiff
|
||||
import io.element.android.x.matrix.sync.state
|
||||
import java.io.Closeable
|
||||
import java.util.Collections
|
||||
import java.util.UUID
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
|
|
@ -22,9 +25,6 @@ import org.matrix.rustcomponents.sdk.SlidingSyncView
|
|||
import org.matrix.rustcomponents.sdk.SlidingSyncViewRoomsListDiff
|
||||
import org.matrix.rustcomponents.sdk.UpdateSummary
|
||||
import timber.log.Timber
|
||||
import java.io.Closeable
|
||||
import java.util.Collections
|
||||
import java.util.UUID
|
||||
|
||||
interface RoomSummaryDataSource {
|
||||
fun roomSummaries(): Flow<List<RoomSummary>>
|
||||
|
|
@ -111,7 +111,6 @@ internal class RustRoomSummaryDataSource(
|
|||
}
|
||||
|
||||
private fun MutableList<RoomSummary>.applyDiff(diff: SlidingSyncViewRoomsListDiff) {
|
||||
|
||||
fun MutableList<RoomSummary>.fillUntil(untilIndex: Int) {
|
||||
repeat((size - 1 until untilIndex).count()) {
|
||||
add(buildEmptyRoomSummary())
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package io.element.android.x.matrix.timeline
|
|||
|
||||
import io.element.android.x.core.coroutine.CoroutineDispatchers
|
||||
import io.element.android.x.matrix.room.MatrixRoom
|
||||
import java.util.Collections
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
|
@ -16,7 +17,6 @@ import org.matrix.rustcomponents.sdk.TimelineChange
|
|||
import org.matrix.rustcomponents.sdk.TimelineDiff
|
||||
import org.matrix.rustcomponents.sdk.TimelineListener
|
||||
import timber.log.Timber
|
||||
import java.util.Collections
|
||||
|
||||
class MatrixTimeline(
|
||||
private val matrixRoom: MatrixRoom,
|
||||
|
|
|
|||
|
|
@ -42,4 +42,3 @@ sealed interface MessageComposerMode {
|
|||
is Reply -> eventId
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@ import io.element.android.wysiwyg.inputhandlers.models.InlineFormat
|
|||
import io.element.android.x.core.ui.DimensionConverter
|
||||
import io.element.android.x.core.ui.hideKeyboard
|
||||
import io.element.android.x.core.ui.showKeyboard
|
||||
import io.element.android.x.element.resources.R as ElementR
|
||||
import io.element.android.x.textcomposer.databinding.ComposerRichTextLayoutBinding
|
||||
import io.element.android.x.textcomposer.databinding.ViewRichTextMenuButtonBinding
|
||||
import io.element.android.x.textcomposer.tools.setTextIfDifferent
|
||||
import uniffi.wysiwyg_composer.ActionState
|
||||
import uniffi.wysiwyg_composer.ComposerAction
|
||||
import io.element.android.x.element.resources.R as ElementR
|
||||
|
||||
// Imported from Element Android
|
||||
class RichTextComposerLayout @JvmOverloads constructor(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue