Skip to content

Commit 244a734

Browse files
committed
Adopt Spring Java Format for code formatting and style
1 parent 7431426 commit 244a734

File tree

157 files changed

+531
-1119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+531
-1119
lines changed

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ buildscript {
33
mavenCentral()
44
maven { url 'https://repo.spring.io/plugins-release' }
55
maven { url 'https://plugins.gradle.org/m2/' }
6+
mavenLocal()
67
}
78
dependencies {
89
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
910
classpath 'io.spring.gradle:spring-io-plugin:0.0.8.RELEASE'
1011
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2'
12+
classpath "io.spring.javaformat:spring-javaformat-gradle-plugin:$javaFormatVersion"
1113
}
1214
}
1315

1416
allprojects {
1517
group = 'org.springframework.restdocs'
1618
repositories {
1719
mavenCentral()
20+
mavenLocal()
1821
}
1922
}
2023

@@ -103,7 +106,7 @@ subprojects {
103106
}
104107

105108
configure(subprojects - project(":docs")) { subproject ->
106-
109+
apply plugin: 'io.spring.javaformat'
107110
apply plugin: 'checkstyle'
108111
apply from: "${rootProject.projectDir}/gradle/publish-maven.gradle"
109112

@@ -134,6 +137,7 @@ configure(subprojects - project(":docs")) { subproject ->
134137
}
135138

136139
dependencies {
140+
checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:$javaFormatVersion"
137141
jacoco 'org.jacoco:org.jacoco.agent::runtime'
138142
}
139143

config/checkstyle/checkstyle-header.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

config/checkstyle/checkstyle-import-control.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

config/checkstyle/checkstyle-suppressions.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

config/checkstyle/checkstyle.xml

Lines changed: 4 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,5 @@
11
<?xml version="1.0"?>
2-
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
3-
<module name="Checker">
4-
5-
<!-- Root Checks -->
6-
<module name="RegexpHeader">
7-
<property name="headerFile" value="${checkstyle.config.dir}/checkstyle-header.txt" />
8-
<property name="fileExtensions" value="java" />
9-
</module>
10-
<module name="NewlineAtEndOfFile" />
11-
12-
<module name="SuppressionFilter">
13-
<property name="file" value="${checkstyle.config.dir}/checkstyle-suppressions.xml"/>
14-
</module>
15-
16-
<!-- TreeWalker Checks -->
17-
<module name="TreeWalker">
18-
19-
<!-- Annotations -->
20-
<module name="AnnotationUseStyle">
21-
<property name="elementStyle" value="compact" />
22-
</module>
23-
<module name="MissingOverride" />
24-
<module name="PackageAnnotation" />
25-
<module name="AnnotationLocation">
26-
<property name="allowSamelineSingleParameterlessAnnotation"
27-
value="false" />
28-
</module>
29-
30-
<!-- Block Checks -->
31-
<module name="EmptyBlock">
32-
<property name="option" value="text" />
33-
</module>
34-
<module name="LeftCurly" />
35-
<module name="RightCurly">
36-
<property name="option" value="alone" />
37-
</module>
38-
<module name="NeedBraces" />
39-
<module name="AvoidNestedBlocks" />
40-
41-
<!-- Class Design -->
42-
<module name="FinalClass" />
43-
<module name="InterfaceIsType" />
44-
<module name="HideUtilityClassConstructor" />
45-
<module name="MutableException" />
46-
<module name="InnerTypeLast" />
47-
<module name="OneTopLevelClass" />
48-
49-
<!-- Coding -->
50-
<module name="CovariantEquals" />
51-
<module name="EmptyStatement" />
52-
<module name="EqualsHashCode" />
53-
<module name="InnerAssignment" />
54-
<module name="SimplifyBooleanExpression" />
55-
<module name="SimplifyBooleanReturn" />
56-
<module name="StringLiteralEquality" />
57-
<module name="NestedForDepth">
58-
<property name="max" value="3" />
59-
</module>
60-
<module name="NestedIfDepth">
61-
<property name="max" value="3" />
62-
</module>
63-
<module name="NestedTryDepth">
64-
<property name="max" value="3" />
65-
</module>
66-
<module name="MultipleVariableDeclarations" />
67-
<module name="RequireThis">
68-
<property name="checkMethods" value="false" />
69-
</module>
70-
<module name="OneStatementPerLine" />
71-
72-
<!-- Imports -->
73-
<module name="AvoidStarImport" />
74-
<module name="AvoidStaticImport">
75-
<property name="excludes"
76-
value="com.jayway.restassured.RestAssured.*, io.restassured.RestAssured.*, org.assertj.core.api.Assertions.*, org.hamcrest.CoreMatchers.*, org.hamcrest.Matchers.*, org.mockito.Mockito.*, org.mockito.BDDMockito.*, org.mockito.Matchers.*, org.springframework.restdocs.cli.CliDocumentation.*, org.springframework.restdocs.headers.HeaderDocumentation.*, org.springframework.restdocs.hypermedia.HypermediaDocumentation.*, org.springframework.restdocs.mockmvc.IterableEnumeration.*, org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.*, org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*, org.springframework.restdocs.payload.PayloadDocumentation.*, org.springframework.restdocs.operation.preprocess.Preprocessors.*, org.springframework.restdocs.request.RequestDocumentation.*, org.springframework.restdocs.restassured.RestAssuredRestDocumentation.*, org.springframework.restdocs.restassured.operation.preprocess.RestAssuredPreprocessors.*, org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.*, org.springframework.restdocs.restassured3.operation.preprocess.RestAssuredPreprocessors.*, org.springframework.restdocs.snippet.Attributes.*, org.springframework.restdocs.templates.TemplateFormats.*, org.springframework.restdocs.test.SnippetConditions.*, org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*, org.springframework.test.web.servlet.result.MockMvcResultMatchers.*" />
77-
</module>
78-
<module name="IllegalImport" />
79-
<module name="RedundantImport" />
80-
<module name="UnusedImports">
81-
<property name="processJavadoc" value="true" />
82-
</module>
83-
<module name="ImportOrder">
84-
<property name="groups" value="java,/^javax?\./,*,org.springframework" />
85-
<property name="ordered" value="true" />
86-
<property name="separated" value="true" />
87-
<property name="option" value="bottom" />
88-
<property name="sortStaticImportsAlphabetically" value="true" />
89-
</module>
90-
<module name="ImportControl">
91-
<property name="file" value="${checkstyle.config.dir}/checkstyle-import-control.xml"/>
92-
</module>
93-
94-
<!-- Javadoc Comments -->
95-
<module name="JavadocType">
96-
<property name="scope" value="package"/>
97-
<property name="authorFormat" value=".+\s.+"/>
98-
</module>
99-
<module name="JavadocMethod">
100-
<property name="scope" value="protected"/>
101-
</module>
102-
<module name="JavadocVariable">
103-
<property name="scope" value="protected"/>
104-
</module>
105-
<module name="JavadocStyle">
106-
<property name="checkEmptyJavadoc" value="true"/>
107-
</module>
108-
<module name="NonEmptyAtclauseDescription"/>
109-
<module name="JavadocTagContinuationIndentation">
110-
<property name="offset" value="0"/>
111-
</module>
112-
<module name="AtclauseOrder">
113-
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF"/>
114-
<property name="tagOrder" value="@param, @author, @since, @see, @version, @serial, @deprecated"/>
115-
</module>
116-
<module name="AtclauseOrder">
117-
<property name="target" value="METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
118-
<property name="tagOrder" value="@param, @return, @throws, @since, @deprecated, @see"/>
119-
</module>
120-
121-
<!-- Miscellaneous -->
122-
<module name="CommentsIndentation" />
123-
<module name="UpperEll" />
124-
<module name="ArrayTypeStyle" />
125-
<module name="OuterTypeFilename" />
126-
127-
<!-- Modifiers -->
128-
<module name="RedundantModifier" />
129-
130-
<!-- Regexp -->
131-
<module name="RegexpSinglelineJava">
132-
<property name="format" value="^\t* +\t*\S" />
133-
<property name="message"
134-
value="Line has leading space characters; indentation should be performed with tabs only." />
135-
<property name="ignoreComments" value="true" />
136-
</module>
137-
<module name="Regexp">
138-
<property name="format" value="[ \t]+$" />
139-
<property name="illegalPattern" value="true" />
140-
<property name="message" value="Trailing whitespace" />
141-
</module>
142-
143-
<!-- Whitespace -->
144-
<module name="GenericWhitespace" />
145-
<module name="MethodParamPad" />
146-
<module name="NoWhitespaceAfter" >
147-
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS, ARRAY_DECLARATOR"/>
148-
</module>
149-
<module name="NoWhitespaceBefore" />
150-
<module name="ParenPad" />
151-
<module name="TypecastParenPad" />
152-
<module name="WhitespaceAfter" />
153-
<module name="WhitespaceAround" />
154-
155-
</module>
156-
</module>
2+
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
3+
<module name="com.puppycrawl.tools.checkstyle.Checker">
4+
<module name="io.spring.javaformat.checkstyle.SpringChecks" />
5+
</module>

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
javaFormatVersion=0.0.7-SNAPSHOT
12
version=1.2.6.BUILD-SNAPSHOT
2-
org.gradle.daemon=false
3+
org.gradle.daemon=false

spring-restdocs-core/src/main/java/org/springframework/restdocs/JUnitRestDocumentation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public JUnitRestDocumentation() {
4343
/**
4444
* Creates a new {@code JUnitRestDocumentation} instance that will generate snippets
4545
* to the given {@code outputDirectory}.
46-
*
4746
* @param outputDirectory the output directory
4847
*/
4948
public JUnitRestDocumentation(String outputDirectory) {

spring-restdocs-core/src/main/java/org/springframework/restdocs/ManualRestDocumentation.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public ManualRestDocumentation() {
4646
/**
4747
* Creates a new {@code ManualRestDocumentation} instance that will generate snippets
4848
* to the given {@code outputDirectory}.
49-
*
5049
* @param outputDirectory the output directory
5150
*/
5251
public ManualRestDocumentation(String outputDirectory) {
@@ -62,7 +61,6 @@ private ManualRestDocumentation(File outputDirectory) {
6261
* {@link RestDocumentationContext} for the test on the given {@code testClass} with
6362
* the given {@code testMethodName}. Must be followed by a call to
6463
* {@link #afterTest()} once the test has completed.
65-
*
6664
* @param testClass the test class
6765
* @param testMethodName the name of the test method
6866
* @throws IllegalStateException if a context has already be created

spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public RestDocumentation() {
4343
/**
4444
* Creates a new {@code RestDocumentation} instance that will generate snippets to the
4545
* given {@code outputDirectory}.
46-
*
4746
* @param outputDirectory the output directory
4847
*/
4948
public RestDocumentation(String outputDirectory) {

spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationContext.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public final class RestDocumentationContext {
3939
* Creates a new {@code RestDocumentationContext} for a test on the given
4040
* {@code testClass} with given {@code testMethodName} that will generate
4141
* documentation to the given {@code outputDirectory}.
42-
*
4342
* @param testClass the class whose test is being executed
4443
* @param testMethodName the name of the test method that is being executed
4544
* @param outputDirectory the directory to which documentation should be written.
@@ -55,43 +54,38 @@ public RestDocumentationContext(Class<?> testClass, String testMethodName,
5554

5655
/**
5756
* Returns the class whose tests are currently executing.
58-
*
59-
* @return The test class
57+
* @return the test class
6058
*/
6159
public Class<?> getTestClass() {
6260
return this.testClass;
6361
}
6462

6563
/**
6664
* Returns the name of the test method that is currently executing.
67-
*
68-
* @return The name of the test method
65+
* @return the name of the test method
6966
*/
7067
public String getTestMethodName() {
7168
return this.testMethodName;
7269
}
7370

7471
/**
7572
* Returns the current step count and then increments it.
76-
*
77-
* @return The step count prior to it being incremented
73+
* @return the step count prior to it being incremented
7874
*/
7975
int getAndIncrementStepCount() {
8076
return this.stepCount.getAndIncrement();
8177
}
8278

8379
/**
8480
* Returns the current step count.
85-
*
86-
* @return The current step count
81+
* @return the current step count
8782
*/
8883
public int getStepCount() {
8984
return this.stepCount.get();
9085
}
9186

9287
/**
9388
* Returns the output directory to which generated snippets should be written.
94-
*
9589
* @return the output directory
9690
*/
9791
public File getOutputDirectory() {

0 commit comments

Comments
 (0)