Skip to content

Commit a4a4566

Browse files
committed
Init: ktlint 적용 및 기존 코드, ci에 ktlint 반영
1 parent 3478a6b commit a4a4566

10 files changed

Lines changed: 68 additions & 38 deletions

File tree

.editorconfig

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

.github/workflows/develop_branch.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
distribution: 'temurin'
2222
cache: gradle
2323

24+
- name: Run ktlint
25+
run: ./gradlew ktlintCheck
26+
2427
- name: Run unit tests
2528
run: ./gradlew testDebugUnitTest
2629

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ android {
2323
isMinifyEnabled = false
2424
proguardFiles(
2525
getDefaultProguardFile("proguard-android-optimize.txt"),
26-
"proguard-rules.pro"
26+
"proguard-rules.pro",
2727
)
2828
}
2929
}

app/src/androidTest/java/com/threegap/bitnagil/ExampleInstrumentedTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package com.threegap.bitnagil
22

3-
import androidx.test.platform.app.InstrumentationRegistry
43
import androidx.test.ext.junit.runners.AndroidJUnit4
5-
4+
import androidx.test.platform.app.InstrumentationRegistry
5+
import org.junit.Assert.assertEquals
66
import org.junit.Test
77
import org.junit.runner.RunWith
88

9-
import org.junit.Assert.*
10-
119
/**
1210
* Instrumented test, which will execute on an Android device.
1311
*

app/src/main/java/com/threegap/bitnagil/MainActivity.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MainActivity : ComponentActivity() {
2222
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
2323
Greeting(
2424
name = "Android",
25-
modifier = Modifier.padding(innerPadding)
25+
modifier = Modifier.padding(innerPadding),
2626
)
2727
}
2828
}
@@ -31,10 +31,13 @@ class MainActivity : ComponentActivity() {
3131
}
3232

3333
@Composable
34-
fun Greeting(name: String, modifier: Modifier = Modifier) {
34+
fun Greeting(
35+
name: String,
36+
modifier: Modifier = Modifier,
37+
) {
3538
Text(
3639
text = "Hello $name!",
37-
modifier = modifier
40+
modifier = modifier,
3841
)
3942
}
4043

app/src/main/java/com/threegap/bitnagil/ui/theme/Theme.kt

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,41 @@ import androidx.compose.material3.lightColorScheme
1010
import androidx.compose.runtime.Composable
1111
import androidx.compose.ui.platform.LocalContext
1212

13-
private val DarkColorScheme = darkColorScheme(
14-
primary = Purple80,
15-
secondary = PurpleGrey80,
16-
tertiary = Pink80
17-
)
13+
private val DarkColorScheme =
14+
darkColorScheme(
15+
primary = Purple80,
16+
secondary = PurpleGrey80,
17+
tertiary = Pink80,
18+
)
1819

19-
private val LightColorScheme = lightColorScheme(
20-
primary = Purple40,
21-
secondary = PurpleGrey40,
22-
tertiary = Pink40
23-
)
20+
private val LightColorScheme =
21+
lightColorScheme(
22+
primary = Purple40,
23+
secondary = PurpleGrey40,
24+
tertiary = Pink40,
25+
)
2426

2527
@Composable
2628
fun BitnagilTheme(
2729
darkTheme: Boolean = isSystemInDarkTheme(),
2830
// Dynamic color is available on Android 12+
2931
dynamicColor: Boolean = true,
30-
content: @Composable () -> Unit
32+
content: @Composable () -> Unit,
3133
) {
32-
val colorScheme = when {
33-
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
34-
val context = LocalContext.current
35-
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
36-
}
34+
val colorScheme =
35+
when {
36+
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
37+
val context = LocalContext.current
38+
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
39+
}
3740

38-
darkTheme -> DarkColorScheme
39-
else -> LightColorScheme
40-
}
41+
darkTheme -> DarkColorScheme
42+
else -> LightColorScheme
43+
}
4144

4245
MaterialTheme(
4346
colorScheme = colorScheme,
4447
typography = Typography,
45-
content = content
48+
content = content,
4649
)
4750
}

app/src/main/java/com/threegap/bitnagil/ui/theme/Type.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import androidx.compose.ui.text.font.FontWeight
77
import androidx.compose.ui.unit.sp
88

99
// Set of Material typography styles to start with
10-
val Typography = Typography(
11-
bodyLarge = TextStyle(
12-
fontFamily = FontFamily.Default,
13-
fontWeight = FontWeight.Normal,
14-
fontSize = 16.sp,
15-
lineHeight = 24.sp,
16-
letterSpacing = 0.5.sp
10+
val Typography =
11+
Typography(
12+
bodyLarge =
13+
TextStyle(
14+
fontFamily = FontFamily.Default,
15+
fontWeight = FontWeight.Normal,
16+
fontSize = 16.sp,
17+
lineHeight = 24.sp,
18+
letterSpacing = 0.5.sp,
19+
),
1720
)
18-
)

app/src/test/java/com/threegap/bitnagil/ExampleUnitTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package com.threegap.bitnagil
22

3+
import org.junit.Assert.assertEquals
34
import org.junit.Test
45

5-
import org.junit.Assert.*
6-
76
/**
87
* Example local unit test, which will execute on the development machine (host).
98
*

build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@ plugins {
33
alias(libs.plugins.android.application) apply false
44
alias(libs.plugins.kotlin.android) apply false
55
alias(libs.plugins.kotlin.compose) apply false
6+
alias(libs.plugins.ktlint.gradle) apply false
67
}
8+
9+
subprojects {
10+
apply(plugin = "org.jlleitschuh.gradle.ktlint")
11+
}

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ espressoCore = "3.6.1"
88
lifecycleRuntimeKtx = "2.9.1"
99
activityCompose = "1.10.1"
1010
composeBom = "2025.06.00"
11+
ktlint = "12.3.0"
1112

1213
[libraries]
1314
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -29,4 +30,5 @@ androidx-material3 = { group = "androidx.compose.material3", name = "material3"
2930
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
3031
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
3132
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
33+
ktlint-gradle = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
3234

0 commit comments

Comments
 (0)