https://kotlinlang.org logo
#konsist
Title
# konsist
p

PoisonedYouth

09/21/2023, 7:09 AM
Ich have the following assertion for the architecture inside a single module:
Copy code
Konsist.scopeFromProduction()
   .assertArchitecture {
       val domain = Layer("domain", "com.poisonedyouth.example.domain..")
       val adapter = Layer("adapter", "com.poisonedyouth.example.adapter..")
       val port = Layer("port", "com.poisonedyouth.example.port..")
       val common = Layer("common", "com.poisonedyouth.example.common..")

       port.dependsOn(domain)
       adapter.dependsOn(port)
       adapter.dependsOn(common)
       domain.dependsOnNothing()
}
The result when running the test:
Copy code
java.util.NoSuchElementException: List is empty.
	at kotlin.collections.CollectionsKt___CollectionsKt.last(_Collections.kt:418)
	at com.lemonappdev.konsist.core.architecture.DependencyRulesCore.checkCircularDependenciesHelper(DependencyRulesCore.kt:126)
	at com.lemonappdev.konsist.core.architecture.DependencyRulesCore.checkCircularDependencies(DependencyRulesCore.kt:79)
	at com.lemonappdev.konsist.core.architecture.DependencyRulesCore.dependsOn(DependencyRulesCore.kt:17)
I think a more clear exception message will help for searching for the problem.
I just learned that the problem is:
Copy code
adapter.dependsOn(port)
 adapter.dependsOn(common)
this does not work. Using the below is working as expected:
Copy code
adapter.dependsOn(common, port)
i

igor.wojda

09/21/2023, 7:40 PM
Thx for reporting and a follow up. It looks like a big on our side - we will investigate it, both the bug and error messages. Can you prepare a sample project? This would speed up things.
p

PoisonedYouth

09/22/2023, 6:13 AM
Yes I will try. Because this is productive Code that I cannot share I need to extract the parts to reproduce it.
i

igor.wojda

09/22/2023, 11:59 AM
I understand completely. In such scenarios I typicallyI take a production project, make a copy of it, remove a bit and make sure that bug still exists. I repeat 🔁 this until I will get the minimal sample project (or at least sample that does not contain any confidential company source code. Unfortunately we have not been able to reproduce this issue, so ATM your sample project is a must have for us to fix this 🐛. BTW This has spiked the idea for me 💡 - write a tool that keeps project structure, but removes bodies from all of the methods - in most cases this should be enough to strip all confidential company source code and create sample project quickly.
p

PoisonedYouth

09/22/2023, 2:02 PM
This is a minimized sample that is showing the expected failure. Just run the test in com.poisonedyouth.taskk.task.konsist.Architecture
👍 2
i

igor.wojda

09/22/2023, 9:02 PM
Thx we will take a look
p

PoisonedYouth

09/25/2023, 2:57 PM
Perfekt. Will update my version