Skip to content

Commit

Permalink
ANDROID-11179 detekt implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jmanriquehiberus committed Sep 18, 2024
1 parent 16231f8 commit 23291e2
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build-tools/detekt.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

detekt {
buildUponDefaultConfig = true
config = files("$projectDir/build-tools/detekt/detekt.yml")
input = files("$projectDir")
}
36 changes: 36 additions & 0 deletions build-tools/detekt/detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
complexity:
TooManyFunctions:
active: false
LongParameterList:
active: false

style:
NewLineAtEndOfFile:
active: false
MagicNumber:
active: false
ReturnCount:
active: false
UnusedImports:
active: true
MaxLineLength:
maxLineLength: 160
UnusedPrivateMember:
ignoreAnnotated: 'Preview'
UnnecessaryAbstractClass:
ignoreAnnotated: "Module"

naming:
FunctionNaming:
active: true
ignoreAnnotated: 'Composable'

empty-blocks:
EmptyFunctionBlock:
active: false

exceptions:
TooGenericExceptionThrown:
active: false
TooGenericExceptionCaught:
active: false
42 changes: 42 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildscript {
accompanist_version = "0.32.0"
coil_version = '2.5.0'
constraintComposeVersion = '1.0.1'
detekt_version = '1.22.0'
roborazzi_version = "1.10.1"
}
repositories {
Expand All @@ -30,6 +31,7 @@ plugins {
id 'org.jetbrains.kotlin.android' version '1.5.21' apply false
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' apply false
id "io.github.takahirom.roborazzi" version '1.10.1' apply false
id 'io.gitlab.arturbosch.detekt' version '1.22.0'
}

allprojects {
Expand All @@ -41,10 +43,50 @@ allprojects {
version = System.getProperty("LIBRARY_VERSION") ?: "undefined"
}

tasks.withType(io.gitlab.arturbosch.detekt.Detekt).all {
exclude("build/")
exclude("**/build/**")
exclude("**/resources/**")
exclude("**/tmp/**")
}

tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach {
reports {
html {
outputLocation.set(file("$buildDir/reports/detekt/detekt-report.html"))
required.set(true)
}
xml {
outputLocation.set(file("$buildDir/reports/detekt/detekt-checkstyle.xml"))
required.set(true)
}
}
}

task detektProjectBaseline(type: io.gitlab.arturbosch.detekt.DetektCreateBaselineTask) {
description = "Overrides current baseline."
ignoreFailures.set(true)
parallel.set(true)
buildUponDefaultConfig.set(true)
setSource(files("$projectDir"))
config.setFrom(files("$projectDir/build-tools/detekt/detekt.yml"))
baseline.set(file("$projectDir/detekt-baseline.xml"))
include("**/*.kt")
include("**/*.kts")
exclude("**/resources/**")
exclude("**/build/**")
exclude("**/tmp/**")
}

repositories {
google()
mavenCentral()
}
}

apply from: "${rootProject.projectDir}/publish_maven_central.gradle"
apply from: "build-tools/detekt.gradle"

tasks.withType(io.gitlab.arturbosch.detekt.Detekt) {
autoCorrect = true
}
8 changes: 8 additions & 0 deletions detekt-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues>
<ID>WildcardImport:protect_android_task.gradle.kts$import java.io.*</ID>
<ID>WildcardImport:protect_android_task.gradle.kts$import java.lang.*</ID>
</CurrentIssues>
</SmellBaseline>
2 changes: 2 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ dependencies {

implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"

implementation "io.gitlab.arturbosch.detekt:$detekt_version"

testImplementation 'junit:junit:4.13.2'
testImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
testImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
Expand Down

0 comments on commit 23291e2

Please sign in to comment.