Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit 3a863d6

Browse files
Fix ktlint (#311)
1 parent 0dd47d3 commit 3a863d6

File tree

10 files changed

+68
-85
lines changed

10 files changed

+68
-85
lines changed

build.gradle.kts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ allprojects {
4949
}
5050
}
5151

52-
apply(plugin = rootProject.libs.plugins.spotless.get().pluginId)
52+
apply(
53+
plugin =
54+
rootProject.libs.plugins.spotless
55+
.get()
56+
.pluginId,
57+
)
5358
configure<SpotlessExtension> {
5459
kotlin {
5560
target("**/*.kt")
@@ -59,8 +64,7 @@ allprojects {
5964
listOf(
6065
libs.ktlintComposeRules.get().toString(),
6166
),
62-
)
63-
.editorConfigOverride(
67+
).editorConfigOverride(
6468
mapOf(
6569
// Disabled because paging-* filenames should be identical to that of AndroidX Paging.
6670
"ktlint_standard_filename" to "disabled",

paging-common/src/commonMain/kotlin/app/cash/paging/CombinedLoadStates.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ fun createCombinedLoadStates(
3737
append: LoadState,
3838
source: LoadStates,
3939
mediator: LoadStates? = null,
40-
): CombinedLoadStates {
41-
return CombinedLoadStates(
42-
refresh,
43-
prepend,
44-
append,
45-
source,
46-
mediator,
47-
)
48-
}
40+
): CombinedLoadStates = CombinedLoadStates(
41+
refresh,
42+
prepend,
43+
append,
44+
source,
45+
mediator,
46+
)

paging-common/src/commonMain/kotlin/app/cash/paging/LoadStates.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ fun LoadStates.copy(
3737
refresh: LoadState = this.refresh,
3838
prepend: LoadState = this.prepend,
3939
append: LoadState = this.append,
40-
): LoadStates {
41-
return LoadStates(
42-
refresh,
43-
prepend,
44-
append,
45-
)
46-
}
40+
): LoadStates = LoadStates(
41+
refresh,
42+
prepend,
43+
append,
44+
)

paging-common/src/commonMain/kotlin/app/cash/paging/Pager.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,19 @@ fun <Key : Any, Value : Any> createPager(
4242
initialKey: Key? = null,
4343
remoteMediator: RemoteMediator<Key, Value>?,
4444
pagingSourceFactory: () -> PagingSource<Key, Value>,
45-
): Pager<Key, Value> {
46-
return Pager(
47-
config,
48-
initialKey,
49-
remoteMediator,
50-
pagingSourceFactory,
51-
)
52-
}
45+
): Pager<Key, Value> = Pager(
46+
config,
47+
initialKey,
48+
remoteMediator,
49+
pagingSourceFactory,
50+
)
5351

5452
fun <Key : Any, Value : Any> createPager(
5553
config: PagingConfig,
5654
initialKey: Key? = null,
5755
pagingSourceFactory: () -> PagingSource<Key, Value>,
58-
): Pager<Key, Value> {
59-
return Pager(
60-
config,
61-
initialKey,
62-
pagingSourceFactory,
63-
)
64-
}
56+
): Pager<Key, Value> = Pager(
57+
config,
58+
initialKey,
59+
pagingSourceFactory,
60+
)

paging-common/src/commonMain/kotlin/app/cash/paging/PagingConfig.kt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,14 @@ fun createPagingConfig(
6060
initialLoadSize: Int = pageSize * 3,
6161
maxSize: Int = MAX_SIZE_UNBOUNDED,
6262
jumpThreshold: Int = COUNT_UNDEFINED,
63-
): PagingConfig {
64-
return PagingConfig(
65-
pageSize,
66-
prefetchDistance,
67-
enablePlaceholders,
68-
initialLoadSize,
69-
maxSize,
70-
jumpThreshold,
71-
)
72-
}
63+
): PagingConfig = PagingConfig(
64+
pageSize,
65+
prefetchDistance,
66+
enablePlaceholders,
67+
initialLoadSize,
68+
maxSize,
69+
jumpThreshold,
70+
)
7371

7472
@Suppress("MinMaxConstant")
7573
const val MAX_SIZE_UNBOUNDED: Int = Int.MAX_VALUE

paging-common/src/commonMain/kotlin/app/cash/paging/PagingSource.kt

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ expect class PagingSourceLoadResultError<Key : Any, Value : Any>(
8686

8787
fun <Key : Any, Value : Any> PagingSourceLoadResultError<Key, Value>.copy(
8888
throwable: Throwable = this.throwable,
89-
): PagingSourceLoadResultError<Key, Value> {
90-
return PagingSourceLoadResultError(throwable)
91-
}
89+
): PagingSourceLoadResultError<Key, Value> = PagingSourceLoadResultError(throwable)
9290

9391
expect class PagingSourceLoadResultInvalid<Key : Any, Value : Any>()
9492

@@ -128,30 +126,26 @@ fun <Key : Any, Value : Any> createPagingSourceLoadResultPage(
128126
nextKey: Key?,
129127
itemsBefore: Int = COUNT_UNDEFINED,
130128
itemsAfter: Int = COUNT_UNDEFINED,
131-
): PagingSourceLoadResultPage<Key, Value> {
132-
return PagingSourceLoadResultPage(
133-
data,
134-
prevKey,
135-
nextKey,
136-
itemsBefore,
137-
itemsAfter,
138-
)
139-
}
129+
): PagingSourceLoadResultPage<Key, Value> = PagingSourceLoadResultPage(
130+
data,
131+
prevKey,
132+
nextKey,
133+
itemsBefore,
134+
itemsAfter,
135+
)
140136

141137
fun <Key : Any, Value : Any> PagingSourceLoadResultPage<Key, Value>.copy(
142138
data: List<Value> = this.data,
143139
prevKey: Key? = this.prevKey,
144140
nextKey: Key? = this.nextKey,
145141
itemsBefore: Int = this.itemsBefore,
146142
itemsAfter: Int = this.itemsAfter,
147-
): PagingSourceLoadResultPage<Key, Value> {
148-
return PagingSourceLoadResultPage(
149-
data,
150-
prevKey,
151-
nextKey,
152-
itemsBefore,
153-
itemsAfter,
154-
)
155-
}
143+
): PagingSourceLoadResultPage<Key, Value> = PagingSourceLoadResultPage(
144+
data,
145+
prevKey,
146+
nextKey,
147+
itemsBefore,
148+
itemsAfter,
149+
)
156150

157151
const val COUNT_UNDEFINED: Int = Int.MIN_VALUE

paging-runtime-uikit/src/iosMain/kotlin/app/cash/paging/PagingCollectionViewController.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,9 @@ class PagingCollectionViewController<T : Any> {
2323
private var collectionView: UICollectionView? = null
2424

2525
private val diffCallback = object : DiffUtil.ItemCallback<T>() {
26-
override fun areItemsTheSame(oldItem: T, newItem: T): Boolean {
27-
return oldItem == newItem
28-
}
26+
override fun areItemsTheSame(oldItem: T, newItem: T): Boolean = oldItem == newItem
2927

30-
override fun areContentsTheSame(oldItem: T, newItem: T): Boolean {
31-
return oldItem == newItem
32-
}
28+
override fun areContentsTheSame(oldItem: T, newItem: T): Boolean = oldItem == newItem
3329
}
3430

3531
private val differ = AsyncPagingDataDiffer(

samples/repo-search/android-composeui/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ android {
3030
}
3131

3232
composeOptions {
33-
kotlinCompilerExtensionVersion = libs.androidx.compose.compiler.get().version
33+
kotlinCompilerExtensionVersion =
34+
libs.androidx.compose.compiler
35+
.get()
36+
.version
3437
}
3538
}
3639

samples/repo-search/shared/src/commonMain/kotlin/app/cash/paging/samples/reposearch/RepoSearchPresenter.kt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,14 @@ class RepoSearchPresenter {
4444
}
4545
}
4646

47-
fun produceViewModels(events: Flow<Event>): Flow<ViewModel> {
48-
return events.map { event ->
49-
when (event) {
50-
is Event.SearchTerm -> {
51-
latestSearchTerm = event.searchTerm
52-
if (event.searchTerm.isEmpty()) {
53-
ViewModel.Empty
54-
} else {
55-
ViewModel.SearchResults(latestSearchTerm, pager.flow)
56-
}
47+
fun produceViewModels(events: Flow<Event>): Flow<ViewModel> = events.map { event ->
48+
when (event) {
49+
is Event.SearchTerm -> {
50+
latestSearchTerm = event.searchTerm
51+
if (event.searchTerm.isEmpty()) {
52+
ViewModel.Empty
53+
} else {
54+
ViewModel.SearchResults(latestSearchTerm, pager.flow)
5755
}
5856
}
5957
}

samples/repo-search/shared/src/iosMain/kotlin/app/cash/paging/samples/reposearch/exposed.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow
77
fun exposedTypes(
88
pagingCollectionViewController: PagingCollectionViewController<*>,
99
mutableSharedFlow: MutableSharedFlow<*>,
10-
) {
11-
throw AssertionError()
12-
}
10+
): Unit = throw AssertionError()
1311

1412
@Suppress("unused") // Used to export types to Objective-C / Swift.
1513
fun <T> mutableSharedFlow(extraBufferCapacity: Int) = MutableSharedFlow<T>(extraBufferCapacity = extraBufferCapacity)

0 commit comments

Comments
 (0)