Skip to content

Commit

Permalink
[type:feature] upgrade checkstyle plugin to 3.4.0 (#5614)
Browse files Browse the repository at this point in the history
* [type:feature] upgrade checkstyle plugin version and migration checkstyle config

* [type:feature] upgrade checkstyle plugin version and fix checkstyle errors

* [type:feature] upgrade checkstyle plugin version and fix checkstyle errors

* [type:feature] upgrade checkstyle plugin version and fix checkstyle errors

* [type:feature] upgrade checkstyle plugin version and fix checkstyle errors

* [type:feature] upgrade checkstyle plugin version and fix checkstyle errors

* [type:feature] upgrade checkstyle plugin version and fix checkstyle errors

* [type:feature] upgrade checkstyle plugin version and fix checkstyle errors

* [type:feature] upgrade checkstyle plugin version and fix checkstyle errors

* [type:feature] upgrade checkstyle plugin version and fix checkstyle errors

* [type:feature] upgrade checkstyle plugin version and fix checkstyle errors

* [type:feature] recover swagger version
  • Loading branch information
Aias00 authored Aug 26, 2024
1 parent 35155ab commit 1f5b5cd
Show file tree
Hide file tree
Showing 34 changed files with 447 additions and 431 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<versions-maven-plugin.version>2.5</versions-maven-plugin.version>
<maven-checkstyle-plugin.version>3.1.0</maven-checkstyle-plugin.version>
<maven-checkstyle-plugin.version>3.4.0</maven-checkstyle-plugin.version>
<apache-rat-plugin.version>0.15</apache-rat-plugin.version>
<frontend-maven-plugin.version>1.6</frontend-maven-plugin.version>
<frontend-maven-plugin.node.version>v12.14.1</frontend-maven-plugin.node.version>
Expand Down Expand Up @@ -723,6 +723,7 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>/script/shenyu_checkstyle.xml</configLocation>
<headerLocation>/script/checkstyle-header.txt</headerLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
Expand Down
36 changes: 22 additions & 14 deletions script/shenyu_checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
<module name="FileLength">
<property name="max" value="2500"/>
</module>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
<!-- <module name="NewlineAtEndOfFile">-->
<!-- <property name="lineSeparator" value="lf"/>-->
<!-- </module>-->
<module name="Translation"/>
<module name="UniqueProperties"/>
<module name="SeverityMatchFilter"/>
Expand All @@ -50,7 +50,13 @@
<property name="format" value="\.printStackTrace"/>
<property name="message" value="Prohibit invoking .printStackTrace in source code ! Please use org.slf4j.Logger and write log instead."/>
</module>


<module name="LineLength">
<property name="max" value="200"/>
<property name="fileExtensions" value="java"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

<module name="TreeWalker">

<!-- Naming Conventions -->
Expand Down Expand Up @@ -87,10 +93,7 @@
<property name="tokens" value="METHOD_DEF" />
<property name="max" value="80" />
</module>
<module name="LineLength">
<property name="max" value="200"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

<module name="OuterTypeNumber"/>

<!-- Whitespace -->
Expand Down Expand Up @@ -133,7 +136,7 @@
<module name="WhitespaceAfter"/>
<module name="SingleSpaceSeparator"/>
<module name="EmptyLineSeparator">
<property name="allowMultipleEmptyLines" value="false"/>
<property name="allowMultipleEmptyLines" value="true"/>
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
</module>

Expand All @@ -142,7 +145,9 @@
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<module name="CustomImportOrder"/>
<!-- <module name="CustomImportOrder">-->
<!-- <property name="separateLineBetweenGroups" value="true"/>-->
<!-- </module>-->

<!-- Annotations -->
<module name="AnnotationLocation">
Expand All @@ -154,7 +159,9 @@
<property name="tokens" value="VARIABLE_DEF"/>
<property name="allowSamelineMultipleAnnotations" value="true"/>
</module>
<module name="AnnotationUseStyle"/>
<module name="AnnotationUseStyle">
<property name="elementStyle" value="ignore"/>
</module>
<module name="MissingOverride"/>
<module name="SuppressWarnings"/>
<module name="MissingDeprecated"/>
Expand Down Expand Up @@ -235,7 +242,9 @@
<module name="AvoidEscapedUnicodeCharacters"/>
<module name="DescendantToken"/>
<module name="FinalParameters"/>
<module name="Indentation"/>
<module name="Indentation">
<property name="arrayInitIndent" value="8"/>
</module>
<module name="OuterTypeFilename"/>
<module name="TodoComment"/>
<module name="TrailingComment"/>
Expand All @@ -251,9 +260,8 @@
<module name="SingleLineJavadoc"/>
<module name="SummaryJavadoc"/>
<module name="JavadocMethod">
<property name="scope" value="public"/>
<property name="accessModifiers" value="public"/>
<property name="allowedAnnotations" value="Override, Test, Before, After, BeforeClass, AfterClass, Parameterized, Parameters, BeforeEach, AfterEach, BeforeAll, AfterAll, ParameterizedTest, TestMethodOrder"/>
<property name="ignoreMethodNamesRegex" value="^assert.*$|^verify.*$"/>
<property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF"/>
</module>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public DataChangedEventDispatcher(final ApplicationContext applicationContext) {
@SuppressWarnings("unchecked")
public void onApplicationEvent(@NotNull final DataChangedEvent event) {
for (DataChangedListener listener : listeners) {
if ((!(listener instanceof AbstractDataChangedListener))
if (!(listener instanceof AbstractDataChangedListener)
&& clusterProperties.isEnabled()
&& Objects.nonNull(shenyuClusterSelectMasterService)
&& !shenyuClusterSelectMasterService.isMaster()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public List<AppAuthVO> searchByCondition(final AppAuthQuery condition) {
@Transactional(rollbackFor = Exception.class)
public ShenyuAdminResult applyCreate(final AuthApplyDTO authApplyDTO) {
if (StringUtils.isBlank(authApplyDTO.getAppName())
|| (authApplyDTO.getOpen() && CollectionUtils.isEmpty(authApplyDTO.getPathList()))) {
|| authApplyDTO.getOpen() && CollectionUtils.isEmpty(authApplyDTO.getPathList())) {
return ShenyuAdminResult.error(ShenyuResultMessage.PARAMETER_ERROR);
}
AppAuthDO appAuthDO = AppAuthDO.create(authApplyDTO);
Expand Down Expand Up @@ -141,7 +141,7 @@ public ShenyuAdminResult applyCreate(final AuthApplyDTO authApplyDTO) {
@Override
public ShenyuAdminResult applyUpdate(final AuthApplyDTO authApplyDTO) {
if (StringUtils.isAnyBlank(authApplyDTO.getAppKey(), authApplyDTO.getAppName())
|| (authApplyDTO.getOpen() && CollectionUtils.isEmpty(authApplyDTO.getPathList()))) {
|| authApplyDTO.getOpen() && CollectionUtils.isEmpty(authApplyDTO.getPathList())) {
return ShenyuAdminResult.error(ShenyuResultMessage.PARAMETER_ERROR);
}
AppAuthDO appAuthDO = appAuthMapper.findByAppKey(authApplyDTO.getAppKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class LocalDataSourceLoader implements InstantiationAwareBeanPostProcesso

@Override
public Object postProcessAfterInitialization(@NonNull final Object bean, @NonNull final String beanName) throws BeansException {
if ((bean instanceof DataSourceProperties) && Boolean.TRUE.equals(dataBaseProperties.getInitEnable())) {
if (bean instanceof DataSourceProperties && Boolean.TRUE.equals(dataBaseProperties.getInitEnable())) {
this.init((DataSourceProperties) bean);
}
return bean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.shenyu.admin.model.query;

import org.apache.shenyu.admin.AbstractReflectGetterSetterTest;
import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.Set;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;

/**
* Test case for TagRelationQuery.
*/
public class TagRelationQueryTest extends AbstractReflectGetterSetterTest {
@Override
protected Class<?> getTargetClass() {
return TagRelationQuery.class;
}

@Test
public void testEqualsAndHashCode() {
TagRelationQuery tagRelationQuery1 = TagRelationQuery.builder().apiId("apiId").tagId("tagId").build();
TagRelationQuery tagRelationQuery2 = TagRelationQuery.builder().apiId("apiId").tagId("tagId").build();

Set<TagRelationQuery> set = new HashSet<>();
set.add(tagRelationQuery1);
set.add(tagRelationQuery2);

assertThat(set, hasSize(1));
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.shenyu.admin.model.query;

import org.apache.shenyu.admin.AbstractReflectGetterSetterTest;
import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.Set;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;

/**
* Test case for TagRelationQuery.
*/
public class TagRelationQueryTest extends AbstractReflectGetterSetterTest {
@Override
protected Class<?> getTargetClass() {
return TagRelationQuery.class;
}

@Test
public void testEqualsAndHashCode() {
TagRelationQuery tagRelationQuery1 = TagRelationQuery.builder().apiId("apiId").tagId("tagId").build();
TagRelationQuery tagRelationQuery2 = TagRelationQuery.builder().apiId("apiId").tagId("tagId").build();

Set<TagRelationQuery> set = new HashSet<>();
set.add(tagRelationQuery1);
set.add(tagRelationQuery2);

assertThat(set, hasSize(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected D preParse(final ApiBean apiBean) {
* Parses the apiDefinition as a registrable objects.
*
* @param apiDefinition apiDefinition to be parsed
* @return
* @return registrable objects
*/
protected abstract List<D> parse(ApiBean.ApiDefinition apiDefinition);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public final class ObjectTypeUtils {
* @return true is basic
*/
public static boolean isBasicType(final Object object) {
return (object instanceof Integer)
|| (object instanceof Byte)
|| (object instanceof Long)
|| (object instanceof Double)
|| (object instanceof Float)
|| (object instanceof Short)
|| (object instanceof Boolean)
|| (object instanceof CharSequence);
return object instanceof Integer
|| object instanceof Byte
|| object instanceof Long
|| object instanceof Double
|| object instanceof Float
|| object instanceof Short
|| object instanceof Boolean
|| object instanceof CharSequence;
}
}
2 changes: 1 addition & 1 deletion shenyu-e2e/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<jetbrains-annotations.version>23.0.0</jetbrains-annotations.version>
<apache-rat-plugin.version>0.15</apache-rat-plugin.version>
<spring-framework.version>5.3.30</spring-framework.version>
<maven-checkstyle-plugin.version>3.1.0</maven-checkstyle-plugin.version>
<maven-checkstyle-plugin.version>3.4.0</maven-checkstyle-plugin.version>
<guava.version>32.0.0-jre</guava.version>
<commons-collection.verion>4.4</commons-collection.verion>
<websocket.version>1.5.1</websocket.version>
Expand Down
3 changes: 2 additions & 1 deletion shenyu-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<versions-maven-plugin.version>2.5</versions-maven-plugin.version>
<docker-maven-plugin.version>0.40.1</docker-maven-plugin.version>
<maven-checkstyle-plugin.version>3.1.0</maven-checkstyle-plugin.version>
<maven-checkstyle-plugin.version>3.4.0</maven-checkstyle-plugin.version>
<swagger.version>2.6.0</swagger.version>
</properties>

Expand Down Expand Up @@ -91,6 +91,7 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>/../script/shenyu_checkstyle.xml</configLocation>
<headerLocation>/../script/checkstyle-header.txt</headerLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ protected void handleTextMessage(final WebSocketSession session, final TextMessa
String payload = message.getPayload();
Object token = session.getAttributes().get("token");
LOG.info("server received {}, sent {}", token, payload);
boolean isTestClose = (Objects.nonNull(token) && Objects.equals(token, "testCloseStatus"))
|| (Objects.nonNull(payload) && Objects.equals(payload, "testCloseStatus"));
boolean isTestClose = Objects.nonNull(token) && Objects.equals(token, "testCloseStatus")
|| Objects.nonNull(payload) && Objects.equals(payload, "testCloseStatus");
if (isTestClose) {
session.close(new CloseStatus(4400, "test:apache shenyu server close, return closeStatus"));
} else {
Expand Down
3 changes: 2 additions & 1 deletion shenyu-integrated-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<tars-client.version>1.7.2</tars-client.version>
<!-- <sofa-rpc-all.version>5.13.0</sofa-rpc-all.version>-->
<!-- <curator.version>4.0.1</curator.version>-->
<maven-checkstyle-plugin.version>3.1.0</maven-checkstyle-plugin.version>
<maven-checkstyle-plugin.version>3.4.0</maven-checkstyle-plugin.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -132,6 +132,7 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>/../script/shenyu_checkstyle.xml</configLocation>
<headerLocation>/../script/checkstyle-header.txt</headerLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void testResponseTimeBalancer() throws Exception {
final LeastActiveLoadBalance leastActiveLoadBalance = new LeastActiveLoadBalance();
Upstream upstream = leastActiveLoadBalance.doSelect(onlyOneList, "localhost");
Upstream upstream1 = leastActiveLoadBalance.doSelect(onlyOneList, "localhost");
Assertions.assertTrue((upstream.getUrl().equals("baidu.com") && upstream1.getUrl().equals("pro.jd.com"))
Assertions.assertTrue(upstream.getUrl().equals("baidu.com") && upstream1.getUrl().equals("pro.jd.com")
|| upstream1.getUrl().equals("baidu.com") && upstream.getUrl().equals("pro.jd.com"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testResponseTimeBalancerSameLag() {
final P2cLoadBalancer p2cLoadBalancer = new P2cLoadBalancer();
Upstream upstream = p2cLoadBalancer.doSelect(upstreamList, "localhost");
Upstream upstream1 = p2cLoadBalancer.doSelect(upstreamList, "localhost");
Assertions.assertTrue((upstream.getUrl().equals("baidu.com") && upstream1.getUrl().equals("pro.jd.com"))
Assertions.assertTrue(upstream.getUrl().equals("baidu.com") && upstream1.getUrl().equals("pro.jd.com")
|| upstream1.getUrl().equals("baidu.com") && upstream.getUrl().equals("pro.jd.com"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ default Object result(ServerWebExchange exchange, Object formatted) {
*/
default Object format(ServerWebExchange exchange, Object origin) {
// basic data or upstream data
if (ObjectTypeUtils.isBasicType(origin) || (origin instanceof byte[])) {
if (ObjectTypeUtils.isBasicType(origin) || origin instanceof byte[]) {
return origin;
}
// error result or rpc origin result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public static URI buildRequestUri(final ServerWebExchange exchange, final String
}
}
URI uri = exchange.getRequest().getURI();
if ((StringUtils.isNotEmpty(uri.getRawQuery()) && uri.getRawQuery().contains("%"))
|| (StringUtils.isNotEmpty(uri.getRawPath()) && uri.getRawPath().contains("%"))) {
if (StringUtils.isNotEmpty(uri.getRawQuery()) && uri.getRawQuery().contains("%")
|| StringUtils.isNotEmpty(uri.getRawPath()) && uri.getRawPath().contains("%")) {
path = path + "?" + RequestQueryCodecUtil.getCodecQuery(exchange);
return UriComponentsBuilder.fromUriString(path).build(true).toUri();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private void sortPluginIfOrderChange(final PluginData oldPluginData, final Plugi
return;
}
if (Objects.isNull(oldPluginData) || Objects.isNull(oldPluginData.getSort())
|| (!Objects.equals(oldPluginData.getSort(), pluginData.getSort()))) {
|| !Objects.equals(oldPluginData.getSort(), pluginData.getSort())) {
eventPublisher.publishEvent(new PluginHandlerEvent(PluginHandlerEventEnum.SORTED, pluginData));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ public ShenyuTrieNode match(final String uriPath, final String bizInfo) {
ShenyuTrieNode newCurrentNode = currentNode.getFailToNode();
// search failToNode's parentNode
ShenyuTrieNode parentNode = newCurrentNode.getParentNode();
if (Objects.isNull(parentNode) || (Objects.nonNull(parentNode.getFailToNode()) && Objects.nonNull(newCurrentNode.getFailToNode())
if (Objects.isNull(parentNode) || Objects.nonNull(parentNode.getFailToNode()) && Objects.nonNull(newCurrentNode.getFailToNode())
&& completeResolveConflict(parentNode, wildcard, matchAll, pathVariable, startIndex)
&& parentNode.getFailToNode().equals(newCurrentNode.getFailToNode()) && "/".equals(parentNode.getParentNode().getMatchStr()))) {
&& parentNode.getFailToNode().equals(newCurrentNode.getFailToNode()) && "/".equals(parentNode.getParentNode().getMatchStr())) {
return null;
}
startIndex--;
Expand All @@ -349,7 +349,7 @@ && completeResolveConflict(parentNode, wildcard, matchAll, pathVariable, startIn
startIndex++;
continue;
}
if ((startIndex == pathParts.length - 1 && checkNode(currentNode, bizInfo)) || (Objects.nonNull(currentNode) && isMatchAll(currentNode.getMatchStr()) && checkNode(currentNode, bizInfo))) {
if (startIndex == pathParts.length - 1 && checkNode(currentNode, bizInfo) || Objects.nonNull(currentNode) && isMatchAll(currentNode.getMatchStr()) && checkNode(currentNode, bizInfo)) {
return currentNode;
}
}
Expand Down
Loading

0 comments on commit 1f5b5cd

Please sign in to comment.