diff --git a/build.gradle.kts b/build.gradle.kts index 91a22f52029..ab72ea48f6b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -49,7 +49,12 @@ allprojects { } } - apply(plugin = rootProject.libs.plugins.spotless.get().pluginId) + apply( + plugin = + rootProject.libs.plugins.spotless + .get() + .pluginId, + ) configure { kotlin { target("**/*.kt") @@ -59,8 +64,7 @@ allprojects { listOf( libs.ktlintComposeRules.get().toString(), ), - ) - .editorConfigOverride( + ).editorConfigOverride( mapOf( // Disabled because paging-* filenames should be identical to that of AndroidX Paging. "ktlint_standard_filename" to "disabled", diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 71228d052c7..7e5f3adf204 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -37,7 +37,7 @@ ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "kto ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" } ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } # Specify the full coordinate for Renovate to track even though we only use the version. -ktlint = "com.pinterest.ktlint:ktlint-cli:1.2.1" +ktlint = "com.pinterest.ktlint:ktlint-cli:1.3.1" ktlintComposeRules = "io.nlopez.compose.rules:ktlint:0.4.10" [plugins] diff --git a/paging-common/src/commonMain/kotlin/app/cash/paging/CombinedLoadStates.kt b/paging-common/src/commonMain/kotlin/app/cash/paging/CombinedLoadStates.kt index 35d4626f2b7..063719abf04 100644 --- a/paging-common/src/commonMain/kotlin/app/cash/paging/CombinedLoadStates.kt +++ b/paging-common/src/commonMain/kotlin/app/cash/paging/CombinedLoadStates.kt @@ -37,12 +37,10 @@ fun createCombinedLoadStates( append: LoadState, source: LoadStates, mediator: LoadStates? = null, -): CombinedLoadStates { - return CombinedLoadStates( - refresh, - prepend, - append, - source, - mediator, - ) -} +): CombinedLoadStates = CombinedLoadStates( + refresh, + prepend, + append, + source, + mediator, +) diff --git a/paging-common/src/commonMain/kotlin/app/cash/paging/LoadStates.kt b/paging-common/src/commonMain/kotlin/app/cash/paging/LoadStates.kt index fd35a37acfb..91c73b3975c 100644 --- a/paging-common/src/commonMain/kotlin/app/cash/paging/LoadStates.kt +++ b/paging-common/src/commonMain/kotlin/app/cash/paging/LoadStates.kt @@ -37,10 +37,8 @@ fun LoadStates.copy( refresh: LoadState = this.refresh, prepend: LoadState = this.prepend, append: LoadState = this.append, -): LoadStates { - return LoadStates( - refresh, - prepend, - append, - ) -} +): LoadStates = LoadStates( + refresh, + prepend, + append, +) diff --git a/paging-common/src/commonMain/kotlin/app/cash/paging/Pager.kt b/paging-common/src/commonMain/kotlin/app/cash/paging/Pager.kt index fce9d8d4051..2e1eff6bd79 100644 --- a/paging-common/src/commonMain/kotlin/app/cash/paging/Pager.kt +++ b/paging-common/src/commonMain/kotlin/app/cash/paging/Pager.kt @@ -42,23 +42,19 @@ fun createPager( initialKey: Key? = null, remoteMediator: RemoteMediator?, pagingSourceFactory: () -> PagingSource, -): Pager { - return Pager( - config, - initialKey, - remoteMediator, - pagingSourceFactory, - ) -} +): Pager = Pager( + config, + initialKey, + remoteMediator, + pagingSourceFactory, +) fun createPager( config: PagingConfig, initialKey: Key? = null, pagingSourceFactory: () -> PagingSource, -): Pager { - return Pager( - config, - initialKey, - pagingSourceFactory, - ) -} +): Pager = Pager( + config, + initialKey, + pagingSourceFactory, +) diff --git a/paging-common/src/commonMain/kotlin/app/cash/paging/PagingConfig.kt b/paging-common/src/commonMain/kotlin/app/cash/paging/PagingConfig.kt index 222f75dbfe1..aa63e55c71b 100644 --- a/paging-common/src/commonMain/kotlin/app/cash/paging/PagingConfig.kt +++ b/paging-common/src/commonMain/kotlin/app/cash/paging/PagingConfig.kt @@ -60,16 +60,14 @@ fun createPagingConfig( initialLoadSize: Int = pageSize * 3, maxSize: Int = MAX_SIZE_UNBOUNDED, jumpThreshold: Int = COUNT_UNDEFINED, -): PagingConfig { - return PagingConfig( - pageSize, - prefetchDistance, - enablePlaceholders, - initialLoadSize, - maxSize, - jumpThreshold, - ) -} +): PagingConfig = PagingConfig( + pageSize, + prefetchDistance, + enablePlaceholders, + initialLoadSize, + maxSize, + jumpThreshold, +) @Suppress("MinMaxConstant") const val MAX_SIZE_UNBOUNDED: Int = Int.MAX_VALUE diff --git a/paging-common/src/commonMain/kotlin/app/cash/paging/PagingSource.kt b/paging-common/src/commonMain/kotlin/app/cash/paging/PagingSource.kt index bf88fa9dc41..102022ad5bf 100644 --- a/paging-common/src/commonMain/kotlin/app/cash/paging/PagingSource.kt +++ b/paging-common/src/commonMain/kotlin/app/cash/paging/PagingSource.kt @@ -86,9 +86,7 @@ expect class PagingSourceLoadResultError( fun PagingSourceLoadResultError.copy( throwable: Throwable = this.throwable, -): PagingSourceLoadResultError { - return PagingSourceLoadResultError(throwable) -} +): PagingSourceLoadResultError = PagingSourceLoadResultError(throwable) expect class PagingSourceLoadResultInvalid() @@ -128,15 +126,13 @@ fun createPagingSourceLoadResultPage( nextKey: Key?, itemsBefore: Int = COUNT_UNDEFINED, itemsAfter: Int = COUNT_UNDEFINED, -): PagingSourceLoadResultPage { - return PagingSourceLoadResultPage( - data, - prevKey, - nextKey, - itemsBefore, - itemsAfter, - ) -} +): PagingSourceLoadResultPage = PagingSourceLoadResultPage( + data, + prevKey, + nextKey, + itemsBefore, + itemsAfter, +) fun PagingSourceLoadResultPage.copy( data: List = this.data, @@ -144,14 +140,12 @@ fun PagingSourceLoadResultPage.copy( nextKey: Key? = this.nextKey, itemsBefore: Int = this.itemsBefore, itemsAfter: Int = this.itemsAfter, -): PagingSourceLoadResultPage { - return PagingSourceLoadResultPage( - data, - prevKey, - nextKey, - itemsBefore, - itemsAfter, - ) -} +): PagingSourceLoadResultPage = PagingSourceLoadResultPage( + data, + prevKey, + nextKey, + itemsBefore, + itemsAfter, +) const val COUNT_UNDEFINED: Int = Int.MIN_VALUE diff --git a/paging-runtime-uikit/src/iosMain/kotlin/app/cash/paging/PagingCollectionViewController.kt b/paging-runtime-uikit/src/iosMain/kotlin/app/cash/paging/PagingCollectionViewController.kt index 784b4c31822..200880af85d 100644 --- a/paging-runtime-uikit/src/iosMain/kotlin/app/cash/paging/PagingCollectionViewController.kt +++ b/paging-runtime-uikit/src/iosMain/kotlin/app/cash/paging/PagingCollectionViewController.kt @@ -23,13 +23,9 @@ class PagingCollectionViewController { private var collectionView: UICollectionView? = null private val diffCallback = object : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: T, newItem: T): Boolean { - return oldItem == newItem - } + override fun areItemsTheSame(oldItem: T, newItem: T): Boolean = oldItem == newItem - override fun areContentsTheSame(oldItem: T, newItem: T): Boolean { - return oldItem == newItem - } + override fun areContentsTheSame(oldItem: T, newItem: T): Boolean = oldItem == newItem } private val differ = AsyncPagingDataDiffer( diff --git a/samples/repo-search/android-composeui/build.gradle.kts b/samples/repo-search/android-composeui/build.gradle.kts index 6c91383c9c9..62a2eb38e8c 100644 --- a/samples/repo-search/android-composeui/build.gradle.kts +++ b/samples/repo-search/android-composeui/build.gradle.kts @@ -30,7 +30,10 @@ android { } composeOptions { - kotlinCompilerExtensionVersion = libs.androidx.compose.compiler.get().version + kotlinCompilerExtensionVersion = + libs.androidx.compose.compiler + .get() + .version } } diff --git a/samples/repo-search/shared/src/commonMain/kotlin/app/cash/paging/samples/reposearch/RepoSearchPresenter.kt b/samples/repo-search/shared/src/commonMain/kotlin/app/cash/paging/samples/reposearch/RepoSearchPresenter.kt index 58d29c1d5c4..3e335617d47 100644 --- a/samples/repo-search/shared/src/commonMain/kotlin/app/cash/paging/samples/reposearch/RepoSearchPresenter.kt +++ b/samples/repo-search/shared/src/commonMain/kotlin/app/cash/paging/samples/reposearch/RepoSearchPresenter.kt @@ -44,16 +44,14 @@ class RepoSearchPresenter { } } - fun produceViewModels(events: Flow): Flow { - return events.map { event -> - when (event) { - is Event.SearchTerm -> { - latestSearchTerm = event.searchTerm - if (event.searchTerm.isEmpty()) { - ViewModel.Empty - } else { - ViewModel.SearchResults(latestSearchTerm, pager.flow) - } + fun produceViewModels(events: Flow): Flow = events.map { event -> + when (event) { + is Event.SearchTerm -> { + latestSearchTerm = event.searchTerm + if (event.searchTerm.isEmpty()) { + ViewModel.Empty + } else { + ViewModel.SearchResults(latestSearchTerm, pager.flow) } } } diff --git a/samples/repo-search/shared/src/iosMain/kotlin/app/cash/paging/samples/reposearch/exposed.kt b/samples/repo-search/shared/src/iosMain/kotlin/app/cash/paging/samples/reposearch/exposed.kt index 93b0a6b30ee..68be9a56c2a 100644 --- a/samples/repo-search/shared/src/iosMain/kotlin/app/cash/paging/samples/reposearch/exposed.kt +++ b/samples/repo-search/shared/src/iosMain/kotlin/app/cash/paging/samples/reposearch/exposed.kt @@ -7,9 +7,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow fun exposedTypes( pagingCollectionViewController: PagingCollectionViewController<*>, mutableSharedFlow: MutableSharedFlow<*>, -) { - throw AssertionError() -} +): Unit = throw AssertionError() @Suppress("unused") // Used to export types to Objective-C / Swift. fun mutableSharedFlow(extraBufferCapacity: Int) = MutableSharedFlow(extraBufferCapacity = extraBufferCapacity)