From 429fa8f74a28bf5549ec4170b10e9013a9ada3be Mon Sep 17 00:00:00 2001 From: Ryan Conway Date: Fri, 3 Nov 2023 14:39:22 +0700 Subject: [PATCH] [#541] Update detekt rules for Jetpack Compose --- template-compose/app/build.gradle.kts | 4 ++ template-compose/build.gradle.kts | 4 ++ .../buildSrc/src/main/java/Dependencies.kt | 2 + .../buildSrc/src/main/java/Versions.kt | 1 + template-compose/detekt-config.yml | 46 +++++++++++++++++++ 5 files changed, 57 insertions(+) diff --git a/template-compose/app/build.gradle.kts b/template-compose/app/build.gradle.kts index ed899e49b..abaf64ab5 100644 --- a/template-compose/app/build.gradle.kts +++ b/template-compose/app/build.gradle.kts @@ -156,6 +156,10 @@ dependencies { kapt(COMPILER) } + with(Dependencies.Kotlin) { + implementation(COLLECTIONS_IMMUTABLE) + } + with(Dependencies.Log) { implementation(TIMBER) diff --git a/template-compose/build.gradle.kts b/template-compose/build.gradle.kts index 9319cd7ef..34a00a78f 100644 --- a/template-compose/build.gradle.kts +++ b/template-compose/build.gradle.kts @@ -9,6 +9,10 @@ plugins { id(Plugins.KOVER) version Versions.KOVER } +dependencies { + detektPlugins("io.nlopez.compose.rules:detekt:0.3.3") +} + tasks.register("clean", Delete::class) { delete(rootProject.buildDir) } diff --git a/template-compose/buildSrc/src/main/java/Dependencies.kt b/template-compose/buildSrc/src/main/java/Dependencies.kt index 1bbba810a..aeee4a74d 100644 --- a/template-compose/buildSrc/src/main/java/Dependencies.kt +++ b/template-compose/buildSrc/src/main/java/Dependencies.kt @@ -29,6 +29,8 @@ object Dependencies { object Kotlin { const val COROUTINES_CORE = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.KOTLIN_COROUTINES}" + const val COLLECTIONS_IMMUTABLE = + "org.jetbrains.kotlinx:kotlinx-collections-immutable:${Versions.KOTLIN_COLLECTIONS_IMMUTABLE}" } object Log { diff --git a/template-compose/buildSrc/src/main/java/Versions.kt b/template-compose/buildSrc/src/main/java/Versions.kt index 04e5458ab..6e86f0643 100644 --- a/template-compose/buildSrc/src/main/java/Versions.kt +++ b/template-compose/buildSrc/src/main/java/Versions.kt @@ -29,6 +29,7 @@ object Versions { const val KOTEST = "5.6.2" const val KOTLIN = "1.9.10" + const val KOTLIN_COLLECTIONS_IMMUTABLE = "0.3.6" const val KOTLIN_COROUTINES = "1.7.1" const val KOVER = "0.7.3" diff --git a/template-compose/detekt-config.yml b/template-compose/detekt-config.yml index a15e6a621..4b2ad59f1 100644 --- a/template-compose/detekt-config.yml +++ b/template-compose/detekt-config.yml @@ -286,6 +286,7 @@ style: MagicNumber: active: true ignoreNumbers: [ '-1', '0', '1', '2' ] + ignoreAnnotated: [ 'Preview' ] ignoreHashCodeFunction: false ignorePropertyDeclaration: true ignoreConstantDeclaration: true @@ -347,3 +348,48 @@ style: active: false WildcardImport: active: false + +Compose: + CompositionLocalAllowlist: + active: true + allowedCompositionLocals: LocalAppColors,LocalAppDimensions,LocalAppShapes,LocalAppStyles,LocalAppTypography + ContentEmitterReturningValues: + active: true + DefaultsVisibility: + active: true + ModifierClickableOrder: + active: true + ModifierComposable: + active: true + ModifierMissing: + active: true + ModifierNaming: + active: true + ModifierNotUsedAtRoot: + active: true + ModifierReused: + active: true + ModifierWithoutDefault: + active: true + MultipleEmitters: + active: true + MutableParams: + active: true + ComposableNaming: + active: true + ComposableParamOrder: + active: true + PreviewAnnotationNaming: + active: true + PreviewPublic: + active: true + RememberMissing: + active: true + RememberContentMissing: + active: true + UnstableCollections: + active: true + ViewModelForwarding: + active: true + ViewModelInjection: + active: true