Skip to content

Commit

Permalink
[style](java) format fe code with some check rules (apache#9460)
Browse files Browse the repository at this point in the history
Issue Number: close apache#9403 

set below rules' severity to error and format code according check info.
a. Merge conflicts unresolved
b. Avoid using corresponding octal or Unicode escape
c. Avoid Escaped Unicode Characters
d. No Line Wrap
e. Package Name
f. Type Name
g. Annotation Location
h. Interface Type Parameter
i. CatchParameterName
j. Pattern Variable Name
k. Record Component Name
l. Record Type Parameter Name
m. Method Type Parameter Name
n. Redundant Import
o. Custom Import Order
p. Unused Imports
q. Avoid Star Import
r. tab character in file
s. Newline At End Of File
t. Trailing whitespace found
  • Loading branch information
morrySnow authored and minghong.zhou committed May 23, 2022
1 parent 0f9d0f3 commit 06207c0
Show file tree
Hide file tree
Showing 1,096 changed files with 3,659 additions and 4,481 deletions.
21 changes: 20 additions & 1 deletion fe/check/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ under the License.

<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="LineLength">
<property name="fileExtensions" value="java"/>
Expand All @@ -53,15 +54,18 @@ under the License.
<module name="RegexpSingleline">
<property name="format" value="&gt;&gt;&gt;&gt;&gt;&gt;&gt;"/>
<property name="message" value="Merge conflicts unresolved."/>
<property name="severity" value="error"/>
</module>
<module name="RegexpSingleline">
<property name="format" value="&lt;&lt;&lt;&lt;&lt;&lt;&lt;"/>
<property name="message" value="Merge conflicts unresolved."/>
<property name="severity" value="error"/>
</module>
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="message" value="Trailing whitespace found."/>
<property name="fileExtensions" value=".java"/>
<property name="severity" value="error"/>
</module>

<module name="TreeWalker">
Expand All @@ -71,11 +75,13 @@ under the License.
<property name="tokens"
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF,
RECORD_DEF, COMPACT_CTOR_DEF"/>
<property name="severity" value="error"/>
</module>
<module name="AnnotationLocation">
<property name="id" value="AnnotationLocationVariables"/>
<property name="tokens" value="VARIABLE_DEF"/>
<property name="allowSamelineMultipleAnnotations" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="MissingOverride">
<property name="severity" value="error"/>
Expand Down Expand Up @@ -151,12 +157,15 @@ under the License.
<module name="AvoidStarImport">
<property name="severity" value="error"/>
</module>
<module name="AvoidStaticImport"/>
<module name="AvoidStaticImport">
<property name="severity" value="error"/>
</module>
<module name="CustomImportOrder">
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
<property name="customImportOrderRules" value="SAME_PACKAGE(3)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
<property name="tokens" value="IMPORT, STATIC_IMPORT, PACKAGE_DEF"/>
<property name="severity" value="error"/>
</module>
<module name="RedundantImport">
<property name="severity" value="error"/>
Expand Down Expand Up @@ -216,6 +225,7 @@ under the License.
<property name="allowEscapesForControlCharacters" value="true"/>
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="CommentsIndentation">
<property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/>
Expand Down Expand Up @@ -247,6 +257,7 @@ under the License.
</module>
<module name="CatchParameterName">
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
<property name="severity" value="error"/>
<message key="name.invalidPattern"
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
Expand All @@ -257,6 +268,7 @@ under the License.
</module>
<module name="InterfaceTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*$)"/>
<property name="severity" value="error"/>
<message key="name.invalidPattern"
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
</module>
Expand All @@ -282,11 +294,13 @@ under the License.
</module>
<module name="MethodTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*$)"/>
<property name="severity" value="error"/>
<message key="name.invalidPattern"
value="Method type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
<property name="severity" value="error"/>
<message key="name.invalidPattern"
value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
Expand All @@ -297,22 +311,26 @@ under the License.
</module>
<module name="PatternVariableName">
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
<property name="severity" value="error"/>
<message key="name.invalidPattern"
value="Pattern variable name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="RecordComponentName">
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
<property name="severity" value="error"/>
<message key="name.invalidPattern"
value="Record component name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="RecordTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*$)"/>
<property name="severity" value="error"/>
<message key="name.invalidPattern"
value="Record type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="TypeName">
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
ANNOTATION_DEF, RECORD_DEF"/>
<property name="severity" value="error"/>
<message key="name.invalidPattern"
value="Type name ''{0}'' must match pattern ''{1}''."/>
</module>
Expand Down Expand Up @@ -344,6 +362,7 @@ under the License.
</module>
<module name="NoLineWrap">
<property name="tokens" value="PACKAGE_DEF, IMPORT, STATIC_IMPORT"/>
<property name="severity" value="error"/>
</module>
<module name="NoWhitespaceBefore">
<property name="tokens"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class FeMetaVersion {
public static final int VERSION_CURRENT = VERSION_109;

// all logs meta version should >= the minimum version, so that we could remove many if clause, for example
// if (FE_METAVERSION < VERSION_94) ...
// these clause will be useless and we could remove them
// if (FE_METAVERSION < VERSION_94) ...
// these clause will be useless and we could remove them
public static final int MINIMUM_VERSION_REQUIRED = VERSION_100;
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,3 @@ public static long decodeVarint64(DataInput in) throws IOException {
return result;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* <p>
* Typical usage is something like the following:
*
*
* <pre>
*
* DataInputBuffer buffer = new DataInputBuffer();
Expand All @@ -41,7 +41,7 @@
* ... read buffer using DataInput methods ...
* }
* </pre>
*
*
*/
public class DataInputBuffer extends DataInputStream {
private static class Buffer extends ByteArrayInputStream {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
* <p>
* Typical usage is something like the following:
*
*
* <pre>
*
* DataOutputBuffer buffer = new DataOutputBuffer();
Expand All @@ -46,7 +46,7 @@
* ... write data to its ultimate destination ...
* }
* </pre>
*
*
*/
public class DataOutputBuffer extends DataOutputStream {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.doris.common.io;

import org.apache.doris.meta.MetaContext;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -51,7 +52,7 @@ public static boolean copy(Writable orig, Writable dest, Class c, int metaVersio
out.close();

DataInputStream in = new DataInputStream(byteArrayOutputStream.getInputStream());

Method readMethod = c.getDeclaredMethod(READ_FIELDS_METHOD_NAME, DataInput.class);
readMethod.invoke(dest, in);
in.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static long copyBytes(InputStream in, OutputStream out,

/**
* Copies from one stream to another.
*
*
* @param in
* InputStream to read from
* @param out
Expand Down Expand Up @@ -117,7 +117,7 @@ public static long copyBytes(InputStream in, OutputStream out,

/**
* Copies from one stream to another.
*
*
* @param in
* InputStream to read from
* @param out
Expand Down Expand Up @@ -155,7 +155,7 @@ public static long copyBytes(InputStream in, OutputStream out,

/**
* Reads len bytes in a loop.
*
*
* @param in
* The InputStream to read from
* @param buf
Expand Down Expand Up @@ -184,7 +184,7 @@ public static void readFully(InputStream in, byte buf[], int off, int len)

/**
* Similar to readFully(). Skips bytes in a loop.
*
*
* @param in
* The InputStream to skip bytes from
* @param len
Expand All @@ -207,7 +207,7 @@ public static void skipFully(InputStream in, long len) throws IOException {
/**
* Close the Closeable objects and <b>ignore</b> any {@link IOException} or
* null pointers. Must only be used for cleanup in exception handlers.
*
*
* @param log
* the log to record problems to at debug level. Can be null.
* @param closeables
Expand All @@ -230,7 +230,7 @@ public static void cleanup(Logger log, java.io.Closeable... closeables) {
/**
* Closes the stream ignoring {@link IOException}. Must only be called in
* cleaning up from exception handlers.
*
*
* @param stream
* the Stream to close
*/
Expand All @@ -240,7 +240,7 @@ public static void closeStream(java.io.Closeable stream) {

/**
* Closes the socket ignoring {@link IOException}
*
*
* @param sock
* the Socket to close
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* <p>
* Typical usage is something like the following:
*
*
* <pre>
*
* InputBuffer buffer = new InputBuffer();
Expand All @@ -41,7 +41,7 @@
* ... read buffer using InputStream methods ...
* }
* </pre>
*
*
* @see DataInputBuffer
* @see DataOutput
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class LimitInputStream extends InputStream {

/**
* An input stream that reads the limited bytes to the given stream.
*
*
* @param in
* The stream to be limited
* @param limitspeed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class LimitOutputStream extends OutputStream {

/**
* A output stream that writes the limited bytes to the given stream.
*
*
* @param out
* The stream to be limited
* @param limitspeed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import java.io.ByteArrayOutputStream;
import java.io.FilterOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStream;

/**
* A reusable {@link OutputStream} implementation that writes to an in-memory
Expand All @@ -32,7 +32,7 @@
*
* <p>
* Typical usage is something like the following:
*
*
* <pre>
*
* OutputBuffer buffer = new OutputBuffer();
Expand All @@ -44,7 +44,7 @@
* ... write data to its ultimate destination ...
* }
* </pre>
*
*
* @see DataOutputBuffer
* @see InputBuffer
*/
Expand Down
Loading

0 comments on commit 06207c0

Please sign in to comment.