Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit fe5a07e7 authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé Committed by GitHub
Browse files

Merge pull request #8395 from wmontwe/fix-spotless-being-slow

Fix spotless being slow
parents 5a0fa0c2 039a9255
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ Please ensure that your pull request meets the following requirements - thanks!
- Does not contain merge commits. Rebase instead.
- Contains commits with descriptive titles.
- New code is written in Kotlin whenever possible.
- Follows our existing codestyle (`gradlew spotlessCheck` to check and `gradlew spotlessFormat` to format your source code; will be checked by CI).
- Follows our existing codestyle (`gradlew spotlessCheck` to check and `gradlew spotlessApply` to format your source code; will be checked by CI).
- Does not break any unit tests (`gradlew testDebugUnitTest`; will be checked by CI).
- Uses a descriptive title; don't put issue numbers in there.
- Contains a reference to the issue that it fixes (e.g. _Closes #XXX_ or _Fixes #XXX_) in the body text.
+67 −0
Original line number Diff line number Diff line
import com.diffplug.gradle.spotless.SpotlessExtension
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Project

fun SpotlessExtension.configureKotlinCheck(
    targets: List<String>,
    project: Project,
    libs: LibrariesForLibs,
) {
    kotlin {
        ktlint(libs.versions.ktlint.get())
            .setEditorConfigPath("${project.rootProject.projectDir}/.editorconfig")
            .editorConfigOverride(kotlinEditorConfigOverride)
        target(targets)
        targetExclude(
            "**/build/",
        )
    }
}

fun SpotlessExtension.configureKotlinGradleCheck(
    targets: List<String>,
    project: Project,
    libs: LibrariesForLibs,
) {
    kotlinGradle {
        ktlint(libs.versions.ktlint.get())
            .setEditorConfigPath("${project.rootProject.projectDir}/.editorconfig")
            .editorConfigOverride(
                mapOf(
                    "ktlint_standard_function-signature" to "disabled",
                )
            )
        target(targets)
        targetExclude("**/build/")
    }
}

fun SpotlessExtension.configureMarkdownCheck(
    targets: List<String>,
) {
    format("markdown") {
        prettier()
        target(targets)
        targetExclude(
            "**/build/",
        )
    }
}

fun SpotlessExtension.configureMiscCheck() {
    format("misc") {
        target(
            "*.gradle",
            ".gitignore",
        )
        trimTrailingWhitespace()
    }
}

val kotlinEditorConfigOverride = 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",
)
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ plugins {
    id("thunderbird.app.android")
    id("org.jetbrains.kotlin.plugin.compose")
    id("thunderbird.quality.detekt.typed")
    id("thunderbird.quality.spotless")
}

android {
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("thunderbird.quality.detekt.typed")
    id("thunderbird.quality.spotless")
}

android {
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ plugins {
    id("application")
    id("org.jetbrains.kotlin.jvm")
    id("thunderbird.quality.detekt.typed")
    id("thunderbird.quality.spotless")
}

java {
Loading