Skip to content

Commit b04540b

Browse files
Add spotless and checkstyle (#5383)
Co-authored-by: Sergei Egorov <[email protected]>
1 parent fffab55 commit b04540b

File tree

5 files changed

+81
-2
lines changed

5 files changed

+81
-2
lines changed

build.gradle

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ plugins {
1313
id 'io.franzbecker.gradle-lombok' version '5.0.0'
1414
id 'com.github.johnrengelman.shadow' version '7.0.0'
1515
id 'me.champeau.gradle.japicmp' version '0.2.9' apply false
16+
id 'com.diffplug.spotless' version '6.3.0' apply false
1617
}
1718

1819
apply from: "$rootDir/gradle/ci-support.gradle"
@@ -22,6 +23,8 @@ subprojects {
2223
apply plugin: 'idea'
2324
apply plugin: 'io.franzbecker.gradle-lombok'
2425
apply from: "$rootDir/gradle/shading.gradle"
26+
apply plugin: 'com.diffplug.spotless'
27+
apply plugin: 'checkstyle'
2528

2629
group = "org.testcontainers"
2730

@@ -105,4 +108,32 @@ subprojects {
105108
dependencies {
106109
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
107110
}
111+
112+
spotless {
113+
enforceCheck false
114+
java {
115+
removeUnusedImports()
116+
trimTrailingWhitespace()
117+
endWithNewline()
118+
119+
prettier(['prettier': '2.5.1', 'prettier-plugin-java': '1.6.1'])
120+
.config([
121+
'parser' : 'java',
122+
'tabWidth' : 4,
123+
'printWidth': 120
124+
])
125+
126+
importOrder('', 'java', 'javax', '\\#')
127+
}
128+
groovyGradle {
129+
target '**/*.groovy'
130+
greclipse('4.19.0')
131+
}
132+
}
133+
134+
checkstyle {
135+
toolVersion = "9.3"
136+
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
137+
ignoreFailures = true
138+
}
108139
}

config/checkstyle/checkstyle.xml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
2+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
3+
<module name="Checker">
4+
<module name="TreeWalker">
5+
<module name="SuppressionCommentFilter"/>
6+
<module name="NeedBraces">
7+
<property name="tokens"
8+
value="
9+
LITERAL_DO,
10+
LITERAL_ELSE,
11+
LITERAL_FOR,
12+
LITERAL_IF,
13+
LITERAL_WHILE,
14+
LITERAL_CASE,
15+
LITERAL_DEFAULT,
16+
LAMBDA,
17+
"
18+
/>
19+
<property name="allowSingleLineStatement" value="true"/>
20+
</module>
21+
<module name="AvoidStaticImport">
22+
<property name="excludes"
23+
value="
24+
io.restassured.RestAssured.*,
25+
org.assertj.core.api.Assertions.*,
26+
org.assertj.core.api.Assumptions.*,
27+
org.awaitility.Awaitility.*,
28+
org.hamcrest.Matchers.*,
29+
org.hamcrest.MatcherAssert.*,
30+
org.junit.Assert.*,
31+
org.junit.Assume.*,
32+
org.junit.jupiter.api.Assertions.*,
33+
org.mockito.Mockito.*,
34+
org.mockito.ArgumentMatchers.*,
35+
org.mockserver.model.HttpRequest.*,
36+
org.mockserver.model.HttpResponse.*,
37+
org.rnorth.ducttape.unreliables.Unreliables.*,
38+
org.rnorth.visibleassertions.VisibleAssertions.*,
39+
"
40+
/>
41+
</module>
42+
<module name="EmptyLineSeparator">
43+
<property name="allowNoEmptyLineBetweenFields" value="false" />
44+
</module>
45+
<module name="OneStatementPerLineCheck"/>
46+
</module>
47+
</module>

docs/contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* follow the style, naming and structure conventions of the rest of the project.
99
* make commits atomic and easy to merge.
1010
* when updating documentation, please see [our guidance for documentation contributions](contributing_docs.md).
11+
* apply format running `./gradlew spotlessApply`
1112
* verify all tests are passing. Build the project with `./gradlew check` to do this.
1213
**N.B.** Gradle's Build Cache is enabled by default, but you can add `--no-build-cache` flag to disable it.
1314

gradle/ci-support.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ task testMatrix {
1717
}
1818
}
1919

20-
// If we're executing the `taskMatrix` task, disable tests and other slow tasks
20+
// If we're executing the `testMatrix` task, disable tests and other slow tasks
2121
// so that we can get a result quickly.
2222
gradle.taskGraph.whenReady {
2323
if (it.hasTask(tasks.testMatrix)) {

modules/neo4j/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ task customNeo4jPluginJar(type: Jar) {
2626
outputs.dir(customNeo4jPluginDestinationDir)
2727
}
2828

29-
test.dependsOn customNeo4jPluginJar
29+
processTestResources.dependsOn customNeo4jPluginJar
3030

3131
dependencies {
3232
customNeo4jPluginCompileOnly "org.neo4j:neo4j:3.5.32"

0 commit comments

Comments
 (0)