[Java] Check orderings of imports

Why:

  • Keep imports in specific orders and groups minimize code changes.

Checkstyle has similar rule, which can be implemented in sonar.
https://checkstyle.sourceforge.io/config_imports.html#ImportOrder

Hello Slawomir,

I’m a bit doubtful about such rule. To me, import order is mainly a question of shared IDE configuration, which should be spread across a development team.

Looking at the checkstyle rule, and reflecting about the problem it tries to handle, there is also so many ordering possibility that such rule could became a nightmare to configure… Which goes against the principle of simple and easy rules that we try hard to enforce. I also feel that a simpler implementation would most probably satisfy only a small minority of our users…

Finally, without much traction and freedback from others, we probably won’t implement such rule as of today.

Cheers,
Michael

2 Likes