Hi Oscar,

On Thu, Sep 26, 2024 at 3:56 PM Oscar Westra van Holthe - Kind <
opw...@apache.org> wrote:

> Hi,
>
> In a recent PR, the order of imports came up as a discussion point. The
> reason behind this is that it’s not always possible to not sort imports.
> Added to that, we do have some rules w.r.t. imports for people that read
> code directly, for example to never use * imports.
>
> As noted in the PR, choosing any import order will change at least half of
> all source files:
> https://github.com/apache/avro/pull/3150#discussion_r1773516333
>
> To solve the issue, and prevent unnecessary changes in PRs, I propose to
> fix the order of imports.
>
> As I see it, there are two “easy” options:
> 1. Use the default order imposed by the spotless plugin (two groups,
> static first, each ordered lexicographically)
> 2. The same, but sort JDK imports (the java/javax packages) separately in
> a third group
>

3. Do not optimize the imports

In Intellij IDEA > Settings
   > Tools > Actions on Save > uncheck "Reformat" and "Optimize imports"
   > Editor > General > Auto Import > uncheck "Optimize imports on the fly"

I do not touch the Java code much lately so you could totally ignore my
preference but in my experience the best is to not led the IDE to
format/optimize lines which are not manually changed. This just makes the
code review much harder (especially the re-formatting).

Martin


> Do you have a preference?
>
>
> Kind regards,
> Oscar
>
> --
> Oscar Westra van Holthe - Kind <opw...@apache.org>
>
>

Reply via email to