diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 71c14876ff..b183621d1f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -139,7 +139,7 @@ test_arch_core = "androidx.arch.core:core-testing:2.2.0" test_junit = "junit:junit:4.13.2" test_runner = "androidx.test:runner:1.6.2" test_mockk = "io.mockk:mockk:1.13.12" -test_konsist = "com.lemonappdev:konsist:0.15.1" +test_konsist = "com.lemonappdev:konsist:0.16.1" test_turbine = "app.cash.turbine:turbine:1.1.0" test_truth = "com.google.truth:truth:1.4.4" test_parameter_injector = "com.google.testparameterinjector:test-parameter-injector:1.17" diff --git a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistArchitectureTest.kt b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistArchitectureTest.kt index fa1b3f415c..7cc848d825 100644 --- a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistArchitectureTest.kt +++ b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistArchitectureTest.kt @@ -82,7 +82,15 @@ class KonsistArchitectureTest { return@all if (type.startsWith("@") || type.startsWith("(") || type.startsWith("suspend")) { true } else { - val fullyQualifiedName = param.type.declaration.packagee?.fullyQualifiedName + "." + type + var typePackage = param.type.declaration.packagee?.name + if (typePackage == type) { + // Workaround, now that packagee.fullyQualifiedName is not available anymore + // It seems that when the type in in the same package as the function, + // the package is equal to the type (which is wrong). + // So in this case, use the package of the function + typePackage = it.packagee?.name + } + val fullyQualifiedName = "$typePackage.$type" fullyQualifiedName !in forbiddenInterfacesForComposableParameter } } diff --git a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt index 797f13dbe8..4257599019 100644 --- a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt +++ b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt @@ -74,7 +74,14 @@ class KonsistClassNameTest { .replace("FakeRust", "") .replace("Fake", "") (it.name.startsWith("Fake") || it.name.startsWith("FakeRust")) && - it.parents().any { parent -> parent.name.replace(".", "") == interfaceName } + it.parents().any { parent -> + // Workaround to get the parent name. For instance: + // parent.name used to return `UserListPresenter.Factory` but is now returning `Factory`. + // So we need to retrieve the name of the parent class differently. + val packageName = parent.packagee!!.name + val parentName = parent.fullyQualifiedName!!.substringAfter("$packageName.").replace(".", "") + parentName == interfaceName + } } }