Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spotless and checkstyle #5383

Merged
merged 12 commits into from
May 20, 2022
38 changes: 38 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ plugins {
id 'io.franzbecker.gradle-lombok' version '5.0.0'
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'me.champeau.gradle.japicmp' version '0.2.9' apply false
id 'com.diffplug.spotless' version '6.3.0' apply false
}

apply from: "$rootDir/gradle/ci-support.gradle"
Expand All @@ -22,6 +23,8 @@ subprojects {
apply plugin: 'idea'
apply plugin: 'io.franzbecker.gradle-lombok'
apply from: "$rootDir/gradle/shading.gradle"
apply plugin: 'com.diffplug.spotless'
apply plugin: 'checkstyle'

group = "org.testcontainers"

Expand Down Expand Up @@ -105,4 +108,39 @@ subprojects {
dependencies {
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
}

spotless {
enforceCheck false
java {
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()

prettier(['prettier': '2.5.1', 'prettier-plugin-java': '1.6.1'])
.config([
'parser' : 'java',
'tabWidth' : 4,
'printWidth': 120
])

importOrder('', 'java', 'javax', '\\#')
}
groovyGradle {
target '**/*.groovy'
greclipse('4.19.0')
}
}

checkstyle {
toolVersion = "9.3"
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
checkstyleTest.enabled = false
checkstyleMain.enabled = false
eddumelendez marked this conversation as resolved.
Show resolved Hide resolved
}

tasks.whenTaskAdded {task ->
if (task.name.equals("checkstyleJarFileTest")) {
task.enabled = false
}
}
eddumelendez marked this conversation as resolved.
Show resolved Hide resolved
}
47 changes: 47 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="SuppressionCommentFilter"/>
<module name="NeedBraces">
<property name="tokens"
value="
LITERAL_DO,
LITERAL_ELSE,
LITERAL_FOR,
LITERAL_IF,
LITERAL_WHILE,
LITERAL_CASE,
LITERAL_DEFAULT,
LAMBDA,
"
/>
<property name="allowSingleLineStatement" value="true"/>
</module>
<module name="AvoidStaticImport">
<property name="excludes"
value="
io.restassured.RestAssured.*,
org.assertj.core.api.Assertions.*,
org.assertj.core.api.Assumptions.*,
org.awaitility.Awaitility.*,
org.hamcrest.Matchers.*,
org.hamcrest.MatcherAssert.*,
org.junit.Assert.*,
org.junit.Assume.*,
org.junit.jupiter.api.Assertions.*,
org.mockito.Mockito.*,
org.mockito.ArgumentMatchers.*,
org.mockserver.model.HttpRequest.*,
org.mockserver.model.HttpResponse.*,
org.rnorth.ducttape.unreliables.Unreliables.*,
org.rnorth.visibleassertions.VisibleAssertions.*,
"
/>
</module>
<module name="EmptyLineSeparator">
<property name="allowNoEmptyLineBetweenFields" value="false" />
</module>
<module name="OneStatementPerLineCheck"/>
</module>
</module>
1 change: 1 addition & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* follow the style, naming and structure conventions of the rest of the project.
* make commits atomic and easy to merge.
* when updating documentation, please see [our guidance for documentation contributions](contributing_docs.md).
* apply format running `./gradlew spotlessApply`
* verify all tests are passing. Build the project with `./gradlew check` to do this.
**N.B.** Gradle's Build Cache is enabled by default, but you can add `--no-build-cache` flag to disable it.

Expand Down
2 changes: 1 addition & 1 deletion gradle/ci-support.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ task testMatrix {
}
}

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