Skip to content

Commit

Permalink
[ISSUE #2992]Recheck all checkstyle and open checkstyle during buildi…
Browse files Browse the repository at this point in the history
…ng (#3293)

* Re-check code style for nacos-config module.

* Re-check code style for other module.

* Open checkstyle plugin check during build
  • Loading branch information
KomachiSion authored Jul 10, 2020
1 parent 5d65653 commit 95f3bfb
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.junit.Ignore;
import org.junit.Test;

import java.util.Objects;
import java.util.Properties;
import java.util.Scanner;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import com.alibaba.nacos.common.utils.ExceptionUtil;
import com.alibaba.nacos.config.server.constant.Constants;
import com.alibaba.nacos.config.server.model.event.RaftDBErrorEvent;
import com.alibaba.nacos.config.server.model.event.RaftDBErrorRecoverEvent;
import com.alibaba.nacos.config.server.model.event.RaftDbErrorEvent;
import com.alibaba.nacos.config.server.model.event.RaftDbErrorRecoverEvent;
import com.alibaba.nacos.consistency.cp.CPProtocol;
import com.alibaba.nacos.consistency.cp.MetadataKey;
import com.alibaba.nacos.core.cluster.Member;
Expand Down Expand Up @@ -125,18 +125,18 @@ private void registerSubscribe() {
public void onEvent(Event event) {
// @JustForTest
// This event only happens in the case of unit tests
if (event instanceof RaftDBErrorRecoverEvent) {
if (event instanceof RaftDbErrorRecoverEvent) {
isDowngrading = false;
return;
}
if (event instanceof RaftDBErrorEvent) {
if (event instanceof RaftDbErrorEvent) {
isDowngrading = true;
}
}

@Override
public boolean canNotify(Event event) {
return (event instanceof RaftDBErrorEvent) || (event instanceof RaftDBErrorRecoverEvent);
return (event instanceof RaftDbErrorEvent) || (event instanceof RaftDbErrorRecoverEvent);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@
* SameConfigPolicy.
*
* @author klw
* @date 2019/5/21 10:55
*/
public enum SameConfigPolicy {

/**
* @Description: abort import on duplicate
* Abort import on duplicate.
*/
ABORT,

/**
* @Description: skipping on duplicate
* Skipping on duplicate.
*/
SKIP,

/**
* @Description: overwrite on duplicate
* Overwrite on duplicate.
*/
OVERWRITE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@
*
* @author <a href="mailto:[email protected]">liaochuntao</a>
*/
@SuppressWarnings("PMD.ClassNamingShouldBeCamelRule")
public class RaftDBErrorEvent implements SlowEvent {
public class RaftDbErrorEvent implements SlowEvent {

private static final long serialVersionUID = 101591819161802336L;

private Throwable ex;

public RaftDBErrorEvent() {
public RaftDbErrorEvent() {
}

public RaftDBErrorEvent(Throwable ex) {
public RaftDbErrorEvent(Throwable ex) {
this.ex = ex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
*
* @author <a href="mailto:[email protected]">liaochuntao</a>
*/
@SuppressWarnings("PMD.ClassNamingShouldBeCamelRule")
@JustForTest
public class RaftDBErrorRecoverEvent implements Event {
public class RaftDbErrorRecoverEvent implements Event {

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import static com.alibaba.nacos.config.server.utils.LogUtil.MEMORY_LOG;

/**
* Print memory task.
*
* @author zongtanghu
*/
public class PrintMemoryTask implements Runnable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public interface DataSourceService {
/**
* Get current db url.
*
* @return
* @return database url
*/
String getCurrentDBUrl();
String getCurrentDbUrl();

/**
* Get heath information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ List<HikariDataSource> build(Environment environment, Callback<HikariDataSource>
return dataSources;
}

interface Callback<DataSource> {
interface Callback<D> {

/**
* Perform custom logic.
*
* @param dataSource dataSource.
* @param datasource dataSource.
*/
void accept(DataSource dataSource);
void accept(D datasource);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public TransactionTemplate getTransactionTemplate() {
}

@Override
public String getCurrentDBUrl() {
public String getCurrentDbUrl() {
DataSource ds = this.jt.getDataSource();
if (ds == null) {
return StringUtils.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public TransactionTemplate getTransactionTemplate() {
}

@Override
public String getCurrentDBUrl() {
public String getCurrentDbUrl() {
return "jdbc:derby:" + ApplicationUtils.getNacosHome() + File.separator + derbyBaseDir + ";create=true";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public void merge(AbstractTask task) {

final String tag;


public String getGroupKey() {
return groupKey;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.alibaba.nacos.config.server.exception.NJdbcException;
import com.alibaba.nacos.config.server.model.event.ConfigDumpEvent;
import com.alibaba.nacos.config.server.model.event.DerbyLoadEvent;
import com.alibaba.nacos.config.server.model.event.RaftDBErrorEvent;
import com.alibaba.nacos.config.server.model.event.RaftDbErrorEvent;
import com.alibaba.nacos.config.server.service.datasource.DynamicDataSource;
import com.alibaba.nacos.config.server.service.datasource.LocalDataSourceServiceImpl;
import com.alibaba.nacos.config.server.service.dump.DumpConfigHandler;
Expand Down Expand Up @@ -186,19 +186,19 @@ protected void init() throws Exception {
this.transactionTemplate = dataSourceService.getTransactionTemplate();

// Registers a Derby Raft state machine failure event for node degradation processing
NotifyCenter.registerToSharePublisher(RaftDBErrorEvent.class);
NotifyCenter.registerToSharePublisher(RaftDbErrorEvent.class);
// Register the snapshot load event
NotifyCenter.registerToSharePublisher(DerbyLoadEvent.class);

NotifyCenter.registerSubscribe(new Subscribe<RaftDBErrorEvent>() {
NotifyCenter.registerSubscribe(new Subscribe<RaftDbErrorEvent>() {
@Override
public void onEvent(RaftDBErrorEvent event) {
public void onEvent(RaftDbErrorEvent event) {
dataSourceService.setHealthStatus("DOWN");
}

@Override
public Class<? extends Event> subscribeType() {
return RaftDBErrorEvent.class;
return RaftDbErrorEvent.class;
}
});

Expand Down Expand Up @@ -549,7 +549,7 @@ public Response onApply(Log log) {
@Override
public void onError(Throwable throwable) {
// Trigger reversion strategy
NotifyCenter.publishEvent(new RaftDBErrorEvent(throwable));
NotifyCenter.publishEvent(new RaftDbErrorEvent(throwable));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public TransactionTemplate getTransactionTemplate() {

@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
public String getCurrentDBUrl() {
return this.dataSourceService.getCurrentDBUrl();
return this.dataSourceService.getCurrentDbUrl();
}

public DatabaseOperate getDatabaseOperate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public TransactionTemplate getTransactionTemplate() {

@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
public String getCurrentDBUrl() {
return this.dataSourceService.getCurrentDBUrl();
return this.dataSourceService.getCurrentDbUrl();
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion example/src/main/java/com/alibaba/nacos/example/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.nacos.example;

import java.util.Properties;
Expand All @@ -22,7 +23,7 @@
import com.alibaba.nacos.api.naming.NamingService;

/**
* Hello world!
* Hello world.
*
* @author xxc
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.nacos.example;

import java.util.Properties;
Expand All @@ -24,7 +25,7 @@
import com.alibaba.nacos.api.exception.NacosException;

/**
* Config service example
* Config service example.
*
* @author Nacos
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.nacos.example;

import java.util.Properties;
Expand All @@ -25,6 +26,8 @@
import com.alibaba.nacos.api.naming.listener.NamingEvent;

/**
* Nacos naming example.
*
* @author nkorange
*/
public class NamingExample {
Expand All @@ -50,8 +53,8 @@ public static void main(String[] args) throws NacosException {
naming.subscribe("nacos.test.3", new EventListener() {
@Override
public void onEvent(Event event) {
System.out.println(((NamingEvent)event).getServiceName());
System.out.println(((NamingEvent)event).getInstances());
System.out.println(((NamingEvent) event).getServiceName());
System.out.println(((NamingEvent) event).getInstances());
}
});
}
Expand Down
49 changes: 0 additions & 49 deletions example/src/test/java/com/alibaba/nacos/example/AppTest.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.alibaba.nacos.istio.mcp;


/**
* The collection types supported by Nacos.
*
Expand Down
4 changes: 2 additions & 2 deletions style/NacosCheckStyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="severity" value="error"/>
<property name="fileExtensions" value="java, properties, xml"/>

<module name="FileTabCharacter">
Expand Down Expand Up @@ -94,7 +94,7 @@
<property name="minLineCount" value="2"/>
<property name="allowedAnnotations"
value="Override, Test, Before, After, BeforeClass, AfterClass, Parameterized, Parameters, Bean"/>
<property name="ignoreMethodNamesRegex" value="^set[A-Z].*|^get[A-Z].*"/>
<property name="ignoreMethodNamesRegex" value="^set[A-Z].*|^get[A-Z].*|main"/>
<property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF"/>
</module>
<module name="SingleLineJavadoc">
Expand Down
Loading

0 comments on commit 95f3bfb

Please sign in to comment.