Skip to content

Commit cde34fc

Browse files
committed
chore: update detekt rules
More compose-friendly
1 parent e661fdc commit cde34fc

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

app/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ android {
128128

129129
detekt {
130130
baseline = file("detekt-baseline.xml")
131+
config.setFrom("$rootDir/detekt.yml")
132+
buildUponDefaultConfig = true
133+
allRules = false
131134
}
132135

133136
dependencies {
@@ -139,4 +142,5 @@ dependencies {
139142
implementation(libs.gestureviews)
140143
implementation(libs.autofittextview)
141144
implementation(libs.zip4j)
145+
detektPlugins(libs.compose.detekt)
142146
}

detekt.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
build:
2+
maxIssues: 0
3+
weights:
4+
complexity: 2
5+
LongParameterList: 2
6+
style: 1
7+
8+
processors:
9+
active: true
10+
exclude:
11+
- "FunctionCountProcessor"
12+
- "PropertyCountProcessor"
13+
14+
config:
15+
validation: true
16+
17+
complexity:
18+
LongParameterList:
19+
active: true
20+
functionThreshold: 10
21+
constructorThreshold: 8
22+
ignoreDefaultParameters: true
23+
ignoreAnnotated:
24+
- "Composable"
25+
LongMethod:
26+
active: true
27+
threshold: 120
28+
ignoreAnnotated:
29+
- "Composable"
30+
- "Preview"
31+
32+
style:
33+
MagicNumber:
34+
active: true
35+
ignoreAnnotated: ["Composable"]
36+
ignoreEnums: true
37+
ignoreNumbers: ["-1", "0", "1", "2", "42", "1000"]
38+
MaxLineLength:
39+
active: true
40+
maxLineLength: 120
41+
excludePackageStatements: true
42+
excludeImportStatements: true
43+
44+
naming:
45+
FunctionNaming:
46+
active: true
47+
ignoreAnnotated: ["Composable", "Preview"]
48+
functionPattern: "[a-z][A-Za-z0-9]*"
49+
50+
Compose: # io.nlopez.compose.rules
51+
ComposableParametersOrdering:
52+
active: true
53+
ModifierDefaultValue:
54+
active: true
55+
MissingModifierDefaultValue:
56+
active: true
57+
PublicComposablePreview:
58+
active: true

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
kotlin = "2.2.0"
44
#Detekt
55
detekt = "1.23.8"
6+
detektCompose = "0.4.22"
67
#AndroidX
78
androidx-swiperefreshlayout = "1.1.0"
89
androidx-documentfile = "1.1.0"
@@ -26,6 +27,8 @@ app-build-kotlinJVMTarget = "17"
2627
#AndroidX
2728
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "androidx-swiperefreshlayout" }
2829
androidx-documentfile = { module = "androidx.documentfile:documentfile", version.ref = "androidx-documentfile" }
30+
#Compose
31+
compose-detekt = { module = "io.nlopez.compose.rules:detekt", version.ref = "detektCompose" }
2932
#Fossify
3033
fossify-commons = { module = "org.fossify:commons", version.ref = "commons" }
3134
#Other

0 commit comments

Comments
 (0)