Merge pull request #5420 from element-hq/feature/bma/metroAssistedInject
Ensure Metro `@AssistedInject` is used.
This commit is contained in:
commit
22aeac664b
14 changed files with 127 additions and 54 deletions
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.tests.konsist
|
||||
|
||||
import com.lemonappdev.konsist.api.Konsist
|
||||
import com.lemonappdev.konsist.api.ext.list.withAnnotationOf
|
||||
import com.lemonappdev.konsist.api.ext.list.withParameter
|
||||
import com.lemonappdev.konsist.api.verify.assertTrue
|
||||
import dev.zacsweers.metro.Assisted
|
||||
import dev.zacsweers.metro.Inject
|
||||
import org.junit.Test
|
||||
|
||||
class KonsistDiTest {
|
||||
@Test
|
||||
fun `class annotated with @Inject should not have constructors with @Assisted parameter`() {
|
||||
Konsist
|
||||
.scopeFromProject()
|
||||
.classes()
|
||||
.withAnnotationOf(Inject::class)
|
||||
.assertTrue(
|
||||
additionalMessage = "Class with @Assisted parameter in constructor should be annotated with @AssistedInject and not @Inject"
|
||||
) { classDeclaration ->
|
||||
classDeclaration.constructors
|
||||
.withParameter { parameterDeclaration ->
|
||||
parameterDeclaration.hasAnnotationOf(Assisted::class)
|
||||
}
|
||||
.isEmpty()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:96a867cb12498cbdc97957bee07855dfaa13602baddaf933aff2b666ef4c7650
|
||||
size 3642
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5bb36ccd718f3fec5b04f1bc812dc7718b5ea7fa4619c8b031466297a8d016fd
|
||||
size 3659
|
||||
Loading…
Add table
Add a link
Reference in a new issue