[DISCUSS] Java files have different import order from Scala files

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

[DISCUSS] Java files have different import order from Scala files

Hi all,

As we all know, the Java files have different import order from the Scala
files in the whole project. For the Java files, we can import the packages
like 'org.apache.commons' before 'org.apache.carbondata' but without any
checkstyle plugin detected.

Code is written once by its author, but read and modified multiple times by
lots of other engineers. As most bugs actually come from future modification
of the code, we need to optimize our codebase for long-term, global
readability and maintainability. Although the order of imports seems not to
be a big deal at most of the time, it does break the readability and
maintainability of the whole project, and even make the project hard to

After some investigation, I find it is easy to keep the same import order
between Java and Scala files.

This is the configs from dev/javastyle-config.xml for Checktyle, the Maven

<module name="ImportOrder">
    <property name="separated" value="true"/>
    <property name="groups" value="/^javax?\./,org.apache.carbondata,*"/>

It means when we import the carbondata packages before the 3rd party
packages, it does compliant to the style standard, so the Checksytle plugin
wouldn't report any style error.

But the import order is different in the scala sytle. Looking at the value
of property named groups, the developer is asked to import the 3rd party
packages before carbondata packages as bellow.

 <check level="error" class="org.scalastyle.scalariform.ImportOrderChecker"
   <parameter name="groups">java,scala,3rdParty,carbondata</parameter>
   <parameter name="group.java">javax?\..*</parameter>
   <parameter name="group.scala">scala\..*</parameter>

To keep consistent to the scala style, I think we could make some effort to
change javastyle-config.xml. However, it would need to modify all of the
Java files.

Is it worthy trying or stay the same?

Reply '+1' if you think it's a good move to change the import order of Java
files, or type '-1' please.

Liu Runzhong

Sent from: http://apache-carbondata-dev-mailing-list-archive.1130556.n5.nabble.com/
Reply | Threaded
Open this post in threaded view

Re: [DISCUSS] Java files have different import order from Scala files

I think it's a good proposal, but it will introduce too many changes.

In my opinion, the different order between Java and Scala files is
acceptable since it will not cause serious (even minor) problems.

Anyway, thanks for your investigation on this. But it's hard to tell
whether we should apply this proposal.