From f6859c5d147d97fffde1565bc610b6fb435ee7d9 Mon Sep 17 00:00:00 2001 From: Carter Jernigan Date: Sun, 22 Jan 2023 15:37:52 -0500 Subject: [PATCH] [#733] Configure Detekt convention plugin --- build-conventions-secant/build.gradle.kts | 3 +- build-conventions-secant/gradle.lockfile | 6 ++++ .../src/main/kotlin/.editorconfig | 11 ------ .../secant.detekt-conventions.gradle.kts | 34 +++++++++++++++++++ build.gradle.kts | 19 +---------- buildscript-gradle.lockfile | 1 - settings.gradle.kts | 1 - tools/detekt-baseline.xml | 33 ++++++++++++++++++ 8 files changed, 76 insertions(+), 32 deletions(-) delete mode 100644 build-conventions-secant/src/main/kotlin/.editorconfig create mode 100644 build-conventions-secant/src/main/kotlin/secant.detekt-conventions.gradle.kts create mode 100644 tools/detekt-baseline.xml diff --git a/build-conventions-secant/build.gradle.kts b/build-conventions-secant/build.gradle.kts index e14e122a..a2505c6c 100644 --- a/build-conventions-secant/build.gradle.kts +++ b/build-conventions-secant/build.gradle.kts @@ -45,8 +45,9 @@ java { dependencies { val rootProperties = getRootProperties() - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProperties.getProperty("KOTLIN_VERSION")}") implementation("com.android.tools.build:gradle:${rootProperties.getProperty("ANDROID_GRADLE_PLUGIN_VERSION")}") + implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${rootProperties.getProperty("DETEKT_VERSION")}") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProperties.getProperty("KOTLIN_VERSION")}") implementation("wtf.emulator:gradle-plugin:${rootProperties.getProperty("EMULATOR_WTF_GRADLE_PLUGIN_VERSION")}") } diff --git a/build-conventions-secant/gradle.lockfile b/build-conventions-secant/gradle.lockfile index 3a5317c3..a2626f36 100644 --- a/build-conventions-secant/gradle.lockfile +++ b/build-conventions-secant/gradle.lockfile @@ -68,6 +68,8 @@ com.vdurmont:semver4j:3.1.0=runtimeClasspath commons-codec:commons-codec:1.11=runtimeClasspath commons-io:commons-io:2.4=runtimeClasspath commons-logging:commons-logging:1.2=runtimeClasspath +io.github.detekt.sarif4k:sarif4k:0.0.1=runtimeClasspath +io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.21.0=compileClasspath,runtimeClasspath io.grpc:grpc-api:1.39.0=runtimeClasspath io.grpc:grpc-context:1.39.0=runtimeClasspath io.grpc:grpc-core:1.39.0=runtimeClasspath @@ -149,6 +151,10 @@ org.jetbrains.kotlin:kotlin-util-io:1.7.10=kotlinCompilerPluginClasspathMain org.jetbrains.kotlin:kotlin-util-io:1.8.0=compileClasspath,runtimeClasspath org.jetbrains.kotlin:kotlin-util-klib:1.8.0=runtimeClasspath org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=runtimeClasspath +org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.1.0=runtimeClasspath +org.jetbrains.kotlinx:kotlinx-serialization-core:1.1.0=runtimeClasspath +org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.1.0=runtimeClasspath +org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0=runtimeClasspath org.jetbrains:annotations:13.0=compileClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,runtimeClasspath org.json:json:20180813=runtimeClasspath org.jvnet.staxex:stax-ex:1.8.1=runtimeClasspath diff --git a/build-conventions-secant/src/main/kotlin/.editorconfig b/build-conventions-secant/src/main/kotlin/.editorconfig deleted file mode 100644 index dba3e41b..00000000 --- a/build-conventions-secant/src/main/kotlin/.editorconfig +++ /dev/null @@ -1,11 +0,0 @@ -disabled_rules=import-ordering,no-wildcard-imports - -# Defines the imports layout. The layout can be composed by the following symbols: -# "*" - wildcard. There must be at least one entry of a single wildcard to match all other imports. Matches anything after a specified symbol/import as well. -# "|" - blank line. Supports only single blank lines between imports. No blank line is allowed in the beginning or end of the layout. -# "^" - alias import, e.g. "^android.*" will match all android alias imports, "^" will match all other alias imports. -# import paths - these can be full paths, e.g. "java.util.List.*" as well as wildcard paths, e.g. "kotlin.**" -# Examples (we use ij_kotlin_imports_layout to set an imports layout for both ktlint and IDEA via a single property): -ij_kotlin_imports_layout=* # alphabetical with capital letters before lower case letters (e.g. Z before a), no blank lines -ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^ # default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list -ij_kotlin_imports_layout=android.**,|,^org.junit.**,kotlin.io.Closeable.*,|,*,^ # custom imports layout \ No newline at end of file diff --git a/build-conventions-secant/src/main/kotlin/secant.detekt-conventions.gradle.kts b/build-conventions-secant/src/main/kotlin/secant.detekt-conventions.gradle.kts new file mode 100644 index 00000000..54a06488 --- /dev/null +++ b/build-conventions-secant/src/main/kotlin/secant.detekt-conventions.gradle.kts @@ -0,0 +1,34 @@ +import io.gitlab.arturbosch.detekt.Detekt +import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask + +plugins { + id("io.gitlab.arturbosch.detekt") +} + +tasks { + register("detektAll", Detekt::class) { + parallel = true + setSource(files(projectDir)) + include("**/*.kt") + include("**/*.kts") + exclude("**/resources/**") + exclude("**/build/**") + config.setFrom(files("${rootProject.projectDir}/tools/detekt.yml")) + baseline.set(File("${rootProject.projectDir}/tools/detekt-baseline.xml")) + buildUponDefaultConfig = true + } + + register("detektGenerateBaseline", DetektCreateBaselineTask::class) { + description = "Overrides current baseline." + buildUponDefaultConfig.set(true) + ignoreFailures.set(true) + parallel.set(true) + setSource(files(rootDir)) + config.setFrom(files("${rootProject.projectDir}/tools/detekt.yml")) + baseline.set(file("$rootDir/tools/detekt-baseline.xml")) + include("**/*.kt") + include("**/*.kts") + exclude("**/resources/**") + exclude("**/build/**") + } +} diff --git a/build.gradle.kts b/build.gradle.kts index 0053155b..f7a1072f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,8 +20,8 @@ buildscript { plugins { id("com.github.ben-manes.versions") id("com.osacky.fulladle") - id("io.gitlab.arturbosch.detekt") id("org.jetbrains.kotlinx.kover") + id("secant.detekt-conventions") id("secant.ktlint-conventions") id("secant.rosetta-conventions") } @@ -30,23 +30,6 @@ val uiIntegrationModuleName: String = projects.uiIntegrationTest.name val uiScreenshotModuleName: String = projects.uiScreenshotTest.name tasks { - register("detektAll", io.gitlab.arturbosch.detekt.Detekt::class) { - parallel = true - setSource(files(projectDir)) - include("**/*.kt") - include("**/*.kts") - exclude("**/resources/**") - exclude("**/build/**") - exclude("**/commonTest/**") - exclude("**/jvmTest/**") - exclude("**/androidTest/**") - // To exclude the whole pure test modules - exclude(uiIntegrationModuleName, uiScreenshotModuleName) - // To regenerate the config, run the task `detektGenerateConfig` - config.setFrom(files("${rootProject.projectDir}/tools/detekt.yml")) - buildUponDefaultConfig = true - } - withType { gradleReleaseChannel = "current" diff --git a/buildscript-gradle.lockfile b/buildscript-gradle.lockfile index 65bcd4e6..6c1d31f7 100644 --- a/buildscript-gradle.lockfile +++ b/buildscript-gradle.lockfile @@ -79,7 +79,6 @@ io.github.x-stream:mxparser:1.2.1=classpath io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.21.0=classpath io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin:1.19.0=classpathCopy io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin:1.20.0=classpathCopy2 -io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin:1.21.0=classpath io.grpc:grpc-api:1.39.0=classpath io.grpc:grpc-context:1.39.0=classpath io.grpc:grpc-core:1.39.0=classpath diff --git a/settings.gradle.kts b/settings.gradle.kts index 3a87618d..118a76c8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -61,7 +61,6 @@ pluginManagement { id("com.github.ben-manes.versions") version (extra["GRADLE_VERSIONS_PLUGIN_VERSION"].toString()) apply (false) id("com.github.triplet.play") version (extra["PLAY_PUBLISHER_PLUGIN_VERSION"].toString()) apply (false) id("com.osacky.fulladle") version (extra["FULLADLE_VERSION"].toString()) apply (false) - id("io.gitlab.arturbosch.detekt") version (extra["DETEKT_VERSION"].toString()) apply (false) id("org.jetbrains.kotlinx.kover") version (extra["KOVER_VERSION"].toString()) apply (false) id("wtf.emulator.gradle") version (extra["EMULATOR_WTF_GRADLE_PLUGIN_VERSION"].toString()) apply (false) kotlin("android") version (kotlinVersion) apply (false) diff --git a/tools/detekt-baseline.xml b/tools/detekt-baseline.xml new file mode 100644 index 00000000..9b49863a --- /dev/null +++ b/tools/detekt-baseline.xml @@ -0,0 +1,33 @@ + + + + + CyclomaticComplexMethod:ScreenshotTest.kt$ScreenshotTest$private fun take_screenshots_for_new_wallet_and_rest_of_app(resContext: Context, tag: String) + CyclomaticComplexMethod:ScreenshotTest.kt$private fun backupScreenshots(resContext: Context, tag: String, composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<MainActivity>, MainActivity>) + FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @LargeTest @SdkSuppress(minSdkVersion = Build.VERSION_CODES.Q) fun take_screenshots_for_new_wallet_and_rest_of_app_dark_en_US() + FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @LargeTest fun take_screenshots_for_new_wallet_and_rest_of_app_light_ar_XB() + FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @LargeTest fun take_screenshots_for_new_wallet_and_rest_of_app_light_en_US() + FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @LargeTest fun take_screenshots_for_new_wallet_and_rest_of_app_light_en_XA() + FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @MediumTest @SdkSuppress(minSdkVersion = Build.VERSION_CODES.Q) fun take_screenshots_for_restore_wallet_dark_en_US() + FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @MediumTest fun take_screenshots_for_restore_wallet_light_ar_XB() + FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @MediumTest fun take_screenshots_for_restore_wallet_light_en_US() + FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @MediumTest fun take_screenshots_for_restore_wallet_light_en_XA() + FunctionNaming:ScreenshotTest.kt$ScreenshotTest$private fun take_screenshots_for_new_wallet_and_rest_of_app(resContext: Context, tag: String) + FunctionNaming:ScreenshotTest.kt$ScreenshotTest$private fun take_screenshots_for_restore_wallet(resContext: Context, tag: String) + LongMethod:ScreenshotTest.kt$ScreenshotTest$private fun take_screenshots_for_new_wallet_and_rest_of_app(resContext: Context, tag: String) + LongMethod:ScreenshotTest.kt$private fun backupScreenshots(resContext: Context, tag: String, composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<MainActivity>, MainActivity>) + MagicNumber:ScreenshotTest.kt$3 + MagicNumber:ScreenshotTest.kt$4 + MayBeConst:EncryptedPreferenceProviderTest.kt$EncryptedPreferenceProviderTest.Companion$private val FILENAME = "encrypted_preference_test" + MayBeConst:StandardPreferenceProviderTest.kt$StandardPreferenceProviderTest.Companion$private val FILENAME = "encrypted_preference_test" + MayBeConst:SupportViewTest.kt$SupportViewTest.Companion$internal val DEFAULT_MESSAGE = "I can haz cheezburger?" + SwallowedException:AndroidUncaughtExceptionHandlerTest.kt$AndroidUncaughtExceptionHandlerTest$e: IllegalStateException + TooManyFunctions:ScreenshotTest.kt$ScreenshotTest : UiTestPrerequisites + UnusedPrivateMember:FlowExtTest.kt$FlowExtTest$i + UseRequire:CheckUpdateViewModel.kt$CheckUpdateViewModel.CheckUpdateViewModelFactory$throw IllegalArgumentException("ViewModel Not Found.") + UseRequire:ExceptionPath.kt$ExceptionPath$throw IllegalArgumentException("Directories couldn't be created") + UseRequire:ExceptionPath.kt$ExceptionPath$throw IllegalArgumentException("Path is a file when a directory was expected") + UseRequire:ExceptionPath.kt$ExceptionPath$throw IllegalArgumentException("Path is not writeable") + UseRequire:UpdateViewModel.kt$UpdateViewModel.UpdateViewModelFactory$throw IllegalArgumentException("ViewModel Not Found.") + +