Do you people know of any equivalent of <ArchUnit>...
# announcements
m
Do you people know of any equivalent of ArchUnit for Kotlin? I couldn’t find one. The closest I found is this detekt plugin which checks a few design principles but it’s not the same thing.
w
Since it works on bytecode, it should more or less work with Kotlin. But is there specific support for e.g. sealed classes, data classes etc.?
k
hm curious what rules would you apply?
only dataclasses in this package?
w
Purely hypothetical as I don’t use ArchUnit, but having only data classes in a specific package/module would make sense, I think
Or for example, if possible, I’d like to check that certain classes’ public methods only return data classes or sealed classes. But that’d plain don’t work with Java classes so it’d be pretty tricky
m
Thanks for the info, I’ll check it out if I can make ArchUnit work for a new project.
@wasyl since ArchUnit allows creating custom rules, maybe there could be a way to identify a Kotlin construct inside bytecode, I don’t know specifically… maybe a data class could be annotated at compile time?
w
Nice find, perhaps just Kotlin Reflection can be used to read the metadata?
m
Not completely sure but the docs say that the core-domain API builds upon reflection and extends it with information on interactions between classes. Perhaps from Kotlin it can reflect on its constructs through this API…I’ll definitely have to try it out!