Browse Source

[ci] Add checkstyle prohibit rule System.out.println (#6778)

* [ci] Add checkstyle prohibit rule System.out.println

* Correct RegexpSingleline place
3.0.0/version-upgrade
Jiajie Zhong 3 years ago committed by GitHub
parent
commit
6045728428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/SnowFlakeUtilsTest.java
  2. 1
      dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/StringTest.java
  3. 1
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java
  4. 1
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveDatasourceProcessorTest.java
  5. 1
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceProcessorTest.java
  6. 1
      dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClientTest.java
  7. 2
      dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/queue/TaskPriorityQueueImplTest.java
  8. 5
      style/checkstyle.xml

17
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/SnowFlakeUtilsTest.java

@ -17,18 +17,19 @@
package org.apache.dolphinscheduler.common.utils; package org.apache.dolphinscheduler.common.utils;
import java.util.HashSet;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
public class SnowFlakeUtilsTest { public class SnowFlakeUtilsTest {
@Test @Test
public void testNextId() { public void testNoGenerateDuplicateId() throws SnowFlakeUtils.SnowFlakeException {
try { HashSet<Long> existsSnowFlakeId = new HashSet<>();
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
Thread.sleep(1); Long currentId = SnowFlakeUtils.getInstance().nextId();
System.out.println(SnowFlakeUtils.getInstance().nextId()); Assert.assertFalse(existsSnowFlakeId.contains(currentId));
} existsSnowFlakeId.add(currentId);
} catch (Exception e) {
e.printStackTrace();
} }
} }
} }

1
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/StringTest.java

@ -47,7 +47,6 @@ public class StringTest {
} }
} }
double during = (System.currentTimeMillis() - start) / 1000.0; double during = (System.currentTimeMillis() - start) / 1000.0;
System.out.println(during);
Assert.assertEquals("1_0000000000_0000000001", origin); Assert.assertEquals("1_0000000000_0000000001", origin);
} }
} }

1
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java

@ -671,7 +671,6 @@ public abstract class UpgradeDao {
taskDefinitionLog.setName(name); taskDefinitionLog.setName(name);
taskDefinitionLog.setWorkerGroup(task.get("workerGroup").asText()); taskDefinitionLog.setWorkerGroup(task.get("workerGroup").asText());
long taskCode = SnowFlakeUtils.getInstance().nextId(); long taskCode = SnowFlakeUtils.getInstance().nextId();
// System.out.println(taskCode);
taskDefinitionLog.setCode(taskCode); taskDefinitionLog.setCode(taskCode);
taskDefinitionLog.setVersion(Constants.VERSION_FIRST); taskDefinitionLog.setVersion(Constants.VERSION_FIRST);
taskDefinitionLog.setProjectCode(processDefinition.getProjectCode()); taskDefinitionLog.setProjectCode(processDefinition.getProjectCode());

1
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveDatasourceProcessorTest.java

@ -59,7 +59,6 @@ public class HiveDatasourceProcessorTest {
PowerMockito.when(CommonUtils.getKerberosStartupState()).thenReturn(false); PowerMockito.when(CommonUtils.getKerberosStartupState()).thenReturn(false);
HiveConnectionParam connectionParams = (HiveConnectionParam) hiveDatasourceProcessor HiveConnectionParam connectionParams = (HiveConnectionParam) hiveDatasourceProcessor
.createConnectionParams(hiveDataSourceParamDTO); .createConnectionParams(hiveDataSourceParamDTO);
System.out.println(JSONUtils.toJsonString(connectionParams));
Assert.assertNotNull(connectionParams); Assert.assertNotNull(connectionParams);
Assert.assertEquals("jdbc:hive2://localhost1:5142,localhost2:5142", connectionParams.getAddress()); Assert.assertEquals("jdbc:hive2://localhost1:5142,localhost2:5142", connectionParams.getAddress());
} }

1
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceProcessorTest.java

@ -58,7 +58,6 @@ public class MysqlDatasourceProcessorTest {
PowerMockito.when(PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test"); PowerMockito.when(PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test");
MysqlConnectionParam connectionParams = (MysqlConnectionParam) mysqlDatasourceProcessor MysqlConnectionParam connectionParams = (MysqlConnectionParam) mysqlDatasourceProcessor
.createConnectionParams(mysqlDatasourceParamDTO); .createConnectionParams(mysqlDatasourceParamDTO);
System.out.println(JSONUtils.toJsonString(connectionParams));
Assert.assertEquals("jdbc:mysql://localhost:3306", connectionParams.getAddress()); Assert.assertEquals("jdbc:mysql://localhost:3306", connectionParams.getAddress());
Assert.assertEquals("jdbc:mysql://localhost:3306/default", connectionParams.getJdbcUrl()); Assert.assertEquals("jdbc:mysql://localhost:3306/default", connectionParams.getJdbcUrl());
} }

1
dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClientTest.java

@ -81,7 +81,6 @@ public class WorkerRegistryClientTest {
@Test @Test
public void testRegistry() { public void testRegistry() {
//workerRegistryClient.initWorkRegistry(); //workerRegistryClient.initWorkRegistry();
// System.out.println(this.workerGroups.iterator());
//Set<String> workerGroups = Sets.newHashSet("127.0.0.1"); //Set<String> workerGroups = Sets.newHashSet("127.0.0.1");
//workerRegistryClient.registry(); //workerRegistryClient.registry();
// workerRegistryClient.handleDeadServer(); // workerRegistryClient.handleDeadServer();

2
dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/queue/TaskPriorityQueueImplTest.java

@ -103,9 +103,7 @@ public class TaskPriorityQueueImplTest {
queue.poll(1000, TimeUnit.MILLISECONDS); queue.poll(1000, TimeUnit.MILLISECONDS);
queue.poll(1000, TimeUnit.MILLISECONDS); queue.poll(1000, TimeUnit.MILLISECONDS);
Assert.assertTrue(queue.size() == 0); Assert.assertTrue(queue.size() == 0);
System.out.println(System.currentTimeMillis());
queue.poll(1000, TimeUnit.MILLISECONDS); queue.poll(1000, TimeUnit.MILLISECONDS);
System.out.println(System.currentTimeMillis());
} }
@Test @Test

5
style/checkstyle.xml

@ -34,6 +34,11 @@
<property name="ignorePattern" value="^ *\* *[^ ]+$"/> <property name="ignorePattern" value="^ *\* *[^ ]+$"/>
</module> </module>
<module name="RegexpSingleline">
<property name="format" value="System\.out\.println"/>
<property name="message" value="Prohibit invoking System.out.println in source code !"/>
</module>
<module name="TreeWalker"> <module name="TreeWalker">
<module name="OuterTypeFilename"> <module name="OuterTypeFilename">
<property name="severity" value="error"/> <property name="severity" value="error"/>

Loading…
Cancel
Save