Suppressing Checkstyle import order issue

Hello!

I’m trying to follow checkstyle documentation for configuring ImportOrder check to work the same as Intellij IDEA default import order.

What happens is we get code smells like 'java.util.Objects' should be separated from previous imports..

When I download our checkstyle configuration directly from Sonar, I can see:

<module name="ImportOrder">
    <property name="severity" value="info"/>
    <property name="ordered" value="true"/>
    <property name="sortStaticImportsAlphabetically" value="true"/>
    <property name="useContainerOrderingForStatic" value="false"/>
    <property name="caseSensitive" value="true"/>
    <property name="separated" value="true"/>
    <property name="groups" value="*,javax,java"/>
    <property name="tokens" value="STATIC_IMPORT"/>
    <property name="separatedStaticGroups" value="false"/>
    <property name="option" value="bottom"/>
</module>

and

<module name="SuppressionXpathSingleFilter">
    <property name="checks" value="ImportOrder"/>
    <property name="message" value="^'java\..*'.*"/>
</module>

The SuppressionXpathSingleFilter should suppress smell we receive.

I’ve tried to run checkstyle locally (using checkstyle configuration downloaded from Sonar) and I get 0 errors. When I remove SuppressionXpathSingleFilter, I get same errors as Sonar.

Versions:

  • SonarQube: 6.7.6 (build 38781)
  • sonar-checkstyle: 8.21

Let me know if you have any questions about our issue.

Tnx! :slight_smile:

You can also try to post your issue on https://github.com/checkstyle/sonar-checkstyle , I am not sure if maintainers of checkstyle plugin monitor this forum.