Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Spotless #7328

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@ root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
indent_size = 4
ij_continuation_indent_size = 4
tab_width = 4
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
max_line_length = 120

[*.{kt,kts}]
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}]
[*.{yml,yaml,json,toml,md}]
indent_size = 2
tab_width = 2
ij_continuation_indent_size = 2

[*.md]
trim_trailing_whitespace = false
26 changes: 13 additions & 13 deletions .github/workflows/markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ on:
- '.github/workflows/markdown.yml'

jobs:
markdown_quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
markdown_quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- uses: gradle/gradle-build-action@v2
- uses: gradle/gradle-build-action@v2

- name: Quality - Spotless Markdown Check
run: ./gradlew spotlessMarkdownCheck
- name: Quality - Spotless Markdown Check
run: ./gradlew spotlessMarkdownCheck
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ class NotificationHelper(
try {
notificationManager.notify(notificationId, notification)
} catch (e: SecurityException) {
// When importing settings from another device, we could end up with a NotificationChannel that references a
// non-existing notification sound. In that case, we end up with a SecurityException with a message similar
// to this:
// UID 123 does not have permission to content://media/external_primary/audio/media/42?title=Coins&canonical=1 [user 0]
// When importing settings from another device, we could end up with a NotificationChannel that references
// a non-existing notification sound. In that case, we end up with a SecurityException with a message
// similar to this:
// UID 123 does not have permission to
// content://media/external_primary/audio/media/42?title=Coins&canonical=1 [user 0]
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
e.message?.contains("does not have permission to") == true
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ class GenericUriParserTest {
assertUriValid("xmpp:[email protected]?message")
assertUriValid("xmpp:[email protected]?message;subject=Hello%20World")
assertUriValid("xmpp:nasty!%23\$%25()*+,-.;=%3F%5B%5C%5D%5E_%60%7B%7C%[email protected]")
assertUriValid("xmpp:[email protected]/repulsive%20!%23%22\$%25&'()*+,-.%2F:;%3C=%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%7D~resource")
assertUriValid(
"xmpp:[email protected]/repulsive" +
"%20!%23%22\$%25&'()*+,-.%2F:;%3C=%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%7D~resource",
)
assertUriValid("xmpp:ji%C5%99i@%C4%8Dechy.example/v%20Praze")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ internal class MigrationTo70(private val db: SQLiteDatabase) {

private fun recreateFoldersTriggers() {
db.execSQL("DROP TRIGGER IF EXISTS delete_folder")
db.execSQL("CREATE TRIGGER delete_folder BEFORE DELETE ON folders BEGIN DELETE FROM messages WHERE old.id = folder_id; END;")
db.execSQL(
"CREATE TRIGGER delete_folder " +
"BEFORE DELETE ON folders " +
"BEGIN " +
"DELETE FROM messages WHERE old.id = folder_id; " +
"END;",
)

db.execSQL("DROP TRIGGER IF EXISTS delete_folder_extra_values")
db.execSQL(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ internal class MigrationTo84(private val db: SQLiteDatabase) {

fun rewriteAddresses() {
val addressSets = db.rawQuery(
"SELECT id, to_list, cc_list, bcc_list, reply_to_list, sender_list FROM messages WHERE empty = 0 AND deleted = 0",
"SELECT id, to_list, cc_list, bcc_list, reply_to_list, sender_list " +
"FROM messages WHERE empty = 0 AND deleted = 0",
null,
).use { cursor ->
cursor.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.fsck.k9.message.AutocryptStatusInteractor
import com.fsck.k9.message.AutocryptStatusInteractor.RecipientAutocryptStatus
import com.fsck.k9.message.CryptoStatus
import com.fsck.k9.view.RecipientSelectView.Recipient
import org.openintents.openpgp.OpenPgpApiManager
import org.openintents.openpgp.OpenPgpApiManager.OpenPgpProviderState

/** This is an immutable object which contains all relevant metadata entered
Expand Down Expand Up @@ -76,10 +75,10 @@ data class ComposeCryptoStatus(
val recipientAddressesAsArray = recipientAddresses.toTypedArray()

private val displayTypeFromProviderError = when (openPgpProviderState) {
OpenPgpApiManager.OpenPgpProviderState.OK -> null
OpenPgpApiManager.OpenPgpProviderState.UNCONFIGURED -> CryptoStatusDisplayType.UNCONFIGURED
OpenPgpApiManager.OpenPgpProviderState.UNINITIALIZED -> CryptoStatusDisplayType.UNINITIALIZED
OpenPgpApiManager.OpenPgpProviderState.ERROR, OpenPgpApiManager.OpenPgpProviderState.UI_REQUIRED -> CryptoStatusDisplayType.ERROR
OpenPgpProviderState.OK -> null
OpenPgpProviderState.UNCONFIGURED -> CryptoStatusDisplayType.UNCONFIGURED
OpenPgpProviderState.UNINITIALIZED -> CryptoStatusDisplayType.UNINITIALIZED
OpenPgpProviderState.ERROR, OpenPgpProviderState.UI_REQUIRED -> CryptoStatusDisplayType.ERROR
}

private val displayTypeFromAutocryptError = when (recipientAutocryptStatusType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ class MessageViewFragment :
if (menuVisible) {
messageLoaderHelper.resumeCryptoOperationIfNecessary()
} else {
// When the menu is hidden, the message associated with this fragment is no longer active. If the user returns
// to it, we want to mark the message as opened again.
// When the menu is hidden, the message associated with this fragment is no longer active. If the user
// returns to it, we want to mark the message as opened again.
wasMessageMarkedAsOpened = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ class JmapBackend(
return messageServerIds.associateWith { it }
}

override fun moveMessagesAndMarkAsRead(sourceFolderServerId: String, targetFolderServerId: String, messageServerIds: List<String>): Map<String, String>? {
override fun moveMessagesAndMarkAsRead(
sourceFolderServerId: String,
targetFolderServerId: String,
messageServerIds: List<String>,
): Map<String, String>? {
commandMove.moveMessagesAndMarkAsRead(targetFolderServerId, messageServerIds)
return messageServerIds.associateWith { it }
}
Expand Down
2 changes: 0 additions & 2 deletions config/detekt/detekt-baseline-app-core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@
<ID>MagicNumber:ServerSettingsSerializer.kt$ServerSettingsAdapter$7</ID>
<ID>MagicNumber:SettingsExporter.kt$SettingsExporter$3</ID>
<ID>MagicNumber:TimberLogger.kt$TimberLogger$26</ID>
<ID>MaxLineLength:GenericUriParserTest.kt$GenericUriParserTest$assertUriValid("xmpp:[email protected]/repulsive%20!%23%22\$%25&amp;'()*+,-.%2F:;%3C=%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%7D~resource")</ID>
<ID>MaxLineLength:NotificationHelper.kt$NotificationHelper$// UID 123 does not have permission to content://media/external_primary/audio/media/42?title=Coins&amp;canonical=1 [user 0]</ID>
<ID>MayBeConst:SummaryNotificationDataCreatorTest.kt$private val TIMESTAMP = 0L</ID>
<ID>MemberNameEqualsClassName:HtmlModification.kt$HtmlModification.Replace$abstract fun replace(textToHtml: TextToHtml)</ID>
<ID>NestedBlockDepth:HttpUriParser.kt$HttpUriParser$private fun tryMatchIpv6Address(text: CharSequence, startPos: Int): Int</ID>
Expand Down
2 changes: 0 additions & 2 deletions config/detekt/detekt-baseline-app-storage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@
<ID>MagicNumber:StorageMigrationTo17.kt$StorageMigrationTo17$0xFFFF00</ID>
<ID>MagicNumber:StorageMigrationTo17.kt$StorageMigrationTo17$0xFFFFFF</ID>
<ID>MagicNumber:ThreadMessageOperations.kt$ThreadMessageOperations$3</ID>
<ID>MaxLineLength:MigrationTo70.kt$MigrationTo70$db.execSQL("CREATE TRIGGER delete_folder BEFORE DELETE ON folders BEGIN DELETE FROM messages WHERE old.id = folder_id; END;")</ID>
<ID>MaxLineLength:MigrationTo84.kt$MigrationTo84$"SELECT id, to_list, cc_list, bcc_list, reply_to_list, sender_list FROM messages WHERE empty = 0 AND deleted = 0"</ID>
<ID>MaxLineLength:RetrieveMessageListOperationsTest.kt$RetrieveMessageListOperationsTest$fun</ID>
<ID>ReturnCount:SaveMessageOperationsTest.kt$SaveMessageOperationsTest$private fun Message.getDownloadState(): MessageDownloadState</ID>
<ID>ReturnCount:StorageMigrationTo19.kt$StorageMigrationTo19$private fun markIfGmailAccount(accountUuid: String)</ID>
Expand Down
5 changes: 0 additions & 5 deletions config/detekt/detekt-baseline-app-ui-legacy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,10 @@
<ID>MagicNumber:SizeFormatter.kt$SizeFormatter$1_000_000L</ID>
<ID>MagicNumber:SizeFormatter.kt$SizeFormatter$999_950L</ID>
<ID>MagicNumber:SizeFormatter.kt$SizeFormatter$999_950_000L</ID>
<ID>MaxLineLength:ComposeCryptoStatus.kt$ComposeCryptoStatus$OpenPgpApiManager.OpenPgpProviderState.ERROR, OpenPgpApiManager.OpenPgpProviderState.UI_REQUIRED -&gt; CryptoStatusDisplayType.ERROR</ID>
<ID>MaxLineLength:MessageViewFragment.kt$MessageViewFragment$// When the menu is hidden, the message associated with this fragment is no longer active. If the user returns</ID>
<ID>MemberNameEqualsClassName:ReplyToView.kt$ReplyToView$private val replyToView: RecipientSelectView = activity.findViewById(R.id.reply_to)</ID>
<ID>NestedBlockDepth:MessageList.kt$MessageList$override fun onBackPressed()</ID>
<ID>NestedBlockDepth:MessageList.kt$MessageList$override fun onOptionsItemSelected(item: MenuItem): Boolean</ID>
<ID>NestedBlockDepth:MessageList.kt$MessageList$private fun decodeExtrasToLaunchData(intent: Intent): LaunchData</ID>
<ID>ReturnCount:AccountSetupBasics.kt$AccountSetupBasics$private fun providersXmlDiscoveryDiscover(email: String): ConnectionSettings?</ID>
<ID>ReturnCount:AccountSetupBasics.kt$private fun DiscoveredServerSettings.toServerSettings(): ServerSettings?</ID>
<ID>ReturnCount:AccountSetupCheckSettings.kt$AccountSetupCheckSettings.CheckAccountTask$private fun isCanceled(): Boolean</ID>
<ID>ReturnCount:ChooseFolderActivity.kt$ChooseFolderActivity$private fun decodeArguments(savedInstanceState: Bundle?): Boolean</ID>
<ID>ReturnCount:EditIdentity.kt$EditIdentity$override fun onOptionsItemSelected(item: MenuItem): Boolean</ID>
Expand Down Expand Up @@ -162,7 +158,6 @@
<ID>TooGenericExceptionThrown:MessageViewFragment.kt$MessageViewFragment$throw RuntimeException("Called showDialog(int) with unknown dialog id.")</ID>
<ID>TooManyFunctions:AccountSettingsDataStore.kt$AccountSettingsDataStore : PreferenceDataStore</ID>
<ID>TooManyFunctions:AccountSettingsFragment.kt$AccountSettingsFragment : PreferenceFragmentCompatConfirmationDialogFragmentListener</ID>
<ID>TooManyFunctions:AccountSetupBasics.kt$AccountSetupBasics : K9Activity</ID>
<ID>TooManyFunctions:AccountSetupCheckSettings.kt$AccountSetupCheckSettings : K9ActivityConfirmationDialogFragmentListener</ID>
<ID>TooManyFunctions:AuthViewModel.kt$AuthViewModel : AndroidViewModel</ID>
<ID>TooManyFunctions:AutocryptKeyTransferActivity.kt$AutocryptKeyTransferActivity : K9Activity</ID>
Expand Down
1 change: 0 additions & 1 deletion config/detekt/detekt-baseline-backend-jmap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues>
<ID>ForbiddenComment:CommandSync.kt$CommandSync$// FIXME: Add sort parameter</ID>
<ID>MaxLineLength:JmapBackend.kt$JmapBackend$override</ID>
<ID>ReturnCount:JmapAccountDiscovery.kt$JmapAccountDiscovery$fun discover(emailAddress: String, password: String): JmapDiscoveryResult</ID>
<ID>SwallowedException:JmapAccountDiscovery.kt$JmapAccountDiscovery$e: EndpointNotFoundException</ID>
<ID>SwallowedException:JmapAccountDiscovery.kt$JmapAccountDiscovery$e: UnauthorizedException</ID>
Expand Down
1 change: 0 additions & 1 deletion config/detekt/detekt-baseline-mail-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<ID>MagicNumber:Utf8.kt$3</ID>
<ID>MagicNumber:Utf8.kt$4</ID>
<ID>MagicNumber:Utf8.kt$6</ID>
<ID>MaxLineLength:BoundaryGeneratorTest.kt$BoundaryGeneratorTest$0</ID>
<ID>ReturnCount:DecoderUtil.kt$DecoderUtil$@JvmStatic fun decodeEncodedWords(body: String, message: Message?): String</ID>
<ID>ReturnCount:DecoderUtil.kt$DecoderUtil$private fun extractEncodedWord(body: String, begin: Int, end: Int, message: Message?): EncodedWord?</ID>
<ID>ReturnCount:FormatFlowedHelper.kt$FormatFlowedHelper$@JvmStatic fun checkFormatFlowed(contentTypeHeaderValue: String?): FormatFlowedResult</ID>
Expand Down
1 change: 0 additions & 1 deletion config/detekt/detekt-baseline-mail-protocols-imap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<ID>MagicNumber:RealImapFolder.kt$RealImapFolder$9</ID>
<ID>MagicNumber:UidValidityResponse.kt$UidValidityResponse.Companion$0xFFFFFFFFL</ID>
<ID>MaxLineLength:RealImapFolder.kt$RealImapFolder$// [MESSAGE, RFC822, [NAME, Fwd: [#HTR-517941]: update plans at 1am Friday - Memory allocation - displayware.eml], NIL, NIL, 7BIT, 5974, NIL, [INLINE, [FILENAME*0, Fwd: [#HTR-517941]: update plans at 1am Friday - Memory all, FILENAME*1, ocation - displayware.eml]], NIL]</ID>
<ID>MaxLineLength:RealImapFolder.kt$RealImapFolder$val canCreateForwardedFlag = canCreateKeywords || internalImapStore.getPermanentFlagsIndex().contains(Flag.FORWARDED)</ID>
<ID>MaxLineLength:RealImapStoreTest.kt$RealImapStoreTest$fun</ID>
<ID>NestedBlockDepth:RealImapFolder.kt$RealImapFolder$@Throws(MessagingException::class) override fun appendMessages(messages: List&lt;Message&gt;): Map&lt;String, String&gt;?</ID>
<ID>NestedBlockDepth:RealImapFolder.kt$RealImapFolder$@Throws(MessagingException::class) override fun fetch( messages: List&lt;ImapMessage&gt;, fetchProfile: FetchProfile, listener: FetchListener?, maxDownloadSize: Int, )</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ inline fun <reified STATE, EVENT, EFFECT> UnidirectionalViewModel<STATE, EVENT,
*/
@Suppress("MaxLineLength")
@Composable
inline fun <reified STATE, EVENT, EFFECT> UnidirectionalViewModel<STATE, EVENT, EFFECT>.observeWithoutEffect(): StateDispatch<STATE, EVENT> {
inline fun <reified STATE, EVENT, EFFECT> UnidirectionalViewModel<STATE, EVENT, EFFECT>.observeWithoutEffect(
// no effect handler
): StateDispatch<STATE, EVENT> {
val collectedState = state.collectAsStateWithLifecycle()
val dispatch: (EVENT) -> Unit = { event(it) }

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ksp = "com.google.devtools.ksp:1.9.10-1.0.13"
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.21.0"
spotless = "com.diffplug.spotless:6.22.0"
detekt = "io.gitlab.arturbosch.detekt:1.23.0"
dependency-check = "com.github.ben-manes.versions:0.48.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ class BoundaryGeneratorTest {

@Test
fun generateBoundary() {
val random = createRandom(
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 35,
)
val seed = IntRange(0, 28).toList().toIntArray()

val random = createRandom(*seed, 35)

Comment on lines +22 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note (for future changes): I think it's useful when tests are separated into arrange, act, assert blocks. Most of the time this separation can be easily achieved by using an empty line between the blocks. By introducing additional empty lines, this change makes it somewhat harder to figure out at a glance which lines belong to which block.

val boundaryGenerator = BoundaryGenerator(random)

val result = boundaryGenerator.generateBoundary()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -970,9 +970,12 @@ internal class RealImapFolder(

val encodeFolderName = folderNameCodec.encode(prefixedName)
val escapedFolderName = ImapUtility.encodeString(encodeFolderName)
val canCreateForwardedFlag = canCreateKeywords ||
internalImapStore.getPermanentFlagsIndex().contains(Flag.FORWARDED)

val combinedFlags = ImapUtility.combineFlags(
message.flags,
canCreateKeywords || internalImapStore.getPermanentFlagsIndex().contains(Flag.FORWARDED),
canCreateForwardedFlag,
)
val command = String.format(
Locale.US,
Expand Down Expand Up @@ -1101,7 +1104,9 @@ internal class RealImapFolder(
open(OpenMode.READ_WRITE)
checkOpen()

val canCreateForwardedFlag = canCreateKeywords || internalImapStore.getPermanentFlagsIndex().contains(Flag.FORWARDED)
val canCreateForwardedFlag = canCreateKeywords ||
internalImapStore.getPermanentFlagsIndex().contains(Flag.FORWARDED)

try {
val combinedFlags = ImapUtility.combineFlags(flags, canCreateForwardedFlag)
val command = String.format(
Expand All @@ -1123,7 +1128,8 @@ internal class RealImapFolder(
checkOpen()

val uids = messages.map { it.uid.toLong() }.toSet()
val canCreateForwardedFlag = canCreateKeywords || internalImapStore.getPermanentFlagsIndex().contains(Flag.FORWARDED)
val canCreateForwardedFlag = canCreateKeywords ||
internalImapStore.getPermanentFlagsIndex().contains(Flag.FORWARDED)
val combinedFlags = ImapUtility.combineFlags(flags, canCreateForwardedFlag)
val commandSuffix = String.format("%sFLAGS.SILENT (%s)", if (value) "+" else "-", combinedFlags)
try {
Expand Down