Implementing an enum that is stateful is widely considered to be bad practice and even outright dangerous (at the very least, it's a violation of the principle of least astonishment). I can't seem to find a FindBugs pattern that warns about this.
The easiest check would probably be to ensure that fields within enums are always declared final. An alternative approach would allow non-final fields (e.g. for implementing lazy instantiation), but complain about setters (which I found in one project - unused, but obviously added/generated accidently).
Log in to post a comment.