ImportOrder should ignore grouping order in static group as option #12

Closed
romani opened this Issue Oct 5, 2013 · 3 comments

4 participants

@romani
Member
romani commented Oct 5, 2013

Created: 2013-08-16
Creator: David Harkness

http://checkstyle.sourceforge.net/config_imports.html#ImportOrder

When you specify package groupings inside ImportOrder, that same ordering is applied to the single group of static imports. Eclipse's Organize Imports feature, however, sorts all static imports alphabetically within a single group--ignoring the package grouping order. There's no way to synchronize the behavior between the two tools.

For example, using "org,java" produces this in Eclipse:

import static java.Math.abs;
import static org.foo.Bar.*;

import org.foo.Foo;

import java.util.Set;

For maximum flexibility, add an option to control whether or not the static imports (when grouped using "top" and "bottom" option) are sorted normally or according to the package groupings.

PS:
Or perhaps it wants the two static imports above to be separated into groups as well. I cannot tell from the error message. So please make message more exact.

@dharkness

To clarify, when static imports are grouped into a single block of text without any empty lines between them, I want them to be sorted alphabetically rather than in the package order. In the example above, java comes before org in the static import group even though regular imports are grouped with org before java due to the package ordering rules.

Right now Checkstyle wants this:

import static org.foo.Bar.*;
import static java.Math.abs;

import org.foo.Foo;

import java.util.Set;

but I want it to match Eclipse (above)--or better an option because I think others may want the current behavior.

@radai-rosenblatt

just found this issue after failing to reconcile checkstyle and eclipse and wanted to say "me too"

@alexkravin alexkravin was assigned by romani Mar 12, 2015
@alexkravin alexkravin added a commit to alexkravin/checkstyle that referenced this issue Mar 13, 2015
@alexkravin alexkravin Import Order Check, added option allows alphabetical grouping order i…
…n static group, issue #12
b40e224
@alexkravin alexkravin added a commit to alexkravin/checkstyle that referenced this issue Mar 13, 2015
@alexkravin alexkravin Import Order Check, added option allows alphabetical grouping order i…
…n static group, issue #12
bcf8817
@alexkravin alexkravin added a commit to alexkravin/checkstyle that referenced this issue Mar 15, 2015
@alexkravin alexkravin Import Order Check, added option allows alphabetical grouping order i…
…n static group, issue #12
248ad5c
@alexkravin alexkravin added a commit to alexkravin/checkstyle that referenced this issue Mar 15, 2015
@alexkravin alexkravin Import Order Check, added option allows alphabetical grouping order i…
…n static group, issue #12
7720619
@alexkravin alexkravin added a commit to alexkravin/checkstyle that referenced this issue Mar 15, 2015
@alexkravin alexkravin Import Order Check, added option allows alphabetical grouping order i…
…n static group, issue #12
1f0caa5
@alexkravin alexkravin added a commit to alexkravin/checkstyle that referenced this issue Mar 16, 2015
@alexkravin alexkravin Import Order Check, added option allows alphabetical grouping order i…
…n static group, issue #12
9b02ca1
@alexkravin alexkravin added a commit to alexkravin/checkstyle that referenced this issue Mar 16, 2015
@alexkravin alexkravin Import Order Check, added option allows alphabetical grouping order i…
…n static group, issue #12
0d2f737
@alexkravin alexkravin added a commit to alexkravin/checkstyle that referenced this issue Mar 16, 2015
@alexkravin alexkravin Import Order Check, added option allows alphabetical grouping order i…
…n static group, issue #12
5c54c8c
@alexkravin alexkravin added a commit to alexkravin/checkstyle that referenced this issue Mar 16, 2015
@alexkravin alexkravin Import Order Check, added option allows alphabetical grouping order i…
…n static group, issue #12
a3a99f9
@romani
Member
romani commented Mar 17, 2015

fixed, will be in 6.5

@romani romani closed this Mar 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment