[FLINK-9069] Add checkstyle rule to detect multiple consecutive semicolons

This closes #5769.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/2d874532
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/2d874532
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/2d874532

Branch: refs/heads/master
Commit: 2d87453260b07e7f605e54cc4b76619ca7945e13
Parents: 767d79f
Author: jparkie <park.jacob...@gmail.com>
Authored: Sun Mar 25 18:09:25 2018 -0700
Committer: zentol <ches...@apache.org>
Committed: Wed Apr 4 08:59:05 2018 +0200

----------------------------------------------------------------------
 .../org/apache/flink/configuration/HistoryServerOptions.java  | 2 +-
 .../java/org/apache/calcite/avatica/util/DateTimeUtils.java   | 4 ++--
 .../runtime/io/network/netty/PartitionRequestQueueTest.java   | 2 +-
 .../main/java/org/apache/flink/yarn/YarnClusterClient.java    | 2 +-
 tools/maven/checkstyle.xml                                    | 7 +++++++
 5 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/2d874532/flink-core/src/main/java/org/apache/flink/configuration/HistoryServerOptions.java
----------------------------------------------------------------------
diff --git 
a/flink-core/src/main/java/org/apache/flink/configuration/HistoryServerOptions.java
 
b/flink-core/src/main/java/org/apache/flink/configuration/HistoryServerOptions.java
index a16fd7f..13cdc1e 100644
--- 
a/flink-core/src/main/java/org/apache/flink/configuration/HistoryServerOptions.java
+++ 
b/flink-core/src/main/java/org/apache/flink/configuration/HistoryServerOptions.java
@@ -34,7 +34,7 @@ public class HistoryServerOptions {
        public static final ConfigOption<Long> 
HISTORY_SERVER_ARCHIVE_REFRESH_INTERVAL =
                key("historyserver.archive.fs.refresh-interval")
                        .defaultValue(10000L)
-                       .withDescription("Interval in milliseconds for 
refreshing the archived job directories.");;
+                       .withDescription("Interval in milliseconds for 
refreshing the archived job directories.");
 
        /**
         * Comma-separated list of directories which the HistoryServer polls 
for new archives.

http://git-wip-us.apache.org/repos/asf/flink/blob/2d874532/flink-libraries/flink-table/src/main/java/org/apache/calcite/avatica/util/DateTimeUtils.java
----------------------------------------------------------------------
diff --git 
a/flink-libraries/flink-table/src/main/java/org/apache/calcite/avatica/util/DateTimeUtils.java
 
b/flink-libraries/flink-table/src/main/java/org/apache/calcite/avatica/util/DateTimeUtils.java
index d1a87a7..fe09d18 100644
--- 
a/flink-libraries/flink-table/src/main/java/org/apache/calcite/avatica/util/DateTimeUtils.java
+++ 
b/flink-libraries/flink-table/src/main/java/org/apache/calcite/avatica/util/DateTimeUtils.java
@@ -427,7 +427,7 @@ public class DateTimeUtils {
        }
 
        public static int digitCount(int v) {
-               for (int n = 1;; n++) {
+               for (int n = 1; true; n++) {
                        v /= 10;
                        if (v == 0) {
                                return n;
@@ -960,7 +960,7 @@ public class DateTimeUtils {
                // Start with an estimate.
                // Since no month has more than 31 days, the estimate is <= the 
true value.
                int m = (date0 - date1) / 31;
-               for (;;) {
+               while (true) {
                        int date2 = addMonths(date1, m);
                        if (date2 >= date0) {
                                return m;

http://git-wip-us.apache.org/repos/asf/flink/blob/2d874532/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/PartitionRequestQueueTest.java
----------------------------------------------------------------------
diff --git 
a/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/PartitionRequestQueueTest.java
 
b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/PartitionRequestQueueTest.java
index f614c18..2deaa9b 100644
--- 
a/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/PartitionRequestQueueTest.java
+++ 
b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/PartitionRequestQueueTest.java
@@ -165,7 +165,7 @@ public class PartitionRequestQueueTest {
                private final AtomicInteger buffersInBacklog;
 
                private DefaultBufferResultSubpartitionView(int 
buffersInBacklog) {
-                       this.buffersInBacklog = new 
AtomicInteger(buffersInBacklog);;
+                       this.buffersInBacklog = new 
AtomicInteger(buffersInBacklog);
                }
 
                @Nullable

http://git-wip-us.apache.org/repos/asf/flink/blob/2d874532/flink-yarn/src/main/java/org/apache/flink/yarn/YarnClusterClient.java
----------------------------------------------------------------------
diff --git 
a/flink-yarn/src/main/java/org/apache/flink/yarn/YarnClusterClient.java 
b/flink-yarn/src/main/java/org/apache/flink/yarn/YarnClusterClient.java
index 29ece26..2ac9664 100644
--- a/flink-yarn/src/main/java/org/apache/flink/yarn/YarnClusterClient.java
+++ b/flink-yarn/src/main/java/org/apache/flink/yarn/YarnClusterClient.java
@@ -244,7 +244,7 @@ public class YarnClusterClient extends 
ClusterClient<ApplicationId> {
        public void waitForClusterToBeReady() {
                logAndSysout("Waiting until all TaskManagers have connected");
 
-               for (GetClusterStatusResponse currentStatus, lastStatus = 
null;; lastStatus = currentStatus) {
+               for (GetClusterStatusResponse currentStatus, lastStatus = null; 
true; lastStatus = currentStatus) {
                        currentStatus = getClusterStatus();
                        if (currentStatus != null && 
!currentStatus.equals(lastStatus)) {
                                logAndSysout("TaskManager status (" + 
currentStatus.numRegisteredTaskManagers() + "/"

http://git-wip-us.apache.org/repos/asf/flink/blob/2d874532/tools/maven/checkstyle.xml
----------------------------------------------------------------------
diff --git a/tools/maven/checkstyle.xml b/tools/maven/checkstyle.xml
index a0168b0..a0e7dd7 100644
--- a/tools/maven/checkstyle.xml
+++ b/tools/maven/checkstyle.xml
@@ -462,6 +462,13 @@ This file is based on the checkstyle file of Apache Beam.
     <!-- Detects empty statements (standalone ";" semicolon). -->
     <module name="EmptyStatement"/>
 
+       <!-- Detect multiple consecutive semicolons (e.g. ";;"). -->
+       <module name="RegexpSinglelineJava">
+         <property name="format" value=";{2,}"/>
+         <property name="message" value="Use one semicolon"/>
+         <property name="ignoreComments" value="true"/>
+       </module>
+
     <!--
 
     MODIFIERS CHECKS

Reply via email to