carp.core-kotlin icon indicating copy to clipboard operation
carp.core-kotlin copied to clipboard

Use static checker for Immutable base classes

Open Whathecode opened this issue 5 years ago • 2 comments

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.

Whathecode avatar Jan 24 '20 10:01 Whathecode

Basic work for this was started on https://github.com/cph-cachet/carp.core-kotlin/tree/immutability-detekt

Whathecode avatar Feb 18 '20 15:02 Whathecode

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.

Whathecode avatar Aug 18 '20 21:08 Whathecode