Skip to content

Commit f8cfe22

Browse files
Merge pull request #325 from touchlab/ks/UpdateKtLint
Updating KtLint
2 parents 4e430ed + 73593b4 commit f8cfe22

File tree

26 files changed

+128
-129
lines changed

26 files changed

+128
-129
lines changed

.editorconfig

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1-
# noinspection EditorConfigKeyCorrectness
1+
# .editorconfig
2+
root = true
3+
24
[*.{kt,kts}]
5+
end_of_line = lf
6+
ij_kotlin_packages_to_use_import_on_demand = true
7+
ij_kotlin_allow_trailing_comma = true
8+
ij_kotlin_allow_trailing_comma_on_call_site = true
9+
ij_kotlin_imports_layout = *
10+
ij_kotlin_indent_before_arrow_on_new_line = false
11+
ij_kotlin_line_break_after_multiline_when_entry = true
12+
indent_size = 4
13+
indent_style = space
14+
insert_final_newline = true
15+
ktlint_argument_list_wrapping_ignore_when_parameter_count_greater_or_equal_than = 8
16+
ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than = 4
317
ktlint_code_style = android_studio
4-
ktlint_function_naming_ignore_when_annotated_with=Composable
18+
ktlint_enum_entry_name_casing = upper_or_camel_cases
19+
ktlint_function_naming_ignore_when_annotated_with = Composable
20+
ktlint_function_signature_body_expression_wrapping = default
21+
ktlint_ignore_back_ticked_identifier = false
22+
max_line_length = 140
23+
parameter-list-wrapping = true

.idea/codeStyles/Project.xml

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ android {
2020
isMinifyEnabled = false
2121
proguardFiles(
2222
getDefaultProguardFile("proguard-android-optimize.txt"),
23-
"proguard-rules.pro"
23+
"proguard-rules.pro",
2424
)
2525
}
2626
}

app/src/main/kotlin/co/touchlab/kampkit/android/MainActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import co.touchlab.kermit.Logger
1111
import org.koin.androidx.viewmodel.ext.android.viewModel
1212
import org.koin.core.component.KoinComponent
1313

14-
class MainActivity : ComponentActivity(), KoinComponent {
14+
class MainActivity :
15+
ComponentActivity(),
16+
KoinComponent {
1517

1618
private val log: Logger by injectLogger("MainActivity")
1719
private val viewModel: BreedViewModel by viewModel()

app/src/main/kotlin/co/touchlab/kampkit/android/MainApp.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ class MainApp : Application() {
2222
single<SharedPreferences> {
2323
get<Context>().getSharedPreferences(
2424
"KAMPSTARTER_SETTINGS",
25-
Context.MODE_PRIVATE
25+
Context.MODE_PRIVATE,
2626
)
2727
}
2828
single<AppInfo> { AndroidAppInfo }
2929
single {
3030
{ Log.i("Startup", "Hello from Android/Kotlin!") }
3131
}
32-
}
32+
},
3333
)
3434
}
3535
}

app/src/main/kotlin/co/touchlab/kampkit/android/ui/Composables.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fun MainScreen(viewModel: BreedViewModel, log: Logger) {
5555
onRefresh = { scope.launch { viewModel.refreshBreeds() } },
5656
onSuccess = { data -> log.v { "View updating with ${data.size} breeds" } },
5757
onError = { exception -> log.e { "Displaying error: $exception" } },
58-
onFavorite = { scope.launch { viewModel.updateBreedFavorite(it) } }
58+
onFavorite = { scope.launch { viewModel.updateBreedFavorite(it) } },
5959
)
6060
}
6161

@@ -66,11 +66,11 @@ fun MainScreenContent(
6666
onRefresh: () -> Unit = {},
6767
onSuccess: (List<Breed>) -> Unit = {},
6868
onError: (String) -> Unit = {},
69-
onFavorite: (Breed) -> Unit = {}
69+
onFavorite: (Breed) -> Unit = {},
7070
) {
7171
Surface(
7272
color = MaterialTheme.colors.background,
73-
modifier = Modifier.fillMaxSize()
73+
modifier = Modifier.fillMaxSize(),
7474
) {
7575
val refreshState = rememberPullRefreshState(dogsState.isLoading, onRefresh)
7676

@@ -97,7 +97,7 @@ fun MainScreenContent(
9797
PullRefreshIndicator(
9898
dogsState.isLoading,
9999
refreshState,
100-
Modifier.align(Alignment.TopCenter)
100+
Modifier.align(Alignment.TopCenter),
101101
)
102102
}
103103
}
@@ -110,7 +110,7 @@ fun Empty() {
110110
.fillMaxSize()
111111
.verticalScroll(rememberScrollState()),
112112
verticalArrangement = Arrangement.Center,
113-
horizontalAlignment = Alignment.CenterHorizontally
113+
horizontalAlignment = Alignment.CenterHorizontally,
114114
) {
115115
Text(stringResource(R.string.empty_breeds))
116116
}
@@ -123,7 +123,7 @@ fun Error(error: String) {
123123
.fillMaxSize()
124124
.verticalScroll(rememberScrollState()),
125125
verticalArrangement = Arrangement.Center,
126-
horizontalAlignment = Alignment.CenterHorizontally
126+
horizontalAlignment = Alignment.CenterHorizontally,
127127
) {
128128
Text(text = error)
129129
}
@@ -151,7 +151,7 @@ fun DogRow(breed: Breed, onClick: (Breed) -> Unit) {
151151
Row(
152152
Modifier
153153
.clickable { onClick(breed) }
154-
.padding(10.dp)
154+
.padding(10.dp),
155155
) {
156156
Text(breed.name, Modifier.weight(1F))
157157
FavoriteIcon(breed)
@@ -164,19 +164,19 @@ fun FavoriteIcon(breed: Breed) {
164164
targetState = !breed.favorite,
165165
animationSpec = TweenSpec(
166166
durationMillis = 500,
167-
easing = FastOutSlowInEasing
167+
easing = FastOutSlowInEasing,
168168
),
169-
label = "CrossFadeFavoriteIcon"
169+
label = "CrossFadeFavoriteIcon",
170170
) { fav ->
171171
if (fav) {
172172
Image(
173173
painter = painterResource(id = R.drawable.ic_favorite_border_24px),
174-
contentDescription = stringResource(R.string.favorite_breed, breed.name)
174+
contentDescription = stringResource(R.string.favorite_breed, breed.name),
175175
)
176176
} else {
177177
Image(
178178
painter = painterResource(id = R.drawable.ic_favorite_24px),
179-
contentDescription = stringResource(R.string.unfavorite_breed, breed.name)
179+
contentDescription = stringResource(R.string.unfavorite_breed, breed.name),
180180
)
181181
}
182182
}
@@ -189,9 +189,9 @@ fun MainScreenContentPreview_Success() {
189189
dogsState = BreedViewState.Content(
190190
breeds = listOf(
191191
Breed(0, "appenzeller", false),
192-
Breed(1, "australian", true)
193-
)
194-
)
192+
Breed(1, "australian", true),
193+
),
194+
),
195195
)
196196
}
197197

app/src/main/kotlin/co/touchlab/kampkit/android/ui/theme/Shapes.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ import androidx.compose.ui.unit.dp
77
val Shapes = Shapes(
88
small = RoundedCornerShape(4.dp),
99
medium = RoundedCornerShape(4.dp),
10-
large = RoundedCornerShape(0.dp)
10+
large = RoundedCornerShape(0.dp),
1111
)

app/src/main/kotlin/co/touchlab/kampkit/android/ui/theme/Theme.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import androidx.compose.runtime.Composable
99
private val DarkColorPalette = darkColors(
1010
primary = Purple200,
1111
primaryVariant = Purple700,
12-
secondary = Teal200
12+
secondary = Teal200,
1313
)
1414

1515
private val LightColorPalette = lightColors(
1616
primary = Purple500,
1717
primaryVariant = Purple700,
18-
secondary = Teal200
18+
secondary = Teal200,
1919

2020
// Other default colors to override
2121
//
@@ -39,6 +39,6 @@ fun KaMPKitTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composabl
3939
colors = colors,
4040
typography = Typography,
4141
shapes = Shapes,
42-
content = content
42+
content = content,
4343
)
4444
}

app/src/main/kotlin/co/touchlab/kampkit/android/ui/theme/Typography.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ val Typography = Typography(
1111
body1 = TextStyle(
1212
fontFamily = FontFamily.Default,
1313
fontWeight = FontWeight.Normal,
14-
fontSize = 16.sp
15-
)
14+
fontSize = 16.sp,
15+
),
1616
// Other default text styles to override
1717
//
1818
// button = TextStyle(

build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ subprojects {
1414
apply(plugin = rootProject.libs.plugins.ktlint.get().pluginId)
1515

1616
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
17+
version.set("1.4.0")
18+
enableExperimentalRules.set(true)
1719
verbose.set(true)
1820
filter {
1921
exclude { it.file.path.contains("build/") }
2022
}
2123
}
24+
25+
afterEvaluate {
26+
tasks.named("check") {
27+
dependsOn(tasks.getByName("ktlintCheck"))
28+
}
29+
}
2230
}

0 commit comments

Comments
 (0)