You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Björn Lindahl (Jira)" <ji...@apache.org> on 2022/05/15 12:04:00 UTC

[jira] [Updated] (MCHECKSTYLE-413) Not grouping according to CustomImportOrder

     [ https://issues.apache.org/jira/browse/MCHECKSTYLE-413?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Björn Lindahl updated MCHECKSTYLE-413:
--------------------------------------
    Description: 
I'm experiencing issues with getting _CustomImportOrder_ working properly. I have theese imports
{quote}import se.pkg1.pkgA.pkgX.SomeClass1 // #1
import se.pkg1.pkgA.pkgX.SomeClass2 // #2
 
import se.pkg1.pkgB.pkgNotX.SomeClassX // #3
{quote}
 
My CustomImportOrder definition looks like this:
{quote}<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> 
{quote}
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:
{quote}import se.pkg1.pkgB.pkgNotX.SomeClassX // #3
import se.pkg1.pkgA.pkgX.SomeClass1 // #1
import se.pkg1.pkgA.pkgX.SomeClass2 // #2
{quote}
Shouldn't the plugin order the imports like in my first listing (#1,2, 3) in the post?

  was:
I'm experiencing issues with getting _CustomImportOrder_ working properly. I have theese imports
{quote}import se.pkg1.pkgA.pkgX.SomeClass1 // #1
import se.pkg1.pkgA.pkgX.SomeClass2 // #2
 
import se.pkg1.pkgB.pkgNotX.SomeClassX // #3{quote}
 
My CustomImportOrder definition looks like this:
{quote}<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> {quote}
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:
{quote}import se.pkg1.pkgB.pkgNotX.SomeClassX // #3
import se.pkg1.pkgA.pkgX.SomeClass1 // #1
import se.pkg1.pkgA.pkgX.SomeClass2 // #2{quote}
Shouldn't the plugin order the imports like in my first listing in the post?


> Not grouping according to CustomImportOrder
> -------------------------------------------
>
>                 Key: MCHECKSTYLE-413
>                 URL: https://issues.apache.org/jira/browse/MCHECKSTYLE-413
>             Project: Maven Checkstyle Plugin
>          Issue Type: Bug
>          Components: checkstyle:check
>    Affects Versions: 3.1.2
>         Environment: Windows 10
>            Reporter: Björn Lindahl
>            Priority: Major
>              Labels: import
>
> I'm experiencing issues with getting _CustomImportOrder_ working properly. I have theese imports
> {quote}import se.pkg1.pkgA.pkgX.SomeClass1 // #1
> import se.pkg1.pkgA.pkgX.SomeClass2 // #2
>  
> import se.pkg1.pkgB.pkgNotX.SomeClassX // #3
> {quote}
>  
> My CustomImportOrder definition looks like this:
> {quote}<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> 
> {quote}
> 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:
> {quote}import se.pkg1.pkgB.pkgNotX.SomeClassX // #3
> import se.pkg1.pkgA.pkgX.SomeClass1 // #1
> import se.pkg1.pkgA.pkgX.SomeClass2 // #2
> {quote}
> Shouldn't the plugin order the imports like in my first listing (#1,2, 3) in the post?



--
This message was sent by Atlassian Jira
(v8.20.7#820007)