[Hawkular-dev] Import order

Peter Palaga ppalaga at redhat.com
Mon Aug 3 08:56:40 EDT 2015


Status update: There is a PR [1] open in build tools to introduce the 
Import order Checkstyle rule with the next version of HK Parent.

Please protest loudly if you disagree.

I have sent PRs fixing the import order to some components repos:
Hawkular: https://github.com/hawkular/hawkular/pull/384
Alerts: https://github.com/hawkular/hawkular-alerts/pull/79
Metrics: https://github.com/hawkular/hawkular-metrics/pull/296
Inventory: https://github.com/hawkular/hawkular-inventory/pull/135

While ordering the imports using Eclipse in the above projects, I have 
found only one subtle mismatch between Eclipse and checkstyle: Here 
https://github.com/hawkular/hawkular-metrics/blob/2062a0a63e3d4a9eb22f77a79e082324d3b166a1/core/metrics-core-api/src/test/java/org/hawkular/metrics/core/api/IntervalTest.java#L19-L22

Eclipse wants

import static org.hawkular.metrics.core.api.Interval.parse;
import static org.hawkular.metrics.core.api.Interval.Units.DAYS;
import static org.hawkular.metrics.core.api.Interval.Units.HOURS;
import static org.hawkular.metrics.core.api.Interval.Units.MINUTES;

While Checkstyle wants

import static org.hawkular.metrics.core.api.Interval.Units.DAYS;
import static org.hawkular.metrics.core.api.Interval.Units.HOURS;
import static org.hawkular.metrics.core.api.Interval.Units.MINUTES;
import static org.hawkular.metrics.core.api.Interval.parse;

There was just one occurrence of this problem and I hope that we can 
neglect it.

Thanks,

Peter

[1] https://github.com/hawkular/hawkular-build-tools/pull/21

On 2015-06-17 09:11, Peter Palaga wrote:
> OK, I'll add the import order check to checkstyle.
> https://issues.jboss.org/browse/HAWKULAR-358 -- P
>
> On 16/06/15 12:14, Thomas Segismont wrote:
>> Le 16/06/2015 11:50, Peter Palaga a écrit :
>>> Hi Mazz,
>>>
>>> While I can remember some basic discussion about the order Java imports,
>>> I do not remember at all what was the result.
>>>
>>> I saw that you added Eclipse prefs for import order to dev tools which
>>> is definitely good
>>> https://github.com/hawkular/hawkular-build-tools/blob/master/ide-configs/eclipse/hawkular-eclipse-preferences-java-codestyle-organizeimports.importorder
>>>
>>> Do Idea prefs contain the same settings?
>>
>> Yes, they were built by Lucas and reviewed by me.
>>
>>>
>>> Are there projects using these settings consequently?
>>
>> All projects _should_ be using the same.
>>
>>>
>>> But did we say we would enforce the imports order by checkstyle?
>>
>> We didn't talk about that.
>>
>> I have recently commented on GitHub that import order was the only thing
>> not checked yet, and we keep on seeing PR with many lines of import
>> order differences.
>>
>> To me, it shows that formatting rules, if not enforced, are not
>> naturally observed.
>>
>>> They have a rule for that:
>>> http://checkstyle.sourceforge.net/config_imports.html#ImportOrder
>>
>> +1 for adding
>>
>>>
>>> Its a pity that we have not done it earlier.
>>>
>>> Thanks,
>>>
>>> Peter
>>> _______________________________________________
>>> hawkular-dev mailing list
>>> hawkular-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/hawkular-dev
>>>
>>
>> _______________________________________________
>> hawkular-dev mailing list
>> hawkular-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hawkular-dev
>>
>
> _______________________________________________
> hawkular-dev mailing list
> hawkular-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hawkular-dev
>



More information about the hawkular-dev mailing list