Pierre Villard created NIFI-15420:
-------------------------------------

             Summary: Add checkstyle rule for import ordering
                 Key: NIFI-15420
                 URL: https://issues.apache.org/jira/browse/NIFI-15420
             Project: Apache NiFi
          Issue Type: Task
          Components: Tools and Build
            Reporter: Pierre Villard
            Assignee: Pierre Villard


While this requires a large number of changes, this will put us in a much 
better position going forward avoiding PRs where imports may have been 
automatically re-ordered because of the IDE settings.

I checked many possible configurations to find something that is both 
useful/legit and not raising a crazy number of violations (this config is about 
11k violations, when the Google Style rule is 30k+ violations).

I'm suggesting this rule:
{code:xml}
<module name="CustomImportOrder">
    <property name="customImportOrderRules" 
value="THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE###STATIC"/>
    <property name="sortImportsInGroupAlphabetically" value="true"/>
    <property name="separateLineBetweenGroups" value="true"/>
    <property name="standardPackageRegExp" value="^(java|javax)\."/>
</module>{code}
And I am also using a maven plugin to help with most of the work (it still 
needs small manual updates after that)
{code:java}
mvn net.revelc.code:impsort-maven-plugin:1.12.0:sort \
  -Dimpsort.staticGroups='*' \
  -Dimpsort.groups='*,java.,javax.' \
  -Dimpsort.staticAfter=true \
  -DskipTests=true {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to