Skip to content

Commit 9a10fea

Browse files
authored
Merge pull request #50 from Go-Socket-Project/feature/49_setup_detekt
🔀 :: (#49) setup detekt
2 parents ad1f709 + bdc6eda commit 9a10fea

File tree

43 files changed

+220
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+220
-59
lines changed

.github/workflows/android.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ jobs:
3939
- name: Run ktlint
4040
run: ./gradlew ktlintCheck
4141

42+
- name: Run detekt
43+
run: ./gradlew detekt
44+
4245
- name: Build with Gradle
4346
run: ./gradlew build
4447

build-logic/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ dependencies {
99
implementation(libs.hilt.gradlePlugin)
1010
implementation(libs.ksp.gradlePlugin)
1111
implementation(libs.compose.compiler.gradlePlugin)
12+
implementation(libs.detekt.gradlePlugin)
1213
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.chat.build_logic
2+
3+
import org.gradle.api.Project
4+
import org.gradle.kotlin.dsl.dependencies
5+
6+
internal fun Project.configureVerifyDetekt() {
7+
with(pluginManager) {
8+
apply("io.gitlab.arturbosch.detekt")
9+
}
10+
11+
dependencies {
12+
"detektPlugins"(libs.findLibrary("detekt.formatting").get())
13+
}
14+
}

build-logic/src/main/kotlin/convention.android.library.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import com.chat.build_logic.configureKotlinAndroid
33
plugins {
44
id("com.android.library")
55
kotlin("android")
6+
id("convention.verify.detekt")
67
}
78

89
android {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import com.chat.build_logic.configureVerifyDetekt
2+
import io.gitlab.arturbosch.detekt.Detekt
3+
4+
configureVerifyDetekt()
5+
6+
tasks.withType<Detekt>().configureEach {
7+
jvmTarget = "17"
8+
9+
buildUponDefaultConfig = true // 기본 설정에서 추가 설정만 덮어쓰기
10+
allRules = false // 모든 룰을 활성화 할지 설정
11+
parallel = true // 코드 분석 병렬 실행 설정
12+
config = files("$rootDir/config/detekt/detekt.yml")
13+
}

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ plugins {
99
alias(libs.plugins.android.test) apply false
1010
alias(libs.plugins.baselineprofile) apply false
1111
alias(libs.plugins.compose.compiler) apply false
12+
alias(libs.plugins.detekt) apply false
1213
}
1314

1415
allprojects {

config/detekt/detekt.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
build:
2+
maxIssues: 0
3+
4+
config:
5+
validation: true
6+
warningsAsErrors: true
7+
8+
complexity:
9+
active: true
10+
ComplexCondition: # 복잡한 조건 설정
11+
active: true
12+
threshold: 5
13+
ComplexInterface: # 많은 함수 및 속성을 포함하는 인터페이스
14+
active: true
15+
threshold: 10
16+
includeStaticDeclarations: false
17+
includePrivateDeclarations: false
18+
CyclomaticComplexMethod: # 독립적 경로의 수가 많은 복잡한 메서드 설정
19+
active: true
20+
threshold: 50
21+
ignoreSingleWhenExpression: false # when 표현식 하나인 메서드 무시
22+
ignoreSimpleWhenEntries: false # 간단한 항목(중괄호 없음)을 무시
23+
ignoreNestingFunctions: false # if 나 for 문 대신 자주 사용되는 함수 무시
24+
nestingFunctions:
25+
- 'also'
26+
- 'apply'
27+
- 'forEach'
28+
- 'isNotNull'
29+
- 'ifNull'
30+
- 'let'
31+
- 'run'
32+
- 'use'
33+
- 'with'
34+
LargeClass: # 큰 클래스 크기 설정
35+
active: true
36+
threshold: 500
37+
LongMethod: # 긴 메서드 크기 설정
38+
active: true
39+
threshold: 400
40+
LongParameterList: # 특정 임계값보다 많은 매개변수가 있는 함수와 생성자
41+
active: true
42+
functionThreshold: 20
43+
constructorThreshold: 7
44+
ignoreDefaultParameters: false # 기본값이 있는 매개변수 포함
45+
ignoreDataClasses: true # 데이터 클래스에 대해서 무시
46+
TooManyFunctions:
47+
active: true
48+
thresholdInFiles: 30
49+
thresholdInClasses: 20
50+
thresholdInInterfaces: 10
51+
thresholdInObjects: 20
52+
thresholdInEnums: 5
53+
ignoreDeprecated: true # @Deprecated 함수를 카운트에서 제외
54+
ignorePrivate: true # private 접근 제어자 함수를 카운트에서 제외
55+
ignoreOverridden: false # 오버라이드한 함수를 카운트에 포함
56+
NestedBlockDepth: # 중첩된 코드 블록
57+
active: true
58+
threshold: 10
59+
60+
coroutines:
61+
active: true
62+
GlobalCoroutineUsage:
63+
active: false
64+
RedundantSuspendModifier:
65+
active: false
66+
SleepInsteadOfDelay:
67+
active: false
68+
SuspendFunWithFlowReturnType:
69+
active: false
70+
71+
empty-blocks:
72+
active: true
73+
74+
exceptions:
75+
active: true
76+
InstanceOfCheckForException: # 예외 유형을 검사하는 catch 블록
77+
active: false
78+
TooGenericExceptionThrown: # 너무 일반적인 유형의 Exception
79+
active: false
80+
exceptionNames:
81+
- 'Error'
82+
- 'Exception'
83+
- 'RuntimeException'
84+
- 'Throwable'
85+
86+
formatting:
87+
active: true
88+
ImportOrdering:
89+
active: false
90+
MaximumLineLength:
91+
active: true
92+
maxLineLength: 160
93+
ArgumentListWrapping:
94+
active: false
95+
Wrapping:
96+
active: false
97+
PackageName:
98+
active: false
99+
100+
naming:
101+
active: true
102+
ConstructorParameterNaming: # 지정된 명명 규칙을 따르지 않는 생성자 매개변수
103+
active: false
104+
FunctionNaming: # 지정된 명명 규칙을 따르지 않는 함수 이름
105+
active: false
106+
BooleanPropertyNaming:
107+
active: true
108+
NonBooleanPropertyPrefixedWithIs:
109+
active: true
110+
PackageNaming:
111+
active: false
112+
113+
performance:
114+
active: true
115+
ForEachOnRange: # 성능 비용이 발생하는 forEach 구문
116+
active: false
117+
SpreadOperator: # 성능 저하 발생하는 spread 연산자
118+
active: false
119+
120+
potential-bugs:
121+
active: true
122+
123+
style:
124+
active: false

core/data/src/test/java/com/chat/data/ExampleUnitTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.chat.data
22

33
import org.junit.Test
4-
5-
import org.junit.Assert.*
4+
import org.junit.Assert.assertEquals
65

76
/**
87
* Example local unit test, which will execute on the development machine (host).
@@ -14,4 +13,4 @@ class ExampleUnitTest {
1413
fun addition_isCorrect() {
1514
assertEquals(4, 2 + 2)
1615
}
17-
}
16+
}

core/designsystem/src/main/java/com/chat/designsystem/component/appbar/DetailAppbar.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ fun DetailAppbar(
4141
@Composable
4242
fun DetailAppbarPreview() {
4343
DetailAppbar()
44-
}
44+
}

core/designsystem/src/main/java/com/chat/designsystem/component/appbar/GoSocketAppbar.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ fun GoSocketAppbarPreview() {
4646
) {
4747
Text(text = "GoSocketAppbar")
4848
}
49-
}
49+
}

0 commit comments

Comments
 (0)