Skip to content

Commit

Permalink
🎨 根据 Spring checkstyle 规则对代码进行格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
Hccake committed Jan 22, 2024
1 parent c221b89 commit 6d65c6d
Show file tree
Hide file tree
Showing 473 changed files with 2,387 additions and 1,827 deletions.
9 changes: 7 additions & 2 deletions .etc/checkstyle/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress files="org.bson.types.ObjectId" checks="io.spring.javaformat.checkstyle.check.SpringHeaderCheck" />
<suppress files="com.alibaba.excel.*.*\.java" checks="io.spring.javaformat.checkstyle.check.SpringHeaderCheck" />
<suppress files="org.bson.types.ObjectId" checks="[a-zA-Z0-9]*" />
<suppress files="com.alibaba.excel.*.*\.java" checks="[a-zA-Z0-9]*" />

<suppress files="org.ballcat.easyexcel.application.ExcelTestApplication" checks="HideUtilityClassConstructorCheck" />
<suppress files="org.ballcat.autoconfigure.web.accesslog.TestApplication" checks="HideUtilityClassConstructorCheck" />
<suppress files="org.ballcat.pay.wx.domain.DefaultWxDomain" checks="FinalClassCheck" />
<suppress files="org.ballcat.autoconfigure.redis.RedisKeyEventAutoConfiguration" checks="HideUtilityClassConstructorCheck" />
</suppressions>
156 changes: 155 additions & 1 deletion .etc/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,158 @@
<property name="headerCopyrightPattern" value="20\d\d-20\d\d"/>
<property name="packageInfoHeaderType" value="none"/>
</module>
</module>

<!-- 文件必须以新行结尾 -->
<module name="com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck"/>

<!-- TreeWalker Checks -->
<module name="com.puppycrawl.tools.checkstyle.TreeWalker">
<!-- Annotations -->
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck">
<property name="elementStyle" value="compact" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.MissingOverrideCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.PackageAnnotationCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck">
<property name="allowSamelineSingleParameterlessAnnotation"
value="false" />
</module>

<!-- Block Checks -->
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck">
<property name="option" value="text" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck">
<property name="option" value="alone" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.AvoidNestedBlocksCheck" />

<!-- Class Design -->
<module name="com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.design.InterfaceIsTypeCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.design.MutableExceptionCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.design.InnerTypeLastCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck" />

<!-- Coding -->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.CovariantEqualsCheck" />-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck" />-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck" />-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck" />-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanExpressionCheck" />-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanReturnCheck" />-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.StringLiteralEqualityCheck" />-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedForDepthCheck">-->
<!-- <property name="max" value="3" />-->
<!-- </module>-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedIfDepthCheck">-->
<!-- <property name="max" value="3" />-->
<!-- </module>-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedTryDepthCheck">-->
<!-- <property name="max" value="3" />-->
<!-- </module>-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclarationsCheck" />-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck">-->
<!-- <property name="checkMethods" value="false" />-->
<!-- <property name="validateOnlyOverlapping" value="false" />-->
<!-- </module>-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck" />-->

<!-- Imports -->
<module name="com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.imports.AvoidStaticImportCheck">
<property name="excludes"
value="org.assertj.core.api.Assertions.*, org.junit.Assert.*, org.junit.Assume.*, org.junit.internal.matchers.ThrowableMessageMatcher.*, org.junit.jupiter.api.Assertions.*, org.hamcrest.CoreMatchers.*, org.hamcrest.Matchers.*, org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.*, org.springframework.boot.configurationprocessor.TestCompiler.*, org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.*, org.mockito.Mockito.*, org.mockito.BDDMockito.*, org.mockito.Matchers.*, org.mockito.ArgumentMatchers.*, org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.*, org.springframework.restdocs.hypermedia.HypermediaDocumentation.*, org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*, org.springframework.test.web.servlet.result.MockMvcResultMatchers.*, org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.*, org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*, org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*, org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo, org.springframework.test.web.client.match.MockRestRequestMatchers.*, org.springframework.test.web.client.response.MockRestResponseCreators.*, org.springframework.web.reactive.function.server.RequestPredicates.*, org.springframework.web.reactive.function.server.RouterFunctions.*, org.springframework.test.web.servlet.setup.MockMvcBuilders.*, io.swagger.v3.oas.annotations.media.Schema.RequiredMode.*, java.lang.annotation.ElementType.*, java.lang.annotation.RetentionPolicy.*, org.springframework.test.web.servlet.result.MockMvcResultHandlers.*, org.ballcat.springsecurity.oauth2.server.authorization.authentication.OAuth2AuthenticationProviderUtils.*" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck">
<property name="processJavadoc" value="true" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck">
<property name="groups" value="java,/^javax?\./,*,io.spring" />
<property name="ordered" value="true" />
<property name="separated" value="true" />
<property name="option" value="bottom" />
<property name="sortStaticImportsAlphabetically" value="true" />
</module>

<!-- Javadoc Comments -->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck">-->
<!-- <property name="scope" value="package"/>-->
<!-- <property name="authorFormat" value=".+\s.+"/>-->
<!-- </module>-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck" />-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck">-->
<!-- <property name="scope" value="public"/>-->
<!-- </module>-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck">-->
<!-- <property name="checkEmptyJavadoc" value="true"/>-->
<!-- </module>-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.NonEmptyAtclauseDescriptionCheck" />-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTagContinuationIndentationCheck">-->
<!-- <property name="offset" value="0"/>-->
<!-- </module>-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.AtclauseOrderCheck">-->
<!-- <property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF"/>-->
<!-- <property name="tagOrder" value="@param, @author, @since, @see, @version, @serial, @deprecated"/>-->
<!-- </module>-->
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.AtclauseOrderCheck">-->
<!-- <property name="target" value="METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>-->
<!-- <property name="tagOrder" value="@param, @return, @throws, @since, @deprecated, @see"/>-->
<!-- </module>-->

<!-- Miscellaneous -->
<module name="com.puppycrawl.tools.checkstyle.checks.indentation.CommentsIndentationCheck">
<property name="tokens" value="BLOCK_COMMENT_BEGIN"/>
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.ArrayTypeStyleCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheck" />

<!-- Modifiers -->
<module name="com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck" />

<!-- Regexp -->
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
<property name="format" value="^\t* +\t*\S" />
<property name="message"
value="Line has leading space characters; indentation should be performed with tabs only." />
<property name="ignoreComments" value="true" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
<property name="maximum" value="0"/>
<property name="format" value="org\.mockito\.Mockito\.(when|doThrow|doAnswer)" />
<property name="message"
value="Please use BDDMockito imports." />
<property name="ignoreComments" value="true" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
<property name="maximum" value="0"/>
<property name="format" value="org\.junit\.Assert\.assert" />
<property name="message"
value="Please use AssertJ imports." />
<property name="ignoreComments" value="true" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpCheck">
<property name="format" value="[ \t]+$" />
<property name="illegalPattern" value="true" />
<property name="message" value="Trailing whitespace" />
</module>

<!-- Whitespace -->
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceAfterCheck" >
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS, ARRAY_DECLARATOR"/>
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck" />
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck" />
</module>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,28 @@

package org.ballcat.common.core.constant;

import org.ballcat.common.core.https.CompatibleSSLFactory;
import org.ballcat.common.core.https.SSLSocketFactoryInitException;
import lombok.experimental.UtilityClass;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import org.ballcat.common.core.https.CompatibleSSLFactory;
import org.ballcat.common.core.https.SSLSocketFactoryInitException;

/**
* @author lingting
*/
@UtilityClass
@SuppressWarnings("java:S4830")
public class HttpsConstants {
public final class HttpsConstants {

private HttpsConstants() {
}

public static final String SSL = "SSL";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

package org.ballcat.common.core.exception;

import java.text.MessageFormat;

import lombok.Getter;
import org.ballcat.common.model.result.ResultCode;

import java.text.MessageFormat;

/**
* 通用业务异常
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@

package org.ballcat.common.core.https;

import org.ballcat.common.core.constant.HttpsConstants;
import org.ballcat.common.util.ArrayUtils;

import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
Expand All @@ -32,6 +24,15 @@
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;

import org.ballcat.common.core.constant.HttpsConstants;
import org.ballcat.common.util.ArrayUtils;

/**
* 用于兼容 android 使用
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

package org.ballcat.common.core.jackson;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jsr310.PackageVersion;
import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer;
Expand All @@ -28,12 +34,6 @@
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
import org.ballcat.common.util.LocalDateTimeUtils;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

/**
* 自定义java8新增时间类型的序列化
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package org.ballcat.common.core.jackson;

import java.io.IOException;
import java.io.Serializable;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.io.Serializable;

/**
* 空数组序列化处理器 如果 Array 为 null,则序列化为 []
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package org.ballcat.common.core.jackson;

import java.io.IOException;
import java.io.Serializable;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.io.Serializable;

/**
* 空 Map 序列化处理器 Map 为 null,则序列化为 {}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package org.ballcat.common.core.jackson;

import java.util.Collection;
import java.util.Map;

import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
Expand All @@ -25,9 +28,6 @@
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
import com.fasterxml.jackson.databind.ser.SerializerFactory;

import java.util.Collection;
import java.util.Map;

/**
* <p>
* 修改了 Null 值的序列化器提供者
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package org.ballcat.common.core.jackson;

import java.io.IOException;
import java.io.Serializable;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.io.Serializable;

/**
* jackson NULL值序列化为 ""
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

package org.ballcat.common.core.request.wrapper;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

/**
* 用于修改 Request Parameter 的 HttpServletRequestWrapper
*
Expand Down Expand Up @@ -60,4 +61,4 @@ public String[] getParameterValues(String name) {
return this.parameterMap.get(name);
}

}
}
Loading

0 comments on commit 6d65c6d

Please sign in to comment.