PoisonedYouth
09/21/2023, 12:02 PMKonsist.scopeFromProduction(moduleName = module)
.classes()
.withPackage("com.poisonedyouth.example.adapter..")
.assert {
it.primaryConstructor!!.parameters.all { parameter ->
// Check that it is only an interface type
}
}
Natalia Peterwas
09/21/2023, 12:25 PMval interfaces = Konsist
.scopeFromProduction()
.interfaces()
.map { it.name }
Konsist.scopeFromProduction()
.classes()
.withPackage("com.poisonedyouth.example.adapter..")
.assert {
it.primaryConstructor!!.parameters.all { parameter ->
parameter.hasType { type ->
interfaces.any { interfaceName ->
type.sourceType == interfaceName
}
}
}
}
But we have a ticket to add a “complex references” - types will return actual instance of KoDeclaration, not a string. This will give is way to check if given type is class or an interface. ATM it may be hard to achieve.PoisonedYouth
09/21/2023, 12:37 PMigor.wojda
09/21/2023, 8:00 PMPoisonedYouth
09/22/2023, 6:11 AM