我测试了自定义的checkstyle.xml并试图设置导入顺序,这是我的代码:
<module name="CustomImportOrder">
<property name="customImportOrderRules" value="STATIC###STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE"/>
<property name="thirdPartyPackageRegExp" value="^(org|net|com)\."/>
<property name="standardPackageRegExp" value="^(java|javax)\."/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
</module>
现在在我的代码中,我有3个导入项:
import java.util.List;
import com.rs.ws.config.ApplicationSettings;
import com.rs.ws.config.ApplicationSettingsRegistry;
当我运行“ mvn clean test”时,它抱怨检查样式违反:
CustomImportOrder: Import statement for 'java.util.List' is in the wrong order. Should be in the 'STANDARD_JAVA_PACKAGE' group, expecting not assigned imports on this line.
我一直在java.util和com.rs.ws的import之间添加更多行或减少行,但仍然引发了同样的抱怨。是因为checkstyle需要静态导入,但是代码中没有静态导入,所以checkstyle认为java.util.List位于静态导入位置中?我该如何解决?