[#733] Configure Detekt convention plugin

This commit is contained in:
Carter Jernigan 2023-01-22 15:37:52 -05:00 committed by Carter Jernigan
parent 049acec253
commit f6859c5d14
8 changed files with 76 additions and 32 deletions

View File

@ -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")}")
}

View File

@ -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

View File

@ -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

View File

@ -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/**")
}
}

View File

@ -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<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
gradleReleaseChannel = "current"

View File

@ -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

View File

@ -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)

33
tools/detekt-baseline.xml Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues>
<ID>CyclomaticComplexMethod:ScreenshotTest.kt$ScreenshotTest$private fun take_screenshots_for_new_wallet_and_rest_of_app(resContext: Context, tag: String)</ID>
<ID>CyclomaticComplexMethod:ScreenshotTest.kt$private fun backupScreenshots(resContext: Context, tag: String, composeTestRule: AndroidComposeTestRule&lt;ActivityScenarioRule&lt;MainActivity&gt;, MainActivity&gt;)</ID>
<ID>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()</ID>
<ID>FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @LargeTest fun take_screenshots_for_new_wallet_and_rest_of_app_light_ar_XB()</ID>
<ID>FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @LargeTest fun take_screenshots_for_new_wallet_and_rest_of_app_light_en_US()</ID>
<ID>FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @LargeTest fun take_screenshots_for_new_wallet_and_rest_of_app_light_en_XA()</ID>
<ID>FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @MediumTest @SdkSuppress(minSdkVersion = Build.VERSION_CODES.Q) fun take_screenshots_for_restore_wallet_dark_en_US()</ID>
<ID>FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @MediumTest fun take_screenshots_for_restore_wallet_light_ar_XB()</ID>
<ID>FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @MediumTest fun take_screenshots_for_restore_wallet_light_en_US()</ID>
<ID>FunctionNaming:ScreenshotTest.kt$ScreenshotTest$@Test @MediumTest fun take_screenshots_for_restore_wallet_light_en_XA()</ID>
<ID>FunctionNaming:ScreenshotTest.kt$ScreenshotTest$private fun take_screenshots_for_new_wallet_and_rest_of_app(resContext: Context, tag: String)</ID>
<ID>FunctionNaming:ScreenshotTest.kt$ScreenshotTest$private fun take_screenshots_for_restore_wallet(resContext: Context, tag: String)</ID>
<ID>LongMethod:ScreenshotTest.kt$ScreenshotTest$private fun take_screenshots_for_new_wallet_and_rest_of_app(resContext: Context, tag: String)</ID>
<ID>LongMethod:ScreenshotTest.kt$private fun backupScreenshots(resContext: Context, tag: String, composeTestRule: AndroidComposeTestRule&lt;ActivityScenarioRule&lt;MainActivity&gt;, MainActivity&gt;)</ID>
<ID>MagicNumber:ScreenshotTest.kt$3</ID>
<ID>MagicNumber:ScreenshotTest.kt$4</ID>
<ID>MayBeConst:EncryptedPreferenceProviderTest.kt$EncryptedPreferenceProviderTest.Companion$private val FILENAME = "encrypted_preference_test"</ID>
<ID>MayBeConst:StandardPreferenceProviderTest.kt$StandardPreferenceProviderTest.Companion$private val FILENAME = "encrypted_preference_test"</ID>
<ID>MayBeConst:SupportViewTest.kt$SupportViewTest.Companion$internal val DEFAULT_MESSAGE = "I can haz cheezburger?"</ID>
<ID>SwallowedException:AndroidUncaughtExceptionHandlerTest.kt$AndroidUncaughtExceptionHandlerTest$e: IllegalStateException</ID>
<ID>TooManyFunctions:ScreenshotTest.kt$ScreenshotTest : UiTestPrerequisites</ID>
<ID>UnusedPrivateMember:FlowExtTest.kt$FlowExtTest$i</ID>
<ID>UseRequire:CheckUpdateViewModel.kt$CheckUpdateViewModel.CheckUpdateViewModelFactory$throw IllegalArgumentException("ViewModel Not Found.")</ID>
<ID>UseRequire:ExceptionPath.kt$ExceptionPath$throw IllegalArgumentException("Directories couldn't be created")</ID>
<ID>UseRequire:ExceptionPath.kt$ExceptionPath$throw IllegalArgumentException("Path is a file when a directory was expected")</ID>
<ID>UseRequire:ExceptionPath.kt$ExceptionPath$throw IllegalArgumentException("Path is not writeable")</ID>
<ID>UseRequire:UpdateViewModel.kt$UpdateViewModel.UpdateViewModelFactory$throw IllegalArgumentException("ViewModel Not Found.")</ID>
</CurrentIssues>
</SmellBaseline>