[hibernate-dev] [SEARCH] Code style - imports

Yoann Rodiere yoann at hibernate.org
Tue Sep 12 03:42:01 EDT 2017


Hello all,

I just noticed that our IDEA codestyle configuration files have specific
rules about how to organize imports, whereas the Eclipse ones don't.
The most noticeable difference: organizing imports in Eclipse puts static
imports at the top, while in IDEA they end up at the bottom. But there are
other differences.
The Hibernate ORM codebase doesn't seem affected by these inconsistencies
(probably because most people working on it use IDEA), but in Hibernate
Search we've already reached the point where half of our files follow one
convention, and the other half follows the other.

What's annoying here is not the inconsistencies themselves (I could live
with that), it's more that in the long run we'll end up with tons of
unnecessary changes in our commits, due to one person using IDEA to edit a
file last edited with Eclipse, and vice-versa.

To make the matter worse, Eclipse is not as flexible as IDEA, and we cannot
configure Eclipse to match the IDEA style exactly. In particular, we cannot
configure where the static imports must go: they will always go to the top (
https://bugs.eclipse.org/bugs/show_bug.cgi?id=304415).

I can see two ways out, each with its own drawbacks:

   - Switch to the "Eclipse" style, and create a Search-specific IDEA code
   style configuration, with static imports at the top. We won't be consistent
   with Hibernate ORM, though.
   - Switch to the "IDEA" style, and create a Search-specific Eclipse code
   style configuration, as close as the IDEA style as possible. As I said
   above, automatic import organizing in Eclipse will never follow this style
   exactly, so it's likely to make organizing imports in Eclipse quite
   painful. We could add checkstyle rules to make sure we strictly follow the
   style even in Eclipse.

WDYT?


Yoann Rodière
Hibernate NoORM Team
yoann at hibernate.org


More information about the hibernate-dev mailing list