Uploaded image for project: 'Maven Checkstyle Plugin'
  1. Maven Checkstyle Plugin
  2. MCHECKSTYLE-413

Not grouping according to CustomImportOrder

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 3.1.2
    • None
    • checkstyle:check
    • Windows 10

    Description

      I'm experiencing issues with getting CustomImportOrder working properly. I have theese imports

      import se.pkg1.pkgA.pkgX.SomeClass1 // #1
      import se.pkg1.pkgA.pkgX.SomeClass2 // #2
       
      import se.pkg1.pkgB.pkgNotX.SomeClassX // #3

       
      My CustomImportOrder definition looks like this:

      <module name="CustomImportOrder">
                  <property name="severity" value="error"/>
                  <property name="customImportOrderRules"                      value="STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS###SAME_PACKAGE(3)###STATIC"/>
                  <property name="standardPackageRegExp" value="java|javax|jakarta"/>
                  <property name="thirdPartyPackageRegExp" value="se.pkg1.pkgA"/>
                  <property name="specialImportsRegExp" value="se.pkg1"/>
                  <property name="sortImportsInGroupAlphabetically" value="true"/>
                  <property name="separateLineBetweenGroups" value="true"/>
              </module> 

      My interpretation and also how the IntelliJ Checkstyle plugin order the imports is that packages in se.pkg1.pkgA falls within THIRD_PARTY_PACKAGE and so #1 and #2 above is grouped together. 
       
      #3 on the other hand falls within SPECIAL_IMPORTS and should be grouped separate, below THIRD_PARTY_PACKAGE. The problem is though that if I import checkstyle config in IntelliJ java imports it seem to work as expected but when I run the 
      maven-checkstyle-plugin it think all three imports should belong to the same group as this:

      import se.pkg1.pkgB.pkgNotX.SomeClassX // #3
      import se.pkg1.pkgA.pkgX.SomeClass1 // #1
      import se.pkg1.pkgA.pkgX.SomeClass2 // #2

      Shouldn't the plugin order the imports like in my first listing (#1,2, 3) in the post?

      Attachments

        Activity

          People

            Unassigned Unassigned
            b.lindahl Björn Lindahl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: