Skip to content

Commit e52c7ee

Browse files
authored
Merge pull request #3371 from element-hq/renovate/com.lemonappdev-konsist-0.x
Update dependency com.lemonappdev:konsist to v0.16.1
2 parents bb1122d + 154114b commit e52c7ee

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ test_arch_core = "androidx.arch.core:core-testing:2.2.0"
139139
test_junit = "junit:junit:4.13.2"
140140
test_runner = "androidx.test:runner:1.6.2"
141141
test_mockk = "io.mockk:mockk:1.13.12"
142-
test_konsist = "com.lemonappdev:konsist:0.15.1"
142+
test_konsist = "com.lemonappdev:konsist:0.16.1"
143143
test_turbine = "app.cash.turbine:turbine:1.1.0"
144144
test_truth = "com.google.truth:truth:1.4.4"
145145
test_parameter_injector = "com.google.testparameterinjector:test-parameter-injector:1.17"

tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistArchitectureTest.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,15 @@ class KonsistArchitectureTest {
8282
return@all if (type.startsWith("@") || type.startsWith("(") || type.startsWith("suspend")) {
8383
true
8484
} else {
85-
val fullyQualifiedName = param.type.declaration.packagee?.fullyQualifiedName + "." + type
85+
var typePackage = param.type.declaration.packagee?.name
86+
if (typePackage == type) {
87+
// Workaround, now that packagee.fullyQualifiedName is not available anymore
88+
// It seems that when the type in in the same package as the function,
89+
// the package is equal to the type (which is wrong).
90+
// So in this case, use the package of the function
91+
typePackage = it.packagee?.name
92+
}
93+
val fullyQualifiedName = "$typePackage.$type"
8694
fullyQualifiedName !in forbiddenInterfacesForComposableParameter
8795
}
8896
}

tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ class KonsistClassNameTest {
7474
.replace("FakeRust", "")
7575
.replace("Fake", "")
7676
(it.name.startsWith("Fake") || it.name.startsWith("FakeRust")) &&
77-
it.parents().any { parent -> parent.name.replace(".", "") == interfaceName }
77+
it.parents().any { parent ->
78+
// Workaround to get the parent name. For instance:
79+
// parent.name used to return `UserListPresenter.Factory` but is now returning `Factory`.
80+
// So we need to retrieve the name of the parent class differently.
81+
val packageName = parent.packagee!!.name
82+
val parentName = parent.fullyQualifiedName!!.substringAfter("$packageName.").replace(".", "")
83+
parentName == interfaceName
84+
}
7885
}
7986
}
8087

0 commit comments

Comments
 (0)