From 1f3c8e4fc208d5db49ffeb4aba32e409f7527e83 Mon Sep 17 00:00:00 2001 From: Colin White Date: Sat, 13 Aug 2022 22:15:24 -0700 Subject: [PATCH] Migrate to kotlinter and update ktlint to 0.46.1. (#1399) --- .github/workflows/ci.yml | 2 +- build.gradle.kts | 18 +++++++++++++----- gradle/libs.versions.toml | 4 ++-- test.sh | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f79503287b..a656551db8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: uses: gradle/wrapper-validation-action@v1 - name: Check style - run: ./gradlew ktlintCheck + run: ./gradlew lintKotlin # Check if there has been a binary incompatible change to the API. # If this change is intentional, run `./gradlew apiDump` and commit the new API files. diff --git a/build.gradle.kts b/build.gradle.kts index ed51746c3f..2b74d7e98f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,6 @@ import com.vanniktech.maven.publish.SonatypeHost.DEFAULT import kotlinx.validation.ApiValidationExtension import org.jetbrains.dokka.gradle.DokkaMultiModuleTask import org.jetbrains.dokka.gradle.DokkaTaskPartial -import org.jlleitschuh.gradle.ktlint.KtlintExtension import java.net.URL buildscript { @@ -51,11 +50,20 @@ allprojects { group = project.groupId version = project.versionName - apply(plugin = "org.jlleitschuh.gradle.ktlint") + apply(plugin = "org.jmailen.kotlinter") - extensions.configure { - version by rootProject.libs.versions.ktlint - disabledRules by setOf("indent", "max-line-length", "parameter-list-wrapping") + kotlinter { + version = rootProject.libs.versions.ktlint + disabledRules = arrayOf( + "annotation", + "argument-list-wrapping", + "filename", + "indent", + "max-line-length", + "parameter-list-wrapping", + "spacing-between-declarations-with-annotations", + "wrapping", + ) } tasks.withType().configureEach { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 16f7eec6f2..2a9abd0689 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,14 +5,14 @@ androidx-test = "1.4.0" compose = "1.2.1" composeCompiler = "1.3.0" coroutines = "1.6.4" -ktlint = "0.44.0" +ktlint = "0.46.1" okhttp = "4.10.0" okio = "3.2.0" [plugins] binaryCompatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.11.0" } dokka = { id = "org.jetbrains.dokka", version = "1.6.10" } -ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "10.3.0" } +ktlint = { id = "org.jmailen.kotlinter", version = "3.11.1" } [libraries] gradlePlugin-android = "com.android.tools.build:gradle:7.2.2" diff --git a/test.sh b/test.sh index 37ddc44bf1..50e46e1dad 100755 --- a/test.sh +++ b/test.sh @@ -1,2 +1,2 @@ #!/bin/bash -./gradlew apiCheck ktlintCheck testDebugUnitTest connectedDebugAndroidTest +./gradlew apiCheck lintKotlin testDebugUnitTest connectedDebugAndroidTest