From 6d08b5f369a5c2f07f14c9a41acac68123b4d137 Mon Sep 17 00:00:00 2001 From: Zongwen Li Date: Tue, 19 Jul 2022 10:03:08 +0800 Subject: [PATCH] [checkstyle] Improved validation scope of MagicNumber (#2194) --- .../apache/seatunnel/api/table/type/SeaTunnelRow.java | 1 - .../seatunnel/api/table/type/SeaTunnelRowType.java | 1 - .../seatunnel/common/utils/VariablesSubstituteTest.java | 1 - .../seatunnel/flink/assertion/AssertExecutorTest.java | 1 - .../flink/assertion/rule/AssertRuleParserTest.java | 1 - .../file/sink/hdfs/FileSinkAggregatedCommitterTest.java | 2 +- .../file/sink/local/FileSinkAggregatedCommitterTest.java | 2 +- .../seatunnel/flink/assertion/AssertExecutorTest.java | 1 - .../flink/assertion/rule/AssertRuleParserTest.java | 1 - .../apache/seatunnel/flink/clickhouse/pojo/Shard.java | 1 - .../seatunnel/flink/clickhouse/pojo/ShardMetadata.java | 1 - .../e2e/flink/v2/fake/FakeSourceToConsoleIT.java | 1 - .../e2e/flink/clickhouse/FakeSourceToClickhouseIT.java | 1 - .../e2e/spark/v2/fake/FakeSourceToConsoleIT.java | 1 - .../seatunnel/e2e/spark/v2/file/FakeSourceToFileIT.java | 1 - .../seatunnel/plugin/discovery/PluginIdentifier.java | 1 - .../translation/flink/utils/TypeConverterUtilsTest.java | 1 - tools/checkstyle/checkStyle.xml | 9 ++++++++- 18 files changed, 10 insertions(+), 18 deletions(-) diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRow.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRow.java index de82a639baf..aa5923ec1c8 100644 --- a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRow.java +++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRow.java @@ -87,7 +87,6 @@ public boolean equals(Object o) { return tableId == that.tableId && kind == that.kind && Arrays.deepEquals(fields, that.fields); } - @SuppressWarnings("magicnumber") @Override public int hashCode() { int result = Objects.hash(tableId, kind); diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRowType.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRowType.java index 45164c2463b..cb94bba000a 100644 --- a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRowType.java +++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRowType.java @@ -98,7 +98,6 @@ public boolean equals(Object obj) { } @Override - @SuppressWarnings("MagicNumber") public int hashCode() { int result = Arrays.hashCode(fieldNames); result = 31 * result + Arrays.hashCode(fieldTypes); diff --git a/seatunnel-common/src/test/java/org/apache/seatunnel/common/utils/VariablesSubstituteTest.java b/seatunnel-common/src/test/java/org/apache/seatunnel/common/utils/VariablesSubstituteTest.java index 33d721ae81f..09d044a5312 100644 --- a/seatunnel-common/src/test/java/org/apache/seatunnel/common/utils/VariablesSubstituteTest.java +++ b/seatunnel-common/src/test/java/org/apache/seatunnel/common/utils/VariablesSubstituteTest.java @@ -26,7 +26,6 @@ public class VariablesSubstituteTest { - @SuppressWarnings("checkstyle:MagicNumber") @Test public void testSubstitute() { String timeFormat = "yyyyMMddHHmmss"; diff --git a/seatunnel-connectors-v2/connector-assert/src/test/java/org/apache/seatunnel/flink/assertion/AssertExecutorTest.java b/seatunnel-connectors-v2/connector-assert/src/test/java/org/apache/seatunnel/flink/assertion/AssertExecutorTest.java index c5d30f3b189..fa9fee2093f 100644 --- a/seatunnel-connectors-v2/connector-assert/src/test/java/org/apache/seatunnel/flink/assertion/AssertExecutorTest.java +++ b/seatunnel-connectors-v2/connector-assert/src/test/java/org/apache/seatunnel/flink/assertion/AssertExecutorTest.java @@ -29,7 +29,6 @@ import java.util.List; -@SuppressWarnings("magicnumber") public class AssertExecutorTest extends TestCase { SeaTunnelRow row = new SeaTunnelRow(new Object[]{"jared", 17}); SeaTunnelRowType rowType = new SeaTunnelRowType(new String[]{"name", "age"}, new SeaTunnelDataType[]{BasicType.STRING_TYPE, BasicType.INT_TYPE}); diff --git a/seatunnel-connectors-v2/connector-assert/src/test/java/org/apache/seatunnel/flink/assertion/rule/AssertRuleParserTest.java b/seatunnel-connectors-v2/connector-assert/src/test/java/org/apache/seatunnel/flink/assertion/rule/AssertRuleParserTest.java index 9a9628dedf0..5c1bb650cc2 100644 --- a/seatunnel-connectors-v2/connector-assert/src/test/java/org/apache/seatunnel/flink/assertion/rule/AssertRuleParserTest.java +++ b/seatunnel-connectors-v2/connector-assert/src/test/java/org/apache/seatunnel/flink/assertion/rule/AssertRuleParserTest.java @@ -28,7 +28,6 @@ import java.util.List; -@SuppressWarnings("magicnumber") public class AssertRuleParserTest extends TestCase { AssertRuleParser parser = new AssertRuleParser(); diff --git a/seatunnel-connectors-v2/connector-file/connector-file-hadoop/src/test/java/org/apache/seatunnel/connectors/seatunnel/file/sink/hdfs/FileSinkAggregatedCommitterTest.java b/seatunnel-connectors-v2/connector-file/connector-file-hadoop/src/test/java/org/apache/seatunnel/connectors/seatunnel/file/sink/hdfs/FileSinkAggregatedCommitterTest.java index 7554cee0951..3262ccd1cb2 100644 --- a/seatunnel-connectors-v2/connector-file/connector-file-hadoop/src/test/java/org/apache/seatunnel/connectors/seatunnel/file/sink/hdfs/FileSinkAggregatedCommitterTest.java +++ b/seatunnel-connectors-v2/connector-file/connector-file-hadoop/src/test/java/org/apache/seatunnel/connectors/seatunnel/file/sink/hdfs/FileSinkAggregatedCommitterTest.java @@ -64,7 +64,7 @@ public void testCommit() throws Exception { Assert.assertTrue(!HdfsUtils.fileExist(transactionDir)); } - @SuppressWarnings({"checkstyle:MagicNumber", "checkstyle:UnnecessaryParentheses"}) + @SuppressWarnings("checkstyle:UnnecessaryParentheses") @Test public void testCombine() throws Exception { FileSinkAggregatedCommitter fileSinkAggregatedCommitter = new FileSinkAggregatedCommitter(new HdfsFileSystemCommitter()); diff --git a/seatunnel-connectors-v2/connector-file/connector-file-local/src/test/java/org/apache/seatunnel/connectors/seatunnel/file/sink/local/FileSinkAggregatedCommitterTest.java b/seatunnel-connectors-v2/connector-file/connector-file-local/src/test/java/org/apache/seatunnel/connectors/seatunnel/file/sink/local/FileSinkAggregatedCommitterTest.java index 6b82041b126..720ad3eba78 100644 --- a/seatunnel-connectors-v2/connector-file/connector-file-local/src/test/java/org/apache/seatunnel/connectors/seatunnel/file/sink/local/FileSinkAggregatedCommitterTest.java +++ b/seatunnel-connectors-v2/connector-file/connector-file-local/src/test/java/org/apache/seatunnel/connectors/seatunnel/file/sink/local/FileSinkAggregatedCommitterTest.java @@ -64,7 +64,7 @@ public void testCommit() throws Exception { Assert.assertTrue(!FileUtils.fileExist(transactionDir)); } - @SuppressWarnings({"checkstyle:UnnecessaryParentheses", "checkstyle:MagicNumber"}) + @SuppressWarnings("checkstyle:UnnecessaryParentheses") @Test public void testCombine() throws Exception { FileSinkAggregatedCommitter fileSinkAggregatedCommitter = new FileSinkAggregatedCommitter(new LocalFileSystemCommitter()); diff --git a/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-assert/src/test/java/org/apache/seatunnel/flink/assertion/AssertExecutorTest.java b/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-assert/src/test/java/org/apache/seatunnel/flink/assertion/AssertExecutorTest.java index 34c533cfc8b..1ddd866b90c 100644 --- a/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-assert/src/test/java/org/apache/seatunnel/flink/assertion/AssertExecutorTest.java +++ b/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-assert/src/test/java/org/apache/seatunnel/flink/assertion/AssertExecutorTest.java @@ -26,7 +26,6 @@ import java.util.List; -@SuppressWarnings("magicnumber") public class AssertExecutorTest extends TestCase { Row row = Row.withNames(); AssertExecutor assertExecutor = new AssertExecutor(); diff --git a/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-assert/src/test/java/org/apache/seatunnel/flink/assertion/rule/AssertRuleParserTest.java b/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-assert/src/test/java/org/apache/seatunnel/flink/assertion/rule/AssertRuleParserTest.java index fad5ed322c6..1df875e9d30 100644 --- a/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-assert/src/test/java/org/apache/seatunnel/flink/assertion/rule/AssertRuleParserTest.java +++ b/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-assert/src/test/java/org/apache/seatunnel/flink/assertion/rule/AssertRuleParserTest.java @@ -25,7 +25,6 @@ import java.util.List; -@SuppressWarnings("magicnumber") public class AssertRuleParserTest extends TestCase { AssertRuleParser parser = new AssertRuleParser(); diff --git a/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-clickhouse/src/main/java/org/apache/seatunnel/flink/clickhouse/pojo/Shard.java b/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-clickhouse/src/main/java/org/apache/seatunnel/flink/clickhouse/pojo/Shard.java index 20f34be1e82..e2d1394df22 100644 --- a/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-clickhouse/src/main/java/org/apache/seatunnel/flink/clickhouse/pojo/Shard.java +++ b/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-clickhouse/src/main/java/org/apache/seatunnel/flink/clickhouse/pojo/Shard.java @@ -114,7 +114,6 @@ public boolean equals(Object o) { } @Override - @SuppressWarnings("magicnumber") public int hashCode() { if (hashCode != -1) { return hashCode; diff --git a/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-clickhouse/src/main/java/org/apache/seatunnel/flink/clickhouse/pojo/ShardMetadata.java b/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-clickhouse/src/main/java/org/apache/seatunnel/flink/clickhouse/pojo/ShardMetadata.java index 96e27336462..033c99d9048 100644 --- a/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-clickhouse/src/main/java/org/apache/seatunnel/flink/clickhouse/pojo/ShardMetadata.java +++ b/seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-clickhouse/src/main/java/org/apache/seatunnel/flink/clickhouse/pojo/ShardMetadata.java @@ -122,7 +122,6 @@ public boolean equals(Object o) { } @Override - @SuppressWarnings("magicnumber") public int hashCode() { int result = shardKey.hashCode(); result = 31 * result + shardKeyType.hashCode(); diff --git a/seatunnel-e2e/seatunnel-flink-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/flink/v2/fake/FakeSourceToConsoleIT.java b/seatunnel-e2e/seatunnel-flink-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/flink/v2/fake/FakeSourceToConsoleIT.java index f715c4e79ad..d480fc94671 100644 --- a/seatunnel-e2e/seatunnel-flink-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/flink/v2/fake/FakeSourceToConsoleIT.java +++ b/seatunnel-e2e/seatunnel-flink-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/flink/v2/fake/FakeSourceToConsoleIT.java @@ -28,7 +28,6 @@ public class FakeSourceToConsoleIT extends FlinkContainer { @Test - @SuppressWarnings("magicnumber") public void testFakeSourceToConsoleSink() throws IOException, InterruptedException { Container.ExecResult execResult = executeSeaTunnelFlinkJob("/fake/fakesource_to_console.conf"); Assert.assertEquals(0, execResult.getExitCode()); diff --git a/seatunnel-e2e/seatunnel-flink-e2e/src/test/java/org/apache/seatunnel/e2e/flink/clickhouse/FakeSourceToClickhouseIT.java b/seatunnel-e2e/seatunnel-flink-e2e/src/test/java/org/apache/seatunnel/e2e/flink/clickhouse/FakeSourceToClickhouseIT.java index adbea780648..1bf0fc6e5ac 100644 --- a/seatunnel-e2e/seatunnel-flink-e2e/src/test/java/org/apache/seatunnel/e2e/flink/clickhouse/FakeSourceToClickhouseIT.java +++ b/seatunnel-e2e/seatunnel-flink-e2e/src/test/java/org/apache/seatunnel/e2e/flink/clickhouse/FakeSourceToClickhouseIT.java @@ -50,7 +50,6 @@ public class FakeSourceToClickhouseIT extends FlinkContainer { private static final Logger LOGGER = LoggerFactory.getLogger(FakeSourceToClickhouseIT.class); @Before - @SuppressWarnings("magicnumber") public void startClickhouseContainer() throws InterruptedException { clickhouseServer = new GenericContainer<>(CLICKHOUSE_DOCKER_IMAGE) .withNetwork(NETWORK) diff --git a/seatunnel-e2e/seatunnel-spark-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/fake/FakeSourceToConsoleIT.java b/seatunnel-e2e/seatunnel-spark-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/fake/FakeSourceToConsoleIT.java index 5f35135bb6d..0749ec06f21 100644 --- a/seatunnel-e2e/seatunnel-spark-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/fake/FakeSourceToConsoleIT.java +++ b/seatunnel-e2e/seatunnel-spark-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/fake/FakeSourceToConsoleIT.java @@ -32,7 +32,6 @@ public class FakeSourceToConsoleIT extends SparkContainer { @Test - @SuppressWarnings("magicnumber") public void testFakeSourceToConsoleSine() throws IOException, InterruptedException { Container.ExecResult execResult = executeSeaTunnelSparkJob("/fake/fakesource_to_console.conf"); Assert.assertEquals(0, execResult.getExitCode()); diff --git a/seatunnel-e2e/seatunnel-spark-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/file/FakeSourceToFileIT.java b/seatunnel-e2e/seatunnel-spark-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/file/FakeSourceToFileIT.java index 5ebe51d4792..c2aeec5131e 100644 --- a/seatunnel-e2e/seatunnel-spark-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/file/FakeSourceToFileIT.java +++ b/seatunnel-e2e/seatunnel-spark-connector-v2-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/file/FakeSourceToFileIT.java @@ -32,7 +32,6 @@ public class FakeSourceToFileIT extends SparkContainer { @Test - @SuppressWarnings("magicnumber") public void testFakeSourceToFile() throws IOException, InterruptedException { Container.ExecResult execResult = executeSeaTunnelSparkJob("/file/fakesource_to_file.conf"); Assert.assertEquals(0, execResult.getExitCode()); diff --git a/seatunnel-plugin-discovery/src/main/java/org/apache/seatunnel/plugin/discovery/PluginIdentifier.java b/seatunnel-plugin-discovery/src/main/java/org/apache/seatunnel/plugin/discovery/PluginIdentifier.java index 97d6e9f81db..37e322b7390 100644 --- a/seatunnel-plugin-discovery/src/main/java/org/apache/seatunnel/plugin/discovery/PluginIdentifier.java +++ b/seatunnel-plugin-discovery/src/main/java/org/apache/seatunnel/plugin/discovery/PluginIdentifier.java @@ -70,7 +70,6 @@ public boolean equals(Object o) { } @Override - @SuppressWarnings("checkstyle:magicnumber") public int hashCode() { int result = engineType != null ? engineType.hashCode() : 0; result = 31 * result + (pluginType != null ? pluginType.hashCode() : 0); diff --git a/seatunnel-translation/seatunnel-translation-flink/src/test/java/org/apache/seatunnel/translation/flink/utils/TypeConverterUtilsTest.java b/seatunnel-translation/seatunnel-translation-flink/src/test/java/org/apache/seatunnel/translation/flink/utils/TypeConverterUtilsTest.java index 9eb6f959f84..b5343fb9200 100644 --- a/seatunnel-translation/seatunnel-translation-flink/src/test/java/org/apache/seatunnel/translation/flink/utils/TypeConverterUtilsTest.java +++ b/seatunnel-translation/seatunnel-translation-flink/src/test/java/org/apache/seatunnel/translation/flink/utils/TypeConverterUtilsTest.java @@ -73,7 +73,6 @@ public void convertShortType() { } @Test - @SuppressWarnings("MagicNumber") public void convertBigDecimalType() { Assert.assertEquals(new BigDecimalTypeInfo(30, 2), TypeConverterUtils.convert(new DecimalType(30, 2))); } diff --git a/tools/checkstyle/checkStyle.xml b/tools/checkstyle/checkStyle.xml index ebbc1f2581e..ddff7c20f1a 100755 --- a/tools/checkstyle/checkStyle.xml +++ b/tools/checkstyle/checkStyle.xml @@ -85,6 +85,11 @@ + + + + + @@ -207,7 +212,9 @@ - + + +