[hibernate-dev] Beyond checkstyle

Sanne Grinovero sanne at hibernate.org
Tue May 26 06:01:00 EDT 2020


Hi all,

in Quarkus we're using a plugin which automatically reformats the code
and sorts imports.

In our older projects we've been using checkstyle; the goal has always
been to try to avoid conflicts and improve readability, but to try to
impose such consistency typically leads to a significant annoyance and
waste of time during development - so imposing checkstyle hans't been
very popular, and certainly comes at a cost.

So the idea in Quarkus has this nice effect: rather than getting "in
the way" it uses a plugin which automatically fixes the code, one
needs to just add the further changes to version control (CI can be
setup to fail rather than fix). The plugin used by Quarkus have some
drawbacks though: the code style can't be configured, and it happens
to look very different than the Hibernate conventions so I don't think
it would be useful for us.

With Hibernate Reactive I started now to explore a new tool which looks better:
 - https://github.com/hibernate/hibernate-reactive/pull/191/commits/c7c47c4c990da945e6058631a2eddfdb06ca7e05

This one is rather flexible and configurable, great support for
Gradle, and can also be set to automatically fix the code rather than
complain.

We're going to use it on Hibernate Reactive to enforce only some
essentials: license headers, remove unused imports, remove end-of-line
whitespace.  I suppose we could start using it for some more advanced
rules later, but I'd be cautious about it. One high on my list of
wishlist is to have imports sorted in a standard way, as that's
another source of totally pointless, annoying conflicts.

Other projects might want to explore using it as well?

It supposedly supports Maven as well; haven't tests it though.
See:
 - https://github.com/diffplug/spotless

Thanks


More information about the hibernate-dev mailing list