carp.core-kotlin
carp.core-kotlin copied to clipboard
Use static checker for Immutable base classes
Right now, immutability of extending classes of several base classes in carp.core is enforced at runtime by extending from an Immutable base class which verifies the correctness of the implementation at runtime.
However, since, we have introduced a static checker (detekt) into the project, and we could use a detekt plugin instead to verify whether extending classes of base classes annotated as @Immutable are implemented correctly. This would also allow us to remove the full kotlin.reflect dependency from carp.core.
The question does arise how we can/should enforce external libraries from applying this plugin. But, overall, an 'immutable class' static checker might be useful to a larger community than just CARP users, so placing this public elsewhere as open source might engage others to maintain/test it.
This would simultaneously solve https://github.com/cph-cachet/carp.core-kotlin/issues/18, since the static checker runs on multiplatform code.
Basic work for this was started on https://github.com/cph-cachet/carp.core-kotlin/tree/immutability-detekt
This is now integrated on develop (https://github.com/cph-cachet/carp.core-kotlin/pull/149), but still needs testing/documentation for use by extending libraries.