From a230e11910cf420d1c547bcef1d1dfcd3855f0e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Tue, 5 Dec 2023 13:59:45 +0100 Subject: [PATCH] Bump Spotless 6.22.0 -> 6.23.3 and Ktlint 0.50.0 -> 1.0.1 --- .editorconfig | 1 - app/core/src/main/java/com/fsck/k9/K9.kt | 4 +- .../NotificationChannelManager.kt | 3 +- .../AutocryptGossipHeaderParserTest.kt | 79 ++++++++++--------- .../K9NotificationResourceProvider.kt | 11 ++- .../java/com/fsck/k9/activity/MessageList.kt | 4 +- .../k9/activity/compose/RecipientPresenter.kt | 5 +- .../k9/ui/messagelist/MessageListFragment.kt | 3 +- .../k9/ui/messageview/MessageViewFragment.kt | 3 +- .../src/main/kotlin/AndroidExtension.kt | 8 +- ...hunderbird.quality.detekt.typed.gradle.kts | 6 +- .../thunderbird.quality.spotless.gradle.kts | 13 ++- .../molecule/ContentLoadingErrorView.kt | 4 +- gradle/libs.versions.toml | 4 +- .../com/fsck/k9/mail/internet/DecoderUtil.kt | 3 +- 15 files changed, 86 insertions(+), 65 deletions(-) diff --git a/.editorconfig b/.editorconfig index d92fbddd4..3bfab9579 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,7 +15,6 @@ max_line_length = 120 ij_kotlin_imports_layout = *,^ ij_kotlin_allow_trailing_comma = true ij_kotlin_allow_trailing_comma_on_call_site = true -ktlint_ignore_back_ticked_identifier = true [*.{yml,yaml,json,toml,md}] indent_size = 2 diff --git a/app/core/src/main/java/com/fsck/k9/K9.kt b/app/core/src/main/java/com/fsck/k9/K9.kt index 7d8d35c03..3bc8899fe 100644 --- a/app/core/src/main/java/com/fsck/k9/K9.kt +++ b/app/core/src/main/java/com/fsck/k9/K9.kt @@ -508,7 +508,9 @@ object K9 : EarlyInit { @Suppress("ktlint:standard:class-naming") enum class BACKGROUND_OPS { - ALWAYS, NEVER, WHEN_CHECKED_AUTO_SYNC + ALWAYS, + NEVER, + WHEN_CHECKED_AUTO_SYNC, } /** diff --git a/app/core/src/main/java/com/fsck/k9/notification/NotificationChannelManager.kt b/app/core/src/main/java/com/fsck/k9/notification/NotificationChannelManager.kt index b964a8d01..4750b4182 100644 --- a/app/core/src/main/java/com/fsck/k9/notification/NotificationChannelManager.kt +++ b/app/core/src/main/java/com/fsck/k9/notification/NotificationChannelManager.kt @@ -26,7 +26,8 @@ class NotificationChannelManager( val miscellaneousChannelId = "misc" enum class ChannelType { - MESSAGES, MISCELLANEOUS + MESSAGES, + MISCELLANEOUS, } init { diff --git a/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptGossipHeaderParserTest.kt b/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptGossipHeaderParserTest.kt index 59f3fb346..368daf09c 100644 --- a/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptGossipHeaderParserTest.kt +++ b/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptGossipHeaderParserTest.kt @@ -14,44 +14,6 @@ import com.fsck.k9.mailstore.MimePartStreamParser import org.junit.Test class AutocryptGossipHeaderParserTest { - val GOSSIP_DATA_BOB = Base64.decodeBase64( - """ - mQGNBFoBt74BDAC8AMsjPY17kxodbfmHah38ZQipY0yfuo97WUBs2jeiFYlQdunPANi5VMgbAX+H - Mq1XoBRs6qW+WpX8Uj11mu22c57BTUXJRbRr4TnTuuOQmT0egwFDe3x8vHSFmcf9OzG8iKR9ftUE - +F2ewrzzmm3XY8hy7QeUgBfClZVA6A3rsX4gGawjDo6ZRBbYwckINgGX/vQk6rGs - """.trimIndent().toByteArray(), - ) - - val GOSSIP_HEADER_BOB = - """ - |addr=bob@autocrypt.example; keydata= - | mQGNBFoBt74BDAC8AMsjPY17kxodbfmHah38ZQipY0yfuo97WUBs2jeiFYlQdunPANi5VMgbAX+H - | Mq1XoBRs6qW+WpX8Uj11mu22c57BTUXJRbRr4TnTuuOQmT0egwFDe3x8vHSFmcf9OzG8iKR9ftUE - | +F2ewrzzmm3XY8hy7QeUgBfClZVA6A3rsX4gGawjDo6ZRBbYwckINgGX/vQk6rGs - """.trimMargin() - - val GOSSIP_RAW_HEADER_BOB = "Autocrypt-Gossip: $GOSSIP_HEADER_BOB".crlf() - - // Example from Autocrypt 1.0 appendix - val GOSSIP_PART = - """ - |Autocrypt-Gossip: $GOSSIP_HEADER_BOB - |Autocrypt-Gossip: addr=carol@autocrypt.example; keydata= - | mQGNBFoBt8oBDADGqfZ6PqW05hUEO1dkKm+ixJXnbVriPz2tRkAqT7lTF4KBGitxo4IPv9RPIjJR - | UMUo89ddyqQfiwKxdFCMDqFDnVRWlDaM+r8sauNJoIFwtTFuvUpkFeCI5gYvneEIIbf1r3Xx1pf5 - | Iy9qsd5eg/4Vvc2AezUv+A6p2DUNHgFMX2FfDus+EPO0wgeWbNaV601aE7UhyugB - |Content-Type: text/plain - | - |Hi Bob and Carol, - | - |I wanted to introduce the two of you to each other. - | - |I hope you are both doing well! You can now both "reply all" here, - |and the thread will remain encrypted. - | - |Regards, - |Alice - """.trimMargin().crlf() private val autocryptGossipHeaderParser = AutocryptGossipHeaderParser.getInstance() @@ -115,4 +77,45 @@ class AutocryptGossipHeaderParserTest { assertThat(gossipHeader).isNull() } + + private companion object { + val GOSSIP_DATA_BOB: ByteArray = Base64.decodeBase64( + """ + mQGNBFoBt74BDAC8AMsjPY17kxodbfmHah38ZQipY0yfuo97WUBs2jeiFYlQdunPANi5VMgbAX+H + Mq1XoBRs6qW+WpX8Uj11mu22c57BTUXJRbRr4TnTuuOQmT0egwFDe3x8vHSFmcf9OzG8iKR9ftUE + +F2ewrzzmm3XY8hy7QeUgBfClZVA6A3rsX4gGawjDo6ZRBbYwckINgGX/vQk6rGs + """.trimIndent().toByteArray(), + ) + + val GOSSIP_HEADER_BOB = + """ + |addr=bob@autocrypt.example; keydata= + | mQGNBFoBt74BDAC8AMsjPY17kxodbfmHah38ZQipY0yfuo97WUBs2jeiFYlQdunPANi5VMgbAX+H + | Mq1XoBRs6qW+WpX8Uj11mu22c57BTUXJRbRr4TnTuuOQmT0egwFDe3x8vHSFmcf9OzG8iKR9ftUE + | +F2ewrzzmm3XY8hy7QeUgBfClZVA6A3rsX4gGawjDo6ZRBbYwckINgGX/vQk6rGs + """.trimMargin() + + val GOSSIP_RAW_HEADER_BOB = "Autocrypt-Gossip: $GOSSIP_HEADER_BOB".crlf() + + // Example from Autocrypt 1.0 appendix + val GOSSIP_PART = + """ + |Autocrypt-Gossip: $GOSSIP_HEADER_BOB + |Autocrypt-Gossip: addr=carol@autocrypt.example; keydata= + | mQGNBFoBt8oBDADGqfZ6PqW05hUEO1dkKm+ixJXnbVriPz2tRkAqT7lTF4KBGitxo4IPv9RPIjJR + | UMUo89ddyqQfiwKxdFCMDqFDnVRWlDaM+r8sauNJoIFwtTFuvUpkFeCI5gYvneEIIbf1r3Xx1pf5 + | Iy9qsd5eg/4Vvc2AezUv+A6p2DUNHgFMX2FfDus+EPO0wgeWbNaV601aE7UhyugB + |Content-Type: text/plain + | + |Hi Bob and Carol, + | + |I wanted to introduce the two of you to each other. + | + |I hope you are both doing well! You can now both "reply all" here, + |and the thread will remain encrypted. + | + |Regards, + |Alice + """.trimMargin().crlf() + } } diff --git a/app/k9mail/src/main/java/com/fsck/k9/notification/K9NotificationResourceProvider.kt b/app/k9mail/src/main/java/com/fsck/k9/notification/K9NotificationResourceProvider.kt index 90df7f176..dc3159d06 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/notification/K9NotificationResourceProvider.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/notification/K9NotificationResourceProvider.kt @@ -48,12 +48,13 @@ class K9NotificationResourceProvider(private val context: Context) : Notificatio override fun certificateErrorBody(): String = context.getString(R.string.notification_certificate_error_text) - override fun newMessagesTitle(newMessagesCount: Int): String = - context.resources.getQuantityString( + override fun newMessagesTitle(newMessagesCount: Int): String { + return context.resources.getQuantityString( R.plurals.notification_new_messages_title, newMessagesCount, newMessagesCount, ) + } override fun additionalMessages(overflowMessagesCount: Int, accountName: String): String = context.getString(R.string.notification_additional_messages, overflowMessagesCount, accountName) @@ -77,11 +78,9 @@ class K9NotificationResourceProvider(private val context: Context) : Notificatio override fun checkingMailTicker(accountName: String, folderName: String): String = context.getString(R.string.notification_bg_sync_ticker, accountName, folderName) - override fun checkingMailTitle(): String = - context.getString(R.string.notification_bg_sync_title) + override fun checkingMailTitle(): String = context.getString(R.string.notification_bg_sync_title) - override fun checkingMailSeparator(): String = - context.getString(R.string.notification_bg_title_separator) + override fun checkingMailSeparator(): String = context.getString(R.string.notification_bg_title_separator) override fun actionMarkAsRead(): String = context.getString(R.string.notification_action_mark_as_read) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt index bda1389ba..c875d42e8 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt @@ -1372,7 +1372,9 @@ open class MessageList : } private enum class DisplayMode { - MESSAGE_LIST, MESSAGE_VIEW, SPLIT_VIEW + MESSAGE_LIST, + MESSAGE_VIEW, + SPLIT_VIEW, } private class LaunchData( diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.kt index 250971225..8de7ec5bf 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.kt @@ -762,6 +762,9 @@ class RecipientPresenter( } enum class CryptoMode { - SIGN_ONLY, NO_CHOICE, CHOICE_DISABLED, CHOICE_ENABLED + SIGN_ONLY, + NO_CHOICE, + CHOICE_DISABLED, + CHOICE_ENABLED, } } diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListFragment.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListFragment.kt index 052c8c391..5d98a47ea 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListFragment.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListFragment.kt @@ -2046,7 +2046,8 @@ class MessageListFragment : } private enum class FolderOperation { - COPY, MOVE + COPY, + MOVE, } private enum class Error(@StringRes val errorText: Int) { diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt index 3ee9d217b..e9666bbed 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt @@ -986,7 +986,8 @@ class MessageViewFragment : } private enum class FolderOperation { - COPY, MOVE + COPY, + MOVE, } companion object { diff --git a/build-plugin/src/main/kotlin/AndroidExtension.kt b/build-plugin/src/main/kotlin/AndroidExtension.kt index b9dda6735..eb8d67950 100644 --- a/build-plugin/src/main/kotlin/AndroidExtension.kt +++ b/build-plugin/src/main/kotlin/AndroidExtension.kt @@ -46,9 +46,7 @@ internal fun CommonExtension<*, *, *, *, *>.configureSharedConfig() { } } -internal fun CommonExtension<*, *, *, *, *>.configureSharedComposeConfig( - libs: LibrariesForLibs, -) { +internal fun CommonExtension<*, *, *, *, *>.configureSharedComposeConfig(libs: LibrariesForLibs) { buildFeatures { compose = true } @@ -63,9 +61,7 @@ internal fun CommonExtension<*, *, *, *, *>.configureSharedComposeConfig( } } -internal fun DependencyHandler.configureSharedComposeDependencies( - libs: LibrariesForLibs, -) { +internal fun DependencyHandler.configureSharedComposeDependencies(libs: LibrariesForLibs) { val composeBom = platform(libs.androidx.compose.bom) implementation(composeBom) androidTestImplementation(composeBom) diff --git a/build-plugin/src/main/kotlin/thunderbird.quality.detekt.typed.gradle.kts b/build-plugin/src/main/kotlin/thunderbird.quality.detekt.typed.gradle.kts index 2ba4da48c..b14f64d0e 100644 --- a/build-plugin/src/main/kotlin/thunderbird.quality.detekt.typed.gradle.kts +++ b/build-plugin/src/main/kotlin/thunderbird.quality.detekt.typed.gradle.kts @@ -19,7 +19,7 @@ configure { tasks.withType().configureEach { jvmTarget = ThunderbirdProjectConfig.javaCompatibilityVersion.toString() - exclude(DEFAULT_EXCLUDES) + exclude(defaultExcludes) reports { html.required.set(true) @@ -31,14 +31,14 @@ tasks.withType().configureEach { tasks.withType().configureEach { jvmTarget = ThunderbirdProjectConfig.javaCompatibilityVersion.toString() - exclude(DEFAULT_EXCLUDES) + exclude(defaultExcludes) } dependencies { detektPlugins(libs.detekt.plugin.compose) } -val DEFAULT_EXCLUDES = listOf( +val defaultExcludes = listOf( "**/.gradle/**", "**/.idea/**", "**/build/**", diff --git a/build-plugin/src/main/kotlin/thunderbird.quality.spotless.gradle.kts b/build-plugin/src/main/kotlin/thunderbird.quality.spotless.gradle.kts index e59057cb4..2181f0516 100644 --- a/build-plugin/src/main/kotlin/thunderbird.quality.spotless.gradle.kts +++ b/build-plugin/src/main/kotlin/thunderbird.quality.spotless.gradle.kts @@ -7,12 +7,15 @@ plugins { configure { kotlin { ktlint(libs.versions.ktlint.get()) - .userData(mapOf("android" to "true")) + .setEditorConfigPath("$projectDir/.editorconfig") + .editorConfigOverride(editorConfigOverride) target("**/*.kt") targetExclude("**/build/", "**/resources/", "plugins/openpgp-api-lib/") } kotlinGradle { ktlint(libs.versions.ktlint.get()) + .setEditorConfigPath("$projectDir/.editorconfig") + .editorConfigOverride(editorConfigOverride) target("**/*.gradle.kts") targetExclude("**/build/") } @@ -26,3 +29,11 @@ configure { trimTrailingWhitespace() } } + +val editorConfigOverride = mapOf( + "ktlint_function_naming_ignore_when_annotated_with" to "Composable", + "ktlint_standard_property-naming" to "disabled", + "ktlint_standard_function-signature" to "disabled", + "ktlint_standard_parameter-list-spacing" to "disabled", + "ktlint_ignore_back_ticked_identifier" to "true", +) diff --git a/core/ui/compose/designsystem/src/main/kotlin/app/k9mail/core/ui/compose/designsystem/molecule/ContentLoadingErrorView.kt b/core/ui/compose/designsystem/src/main/kotlin/app/k9mail/core/ui/compose/designsystem/molecule/ContentLoadingErrorView.kt index 4378fc544..7f339821a 100644 --- a/core/ui/compose/designsystem/src/main/kotlin/app/k9mail/core/ui/compose/designsystem/molecule/ContentLoadingErrorView.kt +++ b/core/ui/compose/designsystem/src/main/kotlin/app/k9mail/core/ui/compose/designsystem/molecule/ContentLoadingErrorView.kt @@ -40,7 +40,9 @@ fun ContentLoadingErrorView( } enum class ContentLoadingErrorState { - Loading, Content, Error + Loading, + Content, + Error, } @Composable diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b621f6699..874258edd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ [versions] gradle = "8.5" androidGradlePlugin = "8.1.4" -ktlint = "0.50.0" +ktlint = "1.0.1" kotlin = "1.9.20" kotlinxCoroutines = "1.7.3" @@ -48,7 +48,7 @@ ksp = "com.google.devtools.ksp:1.9.20-1.0.14" kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -spotless = "com.diffplug.spotless:6.22.0" +spotless = "com.diffplug.spotless:6.23.3" detekt = "io.gitlab.arturbosch.detekt:1.23.4" dependency-check = "com.github.ben-manes.versions:0.50.0" diff --git a/mail/common/src/main/java/com/fsck/k9/mail/internet/DecoderUtil.kt b/mail/common/src/main/java/com/fsck/k9/mail/internet/DecoderUtil.kt index 4a9ddbcc2..fdbad16bd 100644 --- a/mail/common/src/main/java/com/fsck/k9/mail/internet/DecoderUtil.kt +++ b/mail/common/src/main/java/com/fsck/k9/mail/internet/DecoderUtil.kt @@ -196,6 +196,7 @@ internal object DecoderUtil { } private enum class Encoding { - Q, B + Q, + B, } }