You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Stefan Miklosovic (Jira)" <ji...@apache.org> on 2022/09/27 10:52:00 UTC

[jira] [Updated] (CASSANDRA-17925) Java source code should have sorted imports as defined in the codestyle

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

Stefan Miklosovic updated CASSANDRA-17925:
------------------------------------------
    Description: 
After we cleaned all unused imports in CASSANDRA-17876, there is one more task remaining to be done - to add checkstyle for imports order and enforce this on build time.

When the project is imported into IDEA, there is a helper target on Ant called "generate-idea-files". ide/idea/codeStyleSettings.xml contains this:
{code:java}
        <option name="IMPORT_LAYOUT_TABLE">
          <value>
            <package name="java" withSubpackages="true" static="false" />
            <package name="javax" withSubpackages="true" static="false" />
            <emptyLine />
            <package name="com.google.common" withSubpackages="true" static="false" />
            <package name="org.apache.log4j" withSubpackages="true" static="false" />
            <package name="org.apache.commons" withSubpackages="true" static="false" />
            <package name="org.cliffc.high_scale_lib" withSubpackages="true" static="false" />
            <package name="org.junit" withSubpackages="true" static="false" />
            <package name="org.slf4j" withSubpackages="true" static="false" />
            <emptyLine />
            <package name="" withSubpackages="true" static="false" />
            <emptyLine />
            <package name="" withSubpackages="true" static="true" />
          </value>
        </option>
{code}
However, when one runs "Optimise imports" in the context menu after right-clicking on org.cassandra.apache package, it will refactor all the imports which adheres to the above codestyle with hundreds or changes.

This means that the source code, as-is, does not adhere to the self-imposed code style we ship for IDEA.

If we fix this, we should add checkstyle for it like this:
{code:java}
    <module name="ImportOrder">
      <property name="groups" value="/(^java\.|javax)/,/(com\.google\.common|org\.apache\.log4j|org\.apache\.commons|org\.cliffc\.high_scale_lib|org\.junit|org\.slf4j)/"/>
      <property name="ordered" value="true"/>
      <property name="separated" value="true"/>
      <property name="option" value="bottom"/>
      <property name="separatedStaticGroups" value="false"/>
      <property name="sortStaticImportsAlphabetically" value="true"/>
    </module>
{code}
This checkstyle on import order will pass on the source code we run the import optimisation in the context menu on.

This should be applied to test checktyle as well and the source code should be refactored on imports too.

This should be done on cassandra-4.1 as well as for trunk.

  was:
After we cleaned all unused imports in CASSANDRA-17876, there is one more task remaining to be done - to add checkstyle for imports order and enforce this on build time.

When the project is imported into IDEA, there is a helper target on Ant called "generate-idea-files". ide/idea/codeStyleSettings.xml contains this:

{code}
        <option name="IMPORT_LAYOUT_TABLE">
          <value>
            <package name="java" withSubpackages="true" static="false" />
            <package name="javax" withSubpackages="true" static="false" />
            <emptyLine />
            <package name="com.google.common" withSubpackages="true" static="false" />
            <package name="org.apache.log4j" withSubpackages="true" static="false" />
            <package name="org.apache.commons" withSubpackages="true" static="false" />
            <package name="org.cliffc.high_scale_lib" withSubpackages="true" static="false" />
            <package name="org.junit" withSubpackages="true" static="false" />
            <package name="org.slf4j" withSubpackages="true" static="false" />
            <emptyLine />
            <package name="" withSubpackages="true" static="false" />
            <emptyLine />
            <package name="" withSubpackages="true" static="true" />
          </value>
        </option>
{code}

However, when one runs "Optimise imports" in the context menu after right-clicking on org.cassandra.apache package, it will refactor all the imports which adheres to the above codestyle with hundreds or changes.

This means that the source code, as-is, does not adhere to the self-imposed code style we ship for IDEA.

If we fix this, we should add checkstyle for it like this:

{code}
    <module name="ImportOrder">
      <property name="groups" value="/(^java\.|javax)/,/(com\.google\.common|org\.apache\.log4j|org\.apache\.commons|org\.cliffc\.high_scale_lib|org\.junit|org\.slf4j)/"/>
      <property name="ordered" value="true"/>
      <property name="separated" value="true"/>
      <property name="option" value="bottom"/>
      <property name="separatedStaticGroups" value="false"/>
      <property name="sortStaticImportsAlphabetically" value="true"/>
    </module>
{code}

This checkstyle on import order will pass on the source code we run the import optimisation in the context menu.

This should be applied to test checktyle as well and the source code should be refactored on imports too.

This should be done on cassandra-4.1 as well as for trunk.


> Java source code should have sorted imports as defined in the codestyle
> -----------------------------------------------------------------------
>
>                 Key: CASSANDRA-17925
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-17925
>             Project: Cassandra
>          Issue Type: Improvement
>            Reporter: Stefan Miklosovic
>            Priority: Normal
>
> After we cleaned all unused imports in CASSANDRA-17876, there is one more task remaining to be done - to add checkstyle for imports order and enforce this on build time.
> When the project is imported into IDEA, there is a helper target on Ant called "generate-idea-files". ide/idea/codeStyleSettings.xml contains this:
> {code:java}
>         <option name="IMPORT_LAYOUT_TABLE">
>           <value>
>             <package name="java" withSubpackages="true" static="false" />
>             <package name="javax" withSubpackages="true" static="false" />
>             <emptyLine />
>             <package name="com.google.common" withSubpackages="true" static="false" />
>             <package name="org.apache.log4j" withSubpackages="true" static="false" />
>             <package name="org.apache.commons" withSubpackages="true" static="false" />
>             <package name="org.cliffc.high_scale_lib" withSubpackages="true" static="false" />
>             <package name="org.junit" withSubpackages="true" static="false" />
>             <package name="org.slf4j" withSubpackages="true" static="false" />
>             <emptyLine />
>             <package name="" withSubpackages="true" static="false" />
>             <emptyLine />
>             <package name="" withSubpackages="true" static="true" />
>           </value>
>         </option>
> {code}
> However, when one runs "Optimise imports" in the context menu after right-clicking on org.cassandra.apache package, it will refactor all the imports which adheres to the above codestyle with hundreds or changes.
> This means that the source code, as-is, does not adhere to the self-imposed code style we ship for IDEA.
> If we fix this, we should add checkstyle for it like this:
> {code:java}
>     <module name="ImportOrder">
>       <property name="groups" value="/(^java\.|javax)/,/(com\.google\.common|org\.apache\.log4j|org\.apache\.commons|org\.cliffc\.high_scale_lib|org\.junit|org\.slf4j)/"/>
>       <property name="ordered" value="true"/>
>       <property name="separated" value="true"/>
>       <property name="option" value="bottom"/>
>       <property name="separatedStaticGroups" value="false"/>
>       <property name="sortStaticImportsAlphabetically" value="true"/>
>     </module>
> {code}
> This checkstyle on import order will pass on the source code we run the import optimisation in the context menu on.
> This should be applied to test checktyle as well and the source code should be refactored on imports too.
> This should be done on cassandra-4.1 as well as for trunk.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org