From 55609252484411de595421968f523c04c5d362dd Mon Sep 17 00:00:00 2001 From: Vincent TE Date: Wed, 20 Aug 2025 10:59:31 +0200 Subject: [PATCH 1/6] chore: Add ktlint baseline profile --- .editorconfig | 20 + .github/workflows/android.yml | 17 + app/config/ktlint/baseline.xml | 1850 ++++++++++++++++++++++++++++++++ build.gradle.kts | 5 + 4 files changed, 1892 insertions(+) create mode 100644 .editorconfig create mode 100644 app/config/ktlint/baseline.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..531f4d2ea5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# Kotlin Ktlint +root = true + +[*.{kt,kts}] + +ktlint_code_style = android_studio + +ktlint_standard_no-wildcard-imports = disabled +ktlint_standard_no-empty-first-line-in-class-body = disabled +ktlint_standard_no-line-break-before-assignment = disabled +ktlint_standard_multiline-expression-wrapping = disabled +ktlint_standard_string-template-indent = disabled +ktlint_standard_trailing-comma-on-call-site = disabled +ktlint_standard_trailing-comma-on-declaration-site = disabled +ktlint_standard_no-empty-first-line-in-method-block = disabled +ktlint_standard_expression-body-wrapping = disabled +ktlint_standard_function-signature = disabled +ktlint_standard_spacing-between-declarations-with-annotations = disabled + +max_line_length = 130 diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index e15c8487df..97adb3433a 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -9,6 +9,23 @@ concurrency: jobs: + ktlint: + runs-on: ubuntu-latest + + steps: + - name: Checkout the code + uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Install ktlint + run: curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.7.1/ktlint && chmod a+x ktlint + + - name: Run ktlint + run: ./ktlint 'src/**/*.kt' --baseline=config/ktlint/baseline.xml + instrumentation-tests: if: github.event.pull_request.draft == false runs-on: [ self-hosted, Android ] diff --git a/app/config/ktlint/baseline.xml b/app/config/ktlint/baseline.xml new file mode 100644 index 0000000000..dda35cbcaa --- /dev/null +++ b/app/config/ktlint/baseline.xml @@ -0,0 +1,1850 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build.gradle.kts b/build.gradle.kts index 87b256e1f9..6585f8eb64 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,6 +21,11 @@ plugins { alias(libs.plugins.jetbrains.kotlin.serialization) apply false alias(libs.plugins.kapt) apply false alias(libs.plugins.realm.kotlin) apply false + alias(core.plugins.ktlint) version "13.0.0" +} + +subprojects { + apply(plugin = "org.jlleitschuh.gradle.ktlint") } tasks.register("clean", Delete::class) { delete(rootProject.layout.buildDirectory) } From 7a1fb0427cee734ae395e64a6316de741c545825 Mon Sep 17 00:00:00 2001 From: Vincent TE Date: Wed, 20 Aug 2025 14:56:57 +0200 Subject: [PATCH 2/6] chore: Use .editorconfig from Core --- .editorconfig | 20 -------------------- Core | 2 +- 2 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 531f4d2ea5..0000000000 --- a/.editorconfig +++ /dev/null @@ -1,20 +0,0 @@ -# Kotlin Ktlint -root = true - -[*.{kt,kts}] - -ktlint_code_style = android_studio - -ktlint_standard_no-wildcard-imports = disabled -ktlint_standard_no-empty-first-line-in-class-body = disabled -ktlint_standard_no-line-break-before-assignment = disabled -ktlint_standard_multiline-expression-wrapping = disabled -ktlint_standard_string-template-indent = disabled -ktlint_standard_trailing-comma-on-call-site = disabled -ktlint_standard_trailing-comma-on-declaration-site = disabled -ktlint_standard_no-empty-first-line-in-method-block = disabled -ktlint_standard_expression-body-wrapping = disabled -ktlint_standard_function-signature = disabled -ktlint_standard_spacing-between-declarations-with-annotations = disabled - -max_line_length = 130 diff --git a/Core b/Core index 35561ae10d..4859b0b8f9 160000 --- a/Core +++ b/Core @@ -1 +1 @@ -Subproject commit 35561ae10db9495f0f3f221f532d21670137a44e +Subproject commit 4859b0b8f9b1116c908d17a2033bcc0f4252b109 From 9d0abedd1c6fad8dc4a4c2c6b3c65ae469d0bd09 Mon Sep 17 00:00:00 2001 From: Vincent TE Date: Wed, 20 Aug 2025 15:13:06 +0200 Subject: [PATCH 3/6] chore: Re add .editorconfig --- .editorconfig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..531f4d2ea5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# Kotlin Ktlint +root = true + +[*.{kt,kts}] + +ktlint_code_style = android_studio + +ktlint_standard_no-wildcard-imports = disabled +ktlint_standard_no-empty-first-line-in-class-body = disabled +ktlint_standard_no-line-break-before-assignment = disabled +ktlint_standard_multiline-expression-wrapping = disabled +ktlint_standard_string-template-indent = disabled +ktlint_standard_trailing-comma-on-call-site = disabled +ktlint_standard_trailing-comma-on-declaration-site = disabled +ktlint_standard_no-empty-first-line-in-method-block = disabled +ktlint_standard_expression-body-wrapping = disabled +ktlint_standard_function-signature = disabled +ktlint_standard_spacing-between-declarations-with-annotations = disabled + +max_line_length = 130 From 28c349ccdd793159a06656076caf1e7ef18c901b Mon Sep 17 00:00:00 2001 From: Vincent TE Date: Wed, 20 Aug 2025 15:13:23 +0200 Subject: [PATCH 4/6] chore: Update Core --- Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core b/Core index 4859b0b8f9..35561ae10d 160000 --- a/Core +++ b/Core @@ -1 +1 @@ -Subproject commit 4859b0b8f9b1116c908d17a2033bcc0f4252b109 +Subproject commit 35561ae10db9495f0f3f221f532d21670137a44e From 43fbc27fc70515d1e396a90f5370e25d043e527e Mon Sep 17 00:00:00 2001 From: Vincent TE Date: Thu, 21 Aug 2025 10:00:53 +0200 Subject: [PATCH 5/6] chore: Add ktlint to modules --- Core | 2 +- EmojiComponents/build.gradle.kts | 12 ++ EmojiComponents/config/ktlint/baseline.xml | 170 +++++++++++++++++++++ HtmlCleaner/build.gradle | 12 ++ HtmlCleaner/config/ktlint/baseline.xml | 17 +++ app/build.gradle.kts | 12 ++ app/config/ktlint/baseline.xml | 48 +----- 7 files changed, 230 insertions(+), 43 deletions(-) create mode 100644 EmojiComponents/config/ktlint/baseline.xml create mode 100644 HtmlCleaner/config/ktlint/baseline.xml diff --git a/Core b/Core index 35561ae10d..ee15f60506 160000 --- a/Core +++ b/Core @@ -1 +1 @@ -Subproject commit 35561ae10db9495f0f3f221f532d21670137a44e +Subproject commit ee15f605066a0fb963f2241f0871da900d994f1f diff --git a/EmojiComponents/build.gradle.kts b/EmojiComponents/build.gradle.kts index fc9c5a2673..6365660f24 100644 --- a/EmojiComponents/build.gradle.kts +++ b/EmojiComponents/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jlleitschuh.gradle.ktlint.reporter.ReporterType + plugins { id("com.android.library") alias(core.plugins.kotlin.android) @@ -37,6 +39,16 @@ android { } } +ktlint { + version.set("1.7.1") + android.set(true) + ignoreFailures.set(true) + reporters { + reporter(ReporterType.PLAIN) + } + baseline.set(file("${projectDir}/config/ktlint/baseline.xml")) +} + dependencies { implementation(project(":Core:Avatar")) implementation(project(":Core:Compose:Margin")) diff --git a/EmojiComponents/config/ktlint/baseline.xml b/EmojiComponents/config/ktlint/baseline.xml new file mode 100644 index 0000000000..7d4f0ed7b5 --- /dev/null +++ b/EmojiComponents/config/ktlint/baseline.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HtmlCleaner/build.gradle b/HtmlCleaner/build.gradle index f26ddfd99e..6405699c2f 100644 --- a/HtmlCleaner/build.gradle +++ b/HtmlCleaner/build.gradle @@ -1,3 +1,5 @@ +import org.jlleitschuh.gradle.ktlint.reporter.ReporterType + apply plugin: 'com.android.library' apply plugin: 'kotlin-android' @@ -28,6 +30,16 @@ android { } } +ktlint { + version.set("1.7.1") + android.set(true) + ignoreFailures.set(true) + reporters { + reporter(ReporterType.PLAIN) + } + baseline.set(file("${projectDir}/config/ktlint/baseline.xml")) +} + dependencies { api libs.jsoup } diff --git a/HtmlCleaner/config/ktlint/baseline.xml b/HtmlCleaner/config/ktlint/baseline.xml new file mode 100644 index 0000000000..6d745a833f --- /dev/null +++ b/HtmlCleaner/config/ktlint/baseline.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a305f63959..fb54bd9275 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jlleitschuh.gradle.ktlint.reporter.ReporterType + plugins { alias(libs.plugins.android.application) alias(libs.plugins.dagger.hilt) @@ -101,6 +103,16 @@ kotlin { } } +ktlint { + version.set("1.7.1") + android.set(true) + ignoreFailures.set(true) + reporters { + reporter(ReporterType.PLAIN) + } + baseline.set(file("${projectDir}/config/ktlint/baseline.xml")) +} + dependencies { implementation(project(":Core")) implementation(project(":Core:Auth")) diff --git a/app/config/ktlint/baseline.xml b/app/config/ktlint/baseline.xml index dda35cbcaa..ee093deb1c 100644 --- a/app/config/ktlint/baseline.xml +++ b/app/config/ktlint/baseline.xml @@ -1,8 +1,9 @@ - - + + + @@ -176,6 +177,7 @@ + @@ -251,11 +253,6 @@ - - - - - @@ -425,10 +422,8 @@ - - @@ -486,10 +481,6 @@ - - - - @@ -552,6 +543,7 @@ + @@ -764,8 +756,6 @@ - - @@ -775,13 +765,10 @@ - - - @@ -803,13 +790,10 @@ - - - @@ -913,7 +897,6 @@ - @@ -950,10 +933,8 @@ - - @@ -1088,10 +1069,8 @@ - - @@ -1146,7 +1125,6 @@ - @@ -1162,11 +1140,8 @@ - - - @@ -1348,16 +1323,12 @@ - - - - @@ -1500,13 +1471,10 @@ - - - @@ -1559,6 +1527,7 @@ + @@ -1569,7 +1538,6 @@ - @@ -1611,7 +1579,6 @@ - @@ -1643,9 +1610,6 @@ - - - From 924ee2a54cac85eda8b59cb6ee6fa563f6465a27 Mon Sep 17 00:00:00 2001 From: Vincent TE Date: Thu, 21 Aug 2025 11:40:40 +0200 Subject: [PATCH 6/6] chore: Set ignoreFailure to false since we have the baseline file --- EmojiComponents/build.gradle.kts | 2 +- HtmlCleaner/build.gradle | 2 +- app/build.gradle.kts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/EmojiComponents/build.gradle.kts b/EmojiComponents/build.gradle.kts index 6365660f24..813cf8a82e 100644 --- a/EmojiComponents/build.gradle.kts +++ b/EmojiComponents/build.gradle.kts @@ -42,7 +42,7 @@ android { ktlint { version.set("1.7.1") android.set(true) - ignoreFailures.set(true) + ignoreFailures.set(false) reporters { reporter(ReporterType.PLAIN) } diff --git a/HtmlCleaner/build.gradle b/HtmlCleaner/build.gradle index 6405699c2f..35eb67a8f7 100644 --- a/HtmlCleaner/build.gradle +++ b/HtmlCleaner/build.gradle @@ -33,7 +33,7 @@ android { ktlint { version.set("1.7.1") android.set(true) - ignoreFailures.set(true) + ignoreFailures.set(false) reporters { reporter(ReporterType.PLAIN) } diff --git a/app/build.gradle.kts b/app/build.gradle.kts index fb54bd9275..8fd7ce97fe 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -106,7 +106,7 @@ kotlin { ktlint { version.set("1.7.1") android.set(true) - ignoreFailures.set(true) + ignoreFailures.set(false) reporters { reporter(ReporterType.PLAIN) }