Skip to content

Commit 9566d47

Browse files
authored
Merge pull request #30 from auth0/task/detekt-setup
Setup detekt lint for UI-components Android
2 parents 8b40465 + 2d8fa5b commit 9566d47

3 files changed

Lines changed: 136 additions & 0 deletions

File tree

build.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import io.gitlab.arturbosch.detekt.Detekt
2+
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
3+
14
// Top-level build file where you can add configuration options common to all sub-projects/modules.
25
plugins {
36
alias(libs.plugins.android.application) apply false
@@ -6,13 +9,42 @@ plugins {
69
alias(libs.plugins.android.library) apply false
710
alias(libs.plugins.kotlin.parcelize) apply false
811
alias(libs.plugins.dokka)
12+
alias(libs.plugins.detekt) apply false
913
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
1014
}
1115

1216
subprojects {
1317
apply plugin: 'org.jetbrains.dokka'
1418
}
1519

20+
configure(project(':universal_components')) {
21+
apply plugin: 'io.gitlab.arturbosch.detekt'
22+
23+
detekt {
24+
buildUponDefaultConfig = true
25+
parallel = true
26+
source.setFrom(files('src/main/java', 'src/main/kotlin', 'src/test/java', 'src/test/kotlin'))
27+
}
28+
29+
tasks.withType(Detekt).configureEach {
30+
jvmTarget = '17'
31+
reports {
32+
html.required.set(true)
33+
xml.required.set(true)
34+
sarif.required.set(true)
35+
txt.required.set(false)
36+
}
37+
}
38+
39+
tasks.withType(DetektCreateBaselineTask).configureEach {
40+
jvmTarget = '17'
41+
}
42+
43+
dependencies {
44+
detektPlugins libs.detekt.formatting
45+
}
46+
}
47+
1648
nexusPublishing {
1749
repositories {
1850
sonatype{

config/detekt/detekt.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
build:
2+
maxIssues: 0
3+
excludeCorrectable: false
4+
5+
config:
6+
validation: true
7+
warningsAsErrors: false
8+
checkExhaustiveness: false
9+
10+
processors:
11+
active: true
12+
13+
console-reports:
14+
active: true
15+
16+
# ktlint-based rules (detekt-formatting plugin)
17+
formatting:
18+
active: true
19+
android: true
20+
autoCorrect: true
21+
Indentation:
22+
active: true
23+
indentSize: 4
24+
MaximumLineLength:
25+
active: true
26+
maxLineLength: 200
27+
FunctionName:
28+
active: false # Composable functions use PascalCase
29+
ImportOrdering:
30+
active: true
31+
NoWildcardImports:
32+
active: true
33+
34+
complexity:
35+
active: true
36+
LargeClass:
37+
active: true
38+
excludes: [ '**/test/**', '**/androidTest/**' ]
39+
LongMethod:
40+
active: true
41+
threshold: 100
42+
ignoreAnnotated: [ 'Composable' ]
43+
LongParameterList:
44+
active: true
45+
functionThreshold: 10
46+
constructorThreshold: 10
47+
ignoreDefaultParameters: true
48+
ignoreAnnotatedParameter: [ 'Composable' ]
49+
TooManyFunctions:
50+
active: true
51+
thresholdInClasses: 30
52+
thresholdInFiles: 30
53+
thresholdInObjects: 30
54+
thresholdInInterfaces: 30
55+
CyclomaticComplexMethod:
56+
active: true
57+
threshold: 30
58+
59+
naming:
60+
active: true
61+
FunctionNaming:
62+
active: true
63+
functionPattern: '[a-zA-Z][a-zA-Z0-9]*'
64+
ignoreAnnotated: [ 'Composable' ]
65+
TopLevelPropertyNaming:
66+
active: true
67+
constantPattern: '[A-Z][_A-Z0-9]*'
68+
69+
style:
70+
active: true
71+
MaxLineLength:
72+
active: true
73+
maxLineLength: 140
74+
excludes: [ '**/test/**', '**/androidTest/**' ]
75+
MagicNumber:
76+
active: true
77+
excludes: [ '**/theme/Auth0Sizes.kt',
78+
'**/theme/Auth0Dimensions.kt',
79+
'**/theme/Auth0Color.kt',
80+
'**/theme/Auth0Shapes.kt',
81+
'**/test/**',
82+
'**/androidTest/**' ]
83+
ignoreNumbers: [ '-1', '0', '1', '2' ]
84+
ignoreAnnotated: [ 'Composable', 'Preview' ]
85+
ignorePropertyDeclaration: true
86+
ignoreCompanionObjectPropertyDeclaration: true
87+
ReturnCount:
88+
active: true
89+
max: 8
90+
UnusedPrivateMember:
91+
active: true
92+
ignoreAnnotated: [ 'Preview' ]
93+
94+
comments:
95+
active: true
96+
UndocumentedPublicClass:
97+
active: false
98+
UndocumentedPublicFunction:
99+
active: false
100+
UndocumentedPublicProperty:
101+
active: false

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ truth = "1.1.5"
1818
junit4 = "4.13.2"
1919
credentials = "1.5.0"
2020
dokka = "2.0.0"
21+
detekt = "1.23.8"
2122

2223
[libraries]
2324
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -46,6 +47,7 @@ truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }
4647
junit4 = { group = "junit", name = "junit", version.ref = "junit4" }
4748
androidx-credentials = { module = "androidx.credentials:credentials", version.ref = "credentials" }
4849
androidx-credentials-play-services-auth = { module = "androidx.credentials:credentials-play-services-auth", version.ref = "credentials" }
50+
detekt-formatting = { group = "io.gitlab.arturbosch.detekt", name = "detekt-formatting", version.ref = "detekt" }
4951

5052
[plugins]
5153
android-application = { id = "com.android.application", version.ref = "agp" }
@@ -55,4 +57,5 @@ android-library = { id = "com.android.library", version.ref = "agp" }
5557
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
5658
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
5759
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
60+
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
5861

0 commit comments

Comments
 (0)