From 0f684a3728ba49ad254bde8307f8a06af3433885 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sun, 2 Oct 2022 16:02:51 +0530 Subject: [PATCH] feat(detekt): add Twitter's Compose rules --- .github/renovate.json | 10 ++++++ .../kotlin/dev/msfjarvis/aps/gradle/Detekt.kt | 6 ++++ config/detekt/detekt.yml | 35 +++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/.github/renovate.json b/.github/renovate.json index cc6b7ce7..17022cb6 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -26,6 +26,16 @@ ], "datasourceTemplate": "maven", "depNameTemplate": "com.facebook:ktfmt" + }, + { + "fileMatch": [ + ".kt$" + ], + "matchStrings": [ + "TWITTER_RULES_VERSION = \"(?.*)\"" + ], + "datasourceTemplate": "maven", + "depNameTemplate": "com.twitter.compose.rules:detekt" } ] } diff --git a/build-logic/kotlin-plugins/src/main/kotlin/dev/msfjarvis/aps/gradle/Detekt.kt b/build-logic/kotlin-plugins/src/main/kotlin/dev/msfjarvis/aps/gradle/Detekt.kt index b9ea1e60..4f749fdf 100644 --- a/build-logic/kotlin-plugins/src/main/kotlin/dev/msfjarvis/aps/gradle/Detekt.kt +++ b/build-logic/kotlin-plugins/src/main/kotlin/dev/msfjarvis/aps/gradle/Detekt.kt @@ -7,6 +7,8 @@ import org.gradle.kotlin.dsl.configure import org.gradle.language.base.plugins.LifecycleBasePlugin object Detekt { + private const val TWITTER_RULES_VERSION = "0.0.17" + fun apply(project: Project) { project.pluginManager.apply(DetektPlugin::class.java) project.extensions.configure { @@ -24,5 +26,9 @@ object Detekt { dependsOn(project.tasks.named("detekt")) } } + project.dependencies.add( + "detektPlugins", + "com.twitter.compose.rules:detekt:$TWITTER_RULES_VERSION", + ) } } diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml index 50cb8986..41bc1fc0 100644 --- a/config/detekt/detekt.yml +++ b/config/detekt/detekt.yml @@ -712,3 +712,38 @@ style: excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] excludeImports: - 'java.util.*' + +TwitterCompose: + CompositionLocalAllowlist: + active: true + # allowedCompositionLocals: LocalSomething,LocalSomethingElse + CompositionLocalNaming: + active: true + ContentEmitterReturningValues: + active: true + # contentEmitters: MyComposable,MyOtherComposable + ModifierComposable: + active: true + ModifierMissing: + active: true + ModifierReused: + active: true + ModifierWithoutDefault: + active: true + MultipleEmitters: + active: true + # contentEmitters: MyComposable,MyOtherComposable + MutableParams: + active: true + ComposableNaming: + active: true + ComposableParamOrder: + active: true + PreviewPublic: + active: true + RememberMissing: + active: true + ViewModelForwarding: + active: true + ViewModelInjection: + active: true