Enable detekt rules AlsoCouldBeApply and fix existing issues.

This commit is contained in:
Benoit Marty
2023-07-26 11:10:30 +02:00
committed by Benoit Marty
parent 1d3aa2cd05
commit d433c3cbaa
4 changed files with 8 additions and 10 deletions

View File

@@ -41,8 +41,7 @@ class CustomTabHandler @Inject constructor(
if (packageName != null) {
customTabsServiceConnection = object : CustomTabsServiceConnection() {
override fun onCustomTabsServiceConnected(name: ComponentName, client: CustomTabsClient) {
customTabsClient = client
.also { it.warmup(0L) }
customTabsClient = client.apply { warmup(0L) }
prefetchUrl(url)
}

View File

@@ -101,7 +101,7 @@ class DefaultLastMessageTimestampFormatterTest {
* Create DefaultLastMessageFormatter and set current time to the provided date.
*/
private fun createFormatter(@Suppress("SameParameterValue") currentDate: String): LastMessageTimestampFormatter {
val clock = FakeClock().also { it.givenInstant(Instant.parse(currentDate)) }
val clock = FakeClock().apply { givenInstant(Instant.parse(currentDate)) }
val localDateTimeProvider = LocalDateTimeProvider(clock, TimeZone.UTC)
val dateFormatters = DateFormatters(Locale.US, clock, TimeZone.UTC)
return DefaultLastMessageTimestampFormatter(localDateTimeProvider, dateFormatters)

View File

@@ -20,19 +20,16 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
open class AvatarDataProvider : PreviewParameterProvider<AvatarData> {
override val values: Sequence<AvatarData>
get() {
AvatarSize.values()
.also { it.sortBy { item -> item.name } }
.asSequence()
return AvatarSize.values().asSequence().map {
get() = AvatarSize.values()
.asSequence()
.map {
sequenceOf(
anAvatarData(size = it),
anAvatarData(size = it).copy(name = null),
anAvatarData(size = it).copy(url = "aUrl"),
)
}
.flatten()
}
.flatten()
}
fun anAvatarData(

View File

@@ -1,6 +1,8 @@
# Default rules: https://github.com/detekt/detekt/blob/main/detekt-core/src/main/resources/default-detekt-config.yml
style:
AlsoCouldBeApply:
active: true
CascadingCallWrapping:
active: true
includeElvis: true