diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 4cb7457249..d4b7accbaa 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/appnav/src/test/kotlin/io/element/android/appnav/loggedin/LoggedInPresenterTest.kt b/appnav/src/test/kotlin/io/element/android/appnav/loggedin/LoggedInPresenterTest.kt index 519cceddfe..961856148e 100644 --- a/appnav/src/test/kotlin/io/element/android/appnav/loggedin/LoggedInPresenterTest.kt +++ b/appnav/src/test/kotlin/io/element/android/appnav/loggedin/LoggedInPresenterTest.kt @@ -478,7 +478,7 @@ class LoggedInPresenterTest { distributors = listOf(Distributor("aDistributorValue1", "aDistributorName1")), currentDistributor = { null }, ), - registerWithLambda: suspend (MatrixClient, PushProvider, Distributor) -> Result = { _, _, _ -> + registerWithLambda: (MatrixClient, PushProvider, Distributor) -> Result = { _, _, _ -> Result.success(Unit) }, selectPushProviderLambda: (MatrixClient, PushProvider) -> Unit = { _, _ -> lambdaError() }, diff --git a/build.gradle.kts b/build.gradle.kts index 01a1c7164c..d008c6b1d4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,6 +18,7 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.compose.compiler) apply false alias(libs.plugins.ksp) apply false alias(libs.plugins.anvil) apply false alias(libs.plugins.kotlin.jvm) apply false @@ -82,20 +83,15 @@ allprojects { } tasks.withType { - // Warnings are potential errors, so stop ignoring them - // This is disabled by default, but the CI will enforce this. - // You can override by passing `-PallWarningsAsErrors=true` in the command line - // Or add a line with "allWarningsAsErrors=true" in your ~/.gradle/gradle.properties file - kotlinOptions.allWarningsAsErrors = project.properties["allWarningsAsErrors"] == "true" - - kotlinOptions { - /* + compilerOptions { + // Warnings are potential errors, so stop ignoring them + // This is disabled by default, but the CI will enforce this. + // You can override by passing `-PallWarningsAsErrors=true` in the command line + // Or add a line with "allWarningsAsErrors=true" in your ~/.gradle/gradle.properties file + allWarningsAsErrors = project.properties["allWarningsAsErrors"] == "true" + // Uncomment to suppress Compose Kotlin compiler compatibility warning - freeCompilerArgs += listOf( - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true" - ) - */ +// freeCompilerArgs.addAll(listOf("-P", "plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true")) } } } @@ -192,19 +188,23 @@ subprojects { subprojects { tasks.withType().configureEach { - kotlinOptions { + compilerOptions { if (project.findProperty("composeCompilerReports") == "true") { - freeCompilerArgs += listOf( - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + - "${project.layout.buildDirectory.asFile.get().absolutePath}/compose_compiler" + freeCompilerArgs.addAll( + listOf( + "-P", + "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + + "${project.layout.buildDirectory.asFile.get().absolutePath}/compose_compiler" + ) ) } if (project.findProperty("composeCompilerMetrics") == "true") { - freeCompilerArgs += listOf( - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + - "${project.layout.buildDirectory.asFile.get().absolutePath}/compose_compiler" + freeCompilerArgs.addAll( + listOf( + "-P", + "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + + "${project.layout.buildDirectory.asFile.get().absolutePath}/compose_compiler" + ) ) } } diff --git a/features/cachecleaner/api/build.gradle.kts b/features/cachecleaner/api/build.gradle.kts index ebe4fe0dd7..30dfd6d42c 100644 --- a/features/cachecleaner/api/build.gradle.kts +++ b/features/cachecleaner/api/build.gradle.kts @@ -1,3 +1,5 @@ +import extension.setupAnvil + /* * Copyright 2023, 2024 New Vector Ltd. * @@ -7,13 +9,14 @@ plugins { id("io.element.android-library") - alias(libs.plugins.anvil) } android { namespace = "io.element.android.features.cachecleaner.api" } +setupAnvil() + dependencies { implementation(projects.libraries.architecture) implementation(libs.androidx.startup) diff --git a/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt b/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt index 7390b5fde9..f0e5708db3 100644 --- a/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt +++ b/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt @@ -109,12 +109,7 @@ class CallScreenPresenterTest { assertThat(initialState.isInWidgetMode).isTrue() assertThat(widgetProvider.getWidgetCalled).isTrue() assertThat(widgetDriver.runCalledCount).isEqualTo(1) - // Called several times because of the recomposition - analyticsLambda.assertions().isCalledExactly(2) - .withSequence( - listOf(value(MobileScreen.ScreenName.RoomCall)), - listOf(value(MobileScreen.ScreenName.RoomCall)) - ) + analyticsLambda.assertions().isCalledOnce().with(value(MobileScreen.ScreenName.RoomCall)) sendCallNotificationIfNeededLambda.assertions().isCalledOnce() } } diff --git a/features/enterprise/impl/build.gradle.kts b/features/enterprise/impl/build.gradle.kts index fa03bd48e7..5e4ce5c387 100644 --- a/features/enterprise/impl/build.gradle.kts +++ b/features/enterprise/impl/build.gradle.kts @@ -1,3 +1,5 @@ +import extension.setupAnvil + /* * Copyright 2024 New Vector Ltd. * @@ -6,13 +8,14 @@ */ plugins { id("io.element.android-library") - alias(libs.plugins.anvil) } android { namespace = "io.element.android.features.enterprise.impl" } +setupAnvil() + dependencies { implementation(projects.anvilannotations) api(projects.features.enterprise.api) diff --git a/features/ftue/test/build.gradle.kts b/features/ftue/test/build.gradle.kts index 989c3382d6..223b5c855a 100644 --- a/features/ftue/test/build.gradle.kts +++ b/features/ftue/test/build.gradle.kts @@ -1,3 +1,5 @@ +import extension.setupAnvil + /* * Copyright 2024 New Vector Ltd. * @@ -7,7 +9,6 @@ plugins { id("io.element.android-compose-library") - alias(libs.plugins.anvil) id("kotlin-parcelize") } @@ -15,6 +16,8 @@ android { namespace = "io.element.android.features.ftue.test" } +setupAnvil() + dependencies { implementation(projects.features.ftue.api) implementation(projects.tests.testutils) diff --git a/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt b/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt index 45fb2efc86..f194404f8e 100644 --- a/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt +++ b/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt @@ -99,7 +99,7 @@ class AcceptDeclineInvitePresenterTest { InternalAcceptDeclineInviteEvents.ConfirmDeclineInvite ) } - skipItems(1) + skipItems(2) awaitItem().also { state -> assertThat(state.declineAction).isInstanceOf(AsyncAction.Failure::class.java) state.eventSink( @@ -147,7 +147,7 @@ class AcceptDeclineInvitePresenterTest { InternalAcceptDeclineInviteEvents.ConfirmDeclineInvite ) } - skipItems(1) + skipItems(2) awaitItem().also { state -> assertThat(state.declineAction).isInstanceOf(AsyncAction.Success::class.java) } diff --git a/features/joinroom/impl/src/test/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenterTest.kt b/features/joinroom/impl/src/test/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenterTest.kt index 0b2206d6df..0a323122ac 100644 --- a/features/joinroom/impl/src/test/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenterTest.kt +++ b/features/joinroom/impl/src/test/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenterTest.kt @@ -338,11 +338,15 @@ class JoinRoomPresenterTest { awaitItem().also { state -> state.eventSink(JoinRoomEvents.KnockRoom) } + + assertThat(awaitItem().knockAction).isEqualTo(AsyncAction.Loading) awaitItem().also { state -> assertThat(state.knockAction).isEqualTo(AsyncAction.Success(Unit)) fakeKnockRoom.lambda = knockRoomFailure state.eventSink(JoinRoomEvents.KnockRoom) } + + assertThat(awaitItem().knockAction).isEqualTo(AsyncAction.Loading) awaitItem().also { state -> assertThat(state.knockAction).isInstanceOf(AsyncAction.Failure::class.java) } diff --git a/features/licenses/impl/build.gradle.kts b/features/licenses/impl/build.gradle.kts index 36bbd7ef34..9b86cb94a6 100644 --- a/features/licenses/impl/build.gradle.kts +++ b/features/licenses/impl/build.gradle.kts @@ -10,7 +10,6 @@ import extension.setupAnvil plugins { id("io.element.android-compose-library") id("kotlin-parcelize") - alias(libs.plugins.anvil) alias(libs.plugins.kotlin.serialization) } diff --git a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/createaccount/WebViewMessageInterceptor.kt b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/createaccount/WebViewMessageInterceptor.kt index 6dfe903b09..fedc288855 100644 --- a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/createaccount/WebViewMessageInterceptor.kt +++ b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/createaccount/WebViewMessageInterceptor.kt @@ -51,7 +51,7 @@ class WebViewMessageInterceptor( } override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean { - request ?: return super.shouldOverrideUrlLoading(view, request) + request ?: return false // Load the URL in a Chrome Custom Tab, and return true to cancel the load onOpenExternalUrl(request.url.toString()) return true diff --git a/features/migration/impl/build.gradle.kts b/features/migration/impl/build.gradle.kts index 30e1b0c331..c89af9115d 100644 --- a/features/migration/impl/build.gradle.kts +++ b/features/migration/impl/build.gradle.kts @@ -1,3 +1,5 @@ +import extension.setupAnvil + /* * Copyright 2024 New Vector Ltd. * @@ -7,13 +9,14 @@ plugins { id("io.element.android-compose-library") - alias(libs.plugins.anvil) } android { namespace = "io.element.android.features.migration.impl" } +setupAnvil() + dependencies { implementation(projects.features.migration.api) implementation(projects.libraries.architecture) diff --git a/features/roomdirectory/impl/build.gradle.kts b/features/roomdirectory/impl/build.gradle.kts index 6d05cad8e3..3fec2f0bb7 100644 --- a/features/roomdirectory/impl/build.gradle.kts +++ b/features/roomdirectory/impl/build.gradle.kts @@ -9,7 +9,6 @@ import extension.setupAnvil plugins { id("io.element.android-compose-library") - alias(libs.plugins.anvil) id("kotlin-parcelize") } diff --git a/features/verifysession/impl/src/test/kotlin/io/element/android/features/verifysession/impl/VerifySelfSessionPresenterTest.kt b/features/verifysession/impl/src/test/kotlin/io/element/android/features/verifysession/impl/VerifySelfSessionPresenterTest.kt index 0ff24d2254..188c895f5c 100644 --- a/features/verifysession/impl/src/test/kotlin/io/element/android/features/verifysession/impl/VerifySelfSessionPresenterTest.kt +++ b/features/verifysession/impl/src/test/kotlin/io/element/android/features/verifysession/impl/VerifySelfSessionPresenterTest.kt @@ -343,6 +343,7 @@ class VerifySelfSessionPresenterTest { skipItems(1) val initialItem = awaitItem() initialItem.eventSink(VerifySelfSessionViewEvents.SignOut) + assertThat(awaitItem().signOutAction.isLoading()).isTrue() val finalItem = awaitItem() assertThat(finalItem.signOutAction.isSuccess()).isTrue() assertThat(finalItem.signOutAction.dataOrNull()).isEqualTo("aUrl") diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ef9cd5be29..ee18e98f56 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,9 +4,9 @@ [versions] # Project android_gradle_plugin = "8.7.0" -kotlin = "1.9.25" +kotlin = "2.0.20" kotlinpoetKsp = "1.18.1" -ksp = "1.9.25-1.0.20" +ksp = "2.0.20-1.0.25" firebaseAppDistribution = "5.0.0" # AndroidX @@ -62,6 +62,7 @@ kover = "0.8.3" [libraries] # Project android_gradle_plugin = { module = "com.android.tools.build:gradle", version.ref = "android_gradle_plugin" } +compose_compiler_plugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" } # https://developer.android.com/studio/write/java8-support#library-desugaring-versions android_desugar = "com.android.tools:desugar_jdk_libs:2.1.2" anvil_gradle_plugin = { module = "dev.zacsweers.anvil:gradle-plugin", version.ref = "anvil" } @@ -238,3 +239,4 @@ firebaseAppDistribution = { id = "com.google.firebase.appdistribution", version. knit = { id = "org.jetbrains.kotlinx.knit", version = "0.5.0" } sonarqube = "org.sonarqube:5.1.0.4882" licensee = "app.cash.licensee:1.11.0" +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/bottomsheet/CustomSheetState.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/bottomsheet/CustomSheetState.kt index ac02787c3f..694674621a 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/bottomsheet/CustomSheetState.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/bottomsheet/CustomSheetState.kt @@ -7,7 +7,6 @@ package io.element.android.libraries.designsystem.theme.components.bottomsheet -import androidx.compose.animation.core.DecayAnimationSpec import androidx.compose.animation.core.SpringSpec import androidx.compose.animation.core.exponentialDecay import androidx.compose.foundation.ExperimentalFoundationApi @@ -296,13 +295,9 @@ internal object AnchoredDraggableDefaults { /** * The default animation used by [AnchoredDraggableState]. */ - @get:ExperimentalMaterial3Api - @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET") @ExperimentalMaterial3Api val SnapAnimationSpec = SpringSpec() - @get:ExperimentalMaterial3Api - @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET") @ExperimentalMaterial3Api val DecayAnimationSpec = exponentialDecay() } diff --git a/libraries/mediapickers/api/build.gradle.kts b/libraries/mediapickers/api/build.gradle.kts index 24a556d10f..edb9e9263b 100644 --- a/libraries/mediapickers/api/build.gradle.kts +++ b/libraries/mediapickers/api/build.gradle.kts @@ -1,3 +1,5 @@ +import extension.setupAnvil + /* * Copyright 2023, 2024 New Vector Ltd. * @@ -7,9 +9,10 @@ plugins { id("io.element.android-compose-library") - alias(libs.plugins.anvil) } +setupAnvil() + android { namespace = "io.element.android.libraries.mediapickers.api" diff --git a/libraries/mediapickers/test/build.gradle.kts b/libraries/mediapickers/test/build.gradle.kts index 6316465538..689fc0d8eb 100644 --- a/libraries/mediapickers/test/build.gradle.kts +++ b/libraries/mediapickers/test/build.gradle.kts @@ -1,3 +1,5 @@ +import extension.setupAnvil + /* * Copyright 2023, 2024 New Vector Ltd. * @@ -7,9 +9,10 @@ plugins { id("io.element.android-compose-library") - alias(libs.plugins.anvil) } +setupAnvil() + android { namespace = "io.element.android.libraries.mediapickers.test" diff --git a/libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/FakeUnifiedPushNewGatewayHandler.kt b/libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/FakeUnifiedPushNewGatewayHandler.kt index b5083e9da5..838addbca3 100644 --- a/libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/FakeUnifiedPushNewGatewayHandler.kt +++ b/libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/FakeUnifiedPushNewGatewayHandler.kt @@ -10,7 +10,7 @@ package io.element.android.libraries.pushproviders.unifiedpush import io.element.android.tests.testutils.lambda.lambdaError class FakeUnifiedPushNewGatewayHandler( - private val handleResult: suspend (String, String, String) -> Result = { _, _, _ -> lambdaError() }, + private val handleResult: (String, String, String) -> Result = { _, _, _ -> lambdaError() }, ) : UnifiedPushNewGatewayHandler { override suspend fun handle(endpoint: String, pushGateway: String, clientSecret: String): Result { return handleResult(endpoint, pushGateway, clientSecret) diff --git a/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt b/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt index e974fd362b..47c59142ca 100644 --- a/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt +++ b/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt @@ -9,6 +9,7 @@ package io.element.android.libraries.roomselect.impl import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.State import androidx.compose.runtime.collectAsState import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue @@ -22,6 +23,7 @@ import io.element.android.libraries.architecture.Presenter import io.element.android.libraries.designsystem.theme.components.SearchBarResultState import io.element.android.libraries.matrix.ui.model.SelectRoomInfo import io.element.android.libraries.roomselect.api.RoomSelectMode +import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @@ -50,7 +52,7 @@ class RoomSelectPresenter @AssistedInject constructor( val roomSummaryDetailsList by dataSource.roomInfoList.collectAsState(initial = persistentListOf()) - val searchResults by remember { + val searchResults by remember>>> { derivedStateOf { when { roomSummaryDetailsList.isNotEmpty() -> SearchBarResultState.Results(roomSummaryDetailsList.toImmutableList()) diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts index 33d7bb0bd6..2380b204ce 100644 --- a/plugins/build.gradle.kts +++ b/plugins/build.gradle.kts @@ -24,4 +24,5 @@ dependencies { implementation(libs.autonomousapps.dependencyanalysis.plugin) implementation(libs.anvil.gradle.plugin) implementation(libs.ksp.gradle.plugin) + implementation(libs.compose.compiler.plugin) } diff --git a/plugins/src/main/kotlin/extension/CommonExtension.kt b/plugins/src/main/kotlin/extension/CommonExtension.kt index 32e27b516e..4f3f23d707 100644 --- a/plugins/src/main/kotlin/extension/CommonExtension.kt +++ b/plugins/src/main/kotlin/extension/CommonExtension.kt @@ -10,7 +10,6 @@ package extension import Versions import com.android.build.api.dsl.CommonExtension import isEnterpriseBuild -import org.gradle.accessors.dm.LibrariesForLibs import org.gradle.api.Project import java.io.File @@ -44,21 +43,18 @@ fun CommonExtension<*, *, *, *, *, *>.androidConfig(project: Project) { } checkDependencies = false abortOnError = true + ignoreTestSources = true ignoreTestFixturesSources = true checkGeneratedSources = false } } -fun CommonExtension<*, *, *, *, *, *>.composeConfig(libs: LibrariesForLibs) { +fun CommonExtension<*, *, *, *, *, *>.composeConfig() { buildFeatures { compose = true } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.composecompiler.get() - } - packaging { resources.excludes.apply { add("META-INF/AL2.0") diff --git a/plugins/src/main/kotlin/io.element.android-compose-application.gradle.kts b/plugins/src/main/kotlin/io.element.android-compose-application.gradle.kts index 6773164f46..967e4fd707 100644 --- a/plugins/src/main/kotlin/io.element.android-compose-application.gradle.kts +++ b/plugins/src/main/kotlin/io.element.android-compose-application.gradle.kts @@ -19,11 +19,12 @@ plugins { id("com.android.application") id("kotlin-android") id("com.autonomousapps.dependency-analysis") + id("org.jetbrains.kotlin.plugin.compose") } android { androidConfig(project) - composeConfig(libs) + composeConfig() compileOptions { isCoreLibraryDesugaringEnabled = true } diff --git a/plugins/src/main/kotlin/io.element.android-compose-library.gradle.kts b/plugins/src/main/kotlin/io.element.android-compose-library.gradle.kts index 5c6c6a3589..b4d7fe650a 100644 --- a/plugins/src/main/kotlin/io.element.android-compose-library.gradle.kts +++ b/plugins/src/main/kotlin/io.element.android-compose-library.gradle.kts @@ -19,11 +19,12 @@ plugins { id("com.android.library") id("kotlin-android") id("com.autonomousapps.dependency-analysis") + id("org.jetbrains.kotlin.plugin.compose") } android { androidConfig(project) - composeConfig(libs) + composeConfig() compileOptions { isCoreLibraryDesugaringEnabled = true } diff --git a/tests/testutils/src/main/kotlin/io/element/android/tests/testutils/lambda/LambdaRecorder.kt b/tests/testutils/src/main/kotlin/io/element/android/tests/testutils/lambda/LambdaRecorder.kt index c4e5222060..2fa38e04c1 100644 --- a/tests/testutils/src/main/kotlin/io/element/android/tests/testutils/lambda/LambdaRecorder.kt +++ b/tests/testutils/src/main/kotlin/io/element/android/tests/testutils/lambda/LambdaRecorder.kt @@ -7,6 +7,8 @@ package io.element.android.tests.testutils.lambda +import kotlinx.coroutines.runBlocking + /** * A recorder that can be used to record the parameters of lambda invocation. */ @@ -93,21 +95,21 @@ inline fun lambdaAnyRecorder( class LambdaNoParamRecorder(ensureNeverCalled: Boolean, val block: () -> R) : LambdaRecorder(ensureNeverCalled), () -> R { override fun invoke(): R { onInvoke() - return block() + return runBlocking { block() } } } class LambdaOneParamRecorder(ensureNeverCalled: Boolean, val block: (T) -> R) : LambdaRecorder(ensureNeverCalled), (T) -> R { override fun invoke(p: T): R { onInvoke(p) - return block(p) + return runBlocking { block(p) } } } class LambdaTwoParamsRecorder(ensureNeverCalled: Boolean, val block: (T1, T2) -> R) : LambdaRecorder(ensureNeverCalled), (T1, T2) -> R { override fun invoke(p1: T1, p2: T2): R { onInvoke(p1, p2) - return block(p1, p2) + return runBlocking { block(p1, p2) } } } @@ -116,7 +118,7 @@ class LambdaThreeParamsRecorder(ensureNeverCalled: B ), (T1, T2, T3) -> R { override fun invoke(p1: T1, p2: T2, p3: T3): R { onInvoke(p1, p2, p3) - return block(p1, p2, p3) + return runBlocking { block(p1, p2, p3) } } } @@ -125,16 +127,19 @@ class LambdaFourParamsRecorder(ensureNeverCal ), (T1, T2, T3, T4) -> R { override fun invoke(p1: T1, p2: T2, p3: T3, p4: T4): R { onInvoke(p1, p2, p3, p4) - return block(p1, p2, p3, p4) + return runBlocking { block(p1, p2, p3, p4) } } } -class LambdaFiveParamsRecorder(ensureNeverCalled: Boolean, val block: (T1, T2, T3, T4, T5) -> R) : LambdaRecorder( +class LambdaFiveParamsRecorder( + ensureNeverCalled: Boolean, + val block: (T1, T2, T3, T4, T5) -> R, +) : LambdaRecorder( ensureNeverCalled ), (T1, T2, T3, T4, T5) -> R { override fun invoke(p1: T1, p2: T2, p3: T3, p4: T4, p5: T5): R { onInvoke(p1, p2, p3, p4, p5) - return block(p1, p2, p3, p4, p5) + return runBlocking { block(p1, p2, p3, p4, p5) } } } @@ -144,7 +149,7 @@ class LambdaSixParamsRecorder( ) : LambdaRecorder(ensureNeverCalled), (T1, T2, T3, T4, T5, T6) -> R { override fun invoke(p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6): R { onInvoke(p1, p2, p3, p4, p5, p6) - return block(p1, p2, p3, p4, p5, p6) + return runBlocking { block(p1, p2, p3, p4, p5, p6) } } } @@ -154,7 +159,7 @@ class LambdaSevenParamsRecorder R { override fun invoke(p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7): R { onInvoke(p1, p2, p3, p4, p5, p6, p7) - return block(p1, p2, p3, p4, p5, p6, p7) + return runBlocking { block(p1, p2, p3, p4, p5, p6, p7) } } } @@ -164,7 +169,7 @@ class LambdaEightParamsRecorder R { override fun invoke(p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7, p8: T8): R { onInvoke(p1, p2, p3, p4, p5, p6, p7, p8) - return block(p1, p2, p3, p4, p5, p6, p7, p8) + return runBlocking { block(p1, p2, p3, p4, p5, p6, p7, p8) } } } @@ -174,7 +179,7 @@ class LambdaNineParamsRecorder R { override fun invoke(p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7, p8: T8, p9: T9): R { onInvoke(p1, p2, p3, p4, p5, p6, p7, p8, p9) - return block(p1, p2, p3, p4, p5, p6, p7, p8, p9) + return runBlocking { block(p1, p2, p3, p4, p5, p6, p7, p8, p9) } } } diff --git a/tools/detekt/detekt.yml b/tools/detekt/detekt.yml index 263b2e9683..1e73ef425d 100644 --- a/tools/detekt/detekt.yml +++ b/tools/detekt/detekt.yml @@ -3,7 +3,7 @@ style: AlsoCouldBeApply: active: true - OptionalWhenBraces: + BracesOnWhenStatements: active: false CascadingCallWrapping: active: true diff --git a/tools/lint/lint.xml b/tools/lint/lint.xml index 57b2ab0750..6596246383 100644 --- a/tools/lint/lint.xml +++ b/tools/lint/lint.xml @@ -117,4 +117,9 @@ + + + + +