Skip to content

Commit 190717d

Browse files
authored
[enhancement](chore)add single space separator rule to fe check style (apache#12354)
Some times, our code use more than one space as separator by mistake. This PR add a CheckStyle rule SingleSpaceSeparator to check that for Nereids.
1 parent b8e38b9 commit 190717d

File tree

13 files changed

+24
-22
lines changed

13 files changed

+24
-22
lines changed

fe/check/checkstyle/checkstyle.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ under the License.
391391
<property name="tokens" value="METHOD_REF"/>
392392
<property name="option" value="nl"/>
393393
</module>
394+
<module name="SingleSpaceSeparator"/>
394395
<module name="WhitespaceAfter">
395396
<property name="tokens"
396397
value="COMMA, SEMI, TYPECAST, LITERAL_IF, LITERAL_ELSE,

fe/check/checkstyle/suppressions.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ under the License.
4747
<!-- other -->
4848
<suppress files="org[\\/]apache[\\/]doris[\\/](?!nereids)[^\\/]+[\\/]|PaloFe\.java" checks="DeclarationOrder" />
4949
<suppress files="org[\\/]apache[\\/]doris[\\/](?!nereids)[^\\/]+[\\/]|PaloFe\.java" checks="OverloadMethodsDeclarationOrder" />
50+
<suppress files="org[\\/]apache[\\/]doris[\\/](?!nereids)[^\\/]+[\\/]|PaloFe\.java" checks="SingleSpaceSeparator" />
5051
<suppress files="org[\\/]apache[\\/]doris[\\/](?!nereids)[^\\/]+[\\/]|PaloFe\.java" checks="VariableDeclarationUsageDistance" />
5152

5253
<!-- exclude rules for special files -->

fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundFunction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ public String toSql() throws UnboundException {
6464
String params = children.stream()
6565
.map(Expression::toSql)
6666
.collect(Collectors.joining(", "));
67-
return name + "(" + (isDistinct ? "DISTINCT " : "") + params + ")";
67+
return name + "(" + (isDistinct ? "DISTINCT " : "") + params + ")";
6868
}
6969

7070
@Override
7171
public String toString() {
7272
String params = Joiner.on(", ").join(children);
73-
return "'" + name + "(" + (isDistinct ? "DISTINCT " : "") + params + ")";
73+
return "'" + name + "(" + (isDistinct ? "DISTINCT " : "") + params + ")";
7474
}
7575

7676
@Override

fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public Expr visitBoundFunction(BoundFunction function, PlanTranslatorContext con
265265

266266
@Override
267267
public Expr visitBinaryArithmetic(BinaryArithmetic binaryArithmetic, PlanTranslatorContext context) {
268-
ArithmeticExpr arithmeticExpr = new ArithmeticExpr(binaryArithmetic.getLegacyOperator(),
268+
ArithmeticExpr arithmeticExpr = new ArithmeticExpr(binaryArithmetic.getLegacyOperator(),
269269
binaryArithmetic.child(0).accept(this, context),
270270
binaryArithmetic.child(1).accept(this, context));
271271
return arithmeticExpr;

fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public PlanFragment visitPhysicalHashJoin(PhysicalHashJoin<Plan, Plan> hashJoin,
356356

357357
TupleDescriptor leftChildOutputTupleDesc = leftPlanRoot.getOutputTupleDesc();
358358
TupleDescriptor leftTuple =
359-
leftChildOutputTupleDesc != null ? leftChildOutputTupleDesc : context.getTupleDesc(leftPlanRoot);
359+
leftChildOutputTupleDesc != null ? leftChildOutputTupleDesc : context.getTupleDesc(leftPlanRoot);
360360
TupleDescriptor rightChildOutputTupleDesc = rightPlanRoot.getOutputTupleDesc();
361361
TupleDescriptor rightTuple =
362362
rightChildOutputTupleDesc != null ? rightChildOutputTupleDesc : context.getTupleDesc(rightPlanRoot);

fe/fe-core/src/main/java/org/apache/doris/nereids/pattern/generator/LogicalLeafPatternGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public LogicalLeafPatternGenerator(PatternGeneratorAnalyzer analyzer,
3232

3333
@Override
3434
public String genericType() {
35-
return "<" + opType.name + ">";
35+
return "<" + opType.name + ">";
3636
}
3737

3838
@Override

fe/fe-core/src/main/java/org/apache/doris/nereids/pattern/generator/PatternGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public String generateTypePattern(String patterName, String className,
275275
childrenPattern = ", " + childrenPattern;
276276
}
277277

278-
String pattern = "default " + methodGeneric + "\n"
278+
String pattern = "default " + methodGeneric + "\n"
279279
+ "PatternDescriptor" + genericParam + "\n"
280280
+ " " + patterName + "(" + methodParam + ") {\n"
281281
+ " return new PatternDescriptor" + genericParam + "(\n"

fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rewrite/rules/SimplifyNotExprRule.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ public Expression visitNot(Not not, ExpressionRewriteContext context) {
5151
Expression child = not.child();
5252
if (child instanceof ComparisonPredicate) {
5353
ComparisonPredicate cp = (ComparisonPredicate) not.child();
54-
Expression left = rewrite(cp.left(), context);
54+
Expression left = rewrite(cp.left(), context);
5555
Expression right = rewrite(cp.right(), context);
5656

5757
// TODO: visit concrete class instead of `instanceof`.
5858
if (child instanceof GreaterThan) {
5959
return new LessThanEqual(left, right);
6060
} else if (child instanceof GreaterThanEqual) {
6161
return new LessThan(left, right);
62-
} else if (child instanceof LessThan) {
62+
} else if (child instanceof LessThan) {
6363
return new GreaterThanEqual(left, right);
6464
} else if (child instanceof LessThanEqual) {
6565
return new GreaterThan(left, right);
@@ -68,7 +68,7 @@ public Expression visitNot(Not not, ExpressionRewriteContext context) {
6868
}
6969
} else if (child instanceof CompoundPredicate) {
7070
CompoundPredicate cp = (CompoundPredicate) not.child();
71-
Expression left = rewrite(new Not(cp.left()), context);
71+
Expression left = rewrite(new Not(cp.left()), context);
7272
Expression right = rewrite(new Not(cp.right()), context);
7373
return cp.flip(left, right);
7474
}

fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/MergeConsecutiveFilters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* |
4343
* scan
4444
*/
45-
public class MergeConsecutiveFilters extends OneRewriteRuleFactory {
45+
public class MergeConsecutiveFilters extends OneRewriteRuleFactory {
4646
@Override
4747
public Rule build() {
4848
return logicalFilter(logicalFilter()).then(filter -> {

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/WeekOfYear.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
/**
3535
* weekOfYear function
3636
*/
37-
public class WeekOfYear extends BoundFunction implements UnaryExpression, ImplicitCastInputTypes {
37+
public class WeekOfYear extends BoundFunction implements UnaryExpression, ImplicitCastInputTypes {
3838

3939
private static final List<AbstractDataType> EXPECTED_INPUT_TYPES = ImmutableList.of(
4040
new TypeCollection(DateTimeType.INSTANCE)

0 commit comments

Comments
 (0)