Skip to content

Commit 403a670

Browse files
committed
chore: 프로젝트 ktlint detekt 설정
1 parent a655680 commit 403a670

File tree

4 files changed

+130
-1
lines changed

4 files changed

+130
-1
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 4
6+
indent_style = space
7+
max_line_length = 150
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.{kt,kts}]
12+
ij_kotlin_allow_trailing_comma = true
13+
ij_kotlin_allow_trailing_comma_on_call_site = true

build.gradle.kts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
1-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1+
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
2+
import org.jlleitschuh.gradle.ktlint.KtlintExtension
3+
24
plugins {
5+
alias(libs.plugins.kotlin.detekt)
6+
alias(libs.plugins.kotlin.ktlint)
37
alias(libs.plugins.android.application) apply false
48
alias(libs.plugins.kotlin.android) apply false
59
alias(libs.plugins.kotlin.compose) apply false
610
}
11+
12+
val excludeModules: String? by project
13+
14+
allprojects {
15+
if (excludeModules?.split(",")?.contains(project.name) != true) {
16+
apply {
17+
plugin(rootProject.libs.plugins.kotlin.detekt.get().pluginId)
18+
plugin(rootProject.libs.plugins.kotlin.ktlint.get().pluginId)
19+
}
20+
21+
afterEvaluate {
22+
extensions.configure<DetektExtension> {
23+
parallel = true
24+
buildUponDefaultConfig = true
25+
toolVersion = libs.versions.kotlin.detekt.get()
26+
config.setFrom(files("$rootDir/detekt-config.yml"))
27+
}
28+
29+
extensions.configure<KtlintExtension> {
30+
version.set(rootProject.libs.versions.kotlin.ktlint.source.get())
31+
android.set(true)
32+
verbose.set(true)
33+
}
34+
}
35+
}
36+
}

detekt-config.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
complexity:
2+
LongMethod:
3+
threshold: 100
4+
ignoreAnnotated: [ 'Composable' ]
5+
CyclomaticComplexMethod:
6+
threshold: 40
7+
ignoreAnnotated: [ 'Composable' ]
8+
LongParameterList:
9+
active: false
10+
TooManyFunctions:
11+
active: false
12+
ComplexCondition:
13+
threshold: 7
14+
15+
performance:
16+
SpreadOperator:
17+
active: false
18+
19+
formatting:
20+
TrailingCommaOnCallSite:
21+
active: true
22+
TrailingCommaOnDeclarationSite:
23+
active: true
24+
ImportOrdering:
25+
active: false
26+
MaximumLineLength:
27+
active: false
28+
MultiLineIfElse:
29+
active: false
30+
Indentation:
31+
indentSize: 4
32+
ParameterListWrapping:
33+
active: false
34+
ArgumentListWrapping:
35+
indentSize: 4
36+
maxLineLength: 150
37+
KdocWrapping:
38+
active: true
39+
indentSize: 4
40+
Wrapping:
41+
indentSize: 4
42+
active: false
43+
CommentWrapping:
44+
active: false
45+
Filename:
46+
active: false
47+
PackageName:
48+
active: false
49+
AnnotationOnSeparateLine:
50+
active: false
51+
52+
style:
53+
MagicNumber:
54+
active: false
55+
ignoreAnnotated: [ 'AllowMagicNumber' ]
56+
ForbiddenComment:
57+
active: false
58+
UnusedPrivateMember:
59+
ignoreAnnotated: [ 'Preview', 'ComponentPreview', 'DevicePreview' ]
60+
ThrowsCount:
61+
active: false
62+
ReturnCount:
63+
active: false
64+
LoopWithTooManyJumpStatements:
65+
active: false
66+
DestructuringDeclarationWithTooManyEntries:
67+
active: false
68+
MaxLineLength:
69+
active: false
70+
71+
naming:
72+
TopLevelPropertyNaming:
73+
constantPattern: '[A-Z][A-Za-z0-9_]*'
74+
FunctionNaming:
75+
ignoreAnnotated: [ 'Composable' ]
76+
MatchingDeclarationName:
77+
active: false
78+
VariableNaming:
79+
active: false
80+
PackageNaming:
81+
packagePattern: '[a-z]+(\._?[_?A-Za-z0-9]*)*'

gradle/libs.versions.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ espressoCore = "3.6.1"
88
lifecycleRuntimeKtx = "2.8.7"
99
activityCompose = "1.10.1"
1010
composeBom = "2024.09.00"
11+
kotlin-detekt = "1.23.8"
12+
kotlin-ktlint-gradle = "11.6.1"
13+
kotlin-ktlint-source = "0.50.0"
1114

1215
[libraries]
1316
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -29,4 +32,6 @@ androidx-material3 = { group = "androidx.compose.material3", name = "material3"
2932
android-application = { id = "com.android.application", version.ref = "agp" }
3033
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
3134
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
35+
kotlin-detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "kotlin-detekt" }
36+
kotlin-ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "kotlin-ktlint-gradle" }
3237

0 commit comments

Comments
 (0)