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
debug.
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
plugin.
<module name="ImportOrder">
<property name="separated" value="true"/>
<property name="groups" value="/^javax?\./,org.apache.carbondata,*"/>
</module>
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"
enabled="true">
<parameters>
<parameter name="groups">java,scala,3rdParty,carbondata</parameter>
<parameter name="group.java">javax?\..*</parameter>
<parameter name="group.scala">scala\..*</parameter>
<parameter
name="group.3rdParty">(?!org\.apache\.carbondata\.).*</parameter>
<parameter
name="group.carbondata">org\.apache\.carbondata\..*</parameter>
</parameters>
</check>
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.
Thanks,
Liu Runzhong
--
Sent from:
http://apache-carbondata-dev-mailing-list-archive.1130556.n5.nabble.com/