Skip to content

Commit

Permalink
chore: add styleCheck Gradle task to report style violations (#2980)
Browse files Browse the repository at this point in the history
The mnemonics is:
* style: fix code style
* styleCheck: report style violations

Most of the time, ./gradlew style should be good enough.
  • Loading branch information
vlsi committed Nov 8, 2023
1 parent 20d3e06 commit 0a64f4c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
### New Feature Submissions:

1. [ ] Does your submission pass tests?
2. [ ] Does `./gradlew autostyleCheck checkstyleAll` pass ?
2. [ ] Does `./gradlew styleCheck` pass ?
3. [ ] Have you added your new test classes to an existing test suite in alphabetical order?

### Changes to Existing Features:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
with:
job-id: jdk17
arguments: autostyleCheck checkstyleAll jandex
arguments: styleCheck jandex

linux-checkerframework:
name: 'CheckerFramework'
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ on a command line (the outputs are located in the relevant:

./gradlew check # verify code style, execute tests
./gradlew style # update code formatting (for auto-correctable cases) and verify style
./gradlew autostyleCheck checkstyleAll # report code style violations
./gradlew styleCheck # report code style violations

./gradlew test # execute tests
./gradlew test --tests org.postgresql.test.ssl.SslTest # execute test by class
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.github.autostyle.gradle.AutostyleTask
import org.gradle.kotlin.dsl.apply
import org.gradle.language.base.plugins.LifecycleBasePlugin

Expand All @@ -7,6 +8,11 @@ plugins {

if (!buildParameters.skipAutostyle) {
apply(plugin = "build-logic.autostyle")
if (!buildParameters.skipCheckstyle) {
tasks.withType<Checkstyle>().configureEach {
mustRunAfter(tasks.withType<AutostyleTask>())
}
}
}

val skipCheckstyle = buildParameters.skipCheckstyle || run {
Expand Down Expand Up @@ -48,4 +54,17 @@ if (!buildParameters.skipAutostyle || !skipCheckstyle || !buildParameters.skipFo
dependsOn("forbiddenApis")
}
}
tasks.register("styleCheck") {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Report code style violations (license header, import order, whitespace at end of line, ...)"
if (!buildParameters.skipAutostyle) {
dependsOn("autostyleCheck")
}
if (!skipCheckstyle) {
dependsOn("checkstyleAll")
}
if (!buildParameters.skipForbiddenApis) {
dependsOn("forbiddenApis")
}
}
}

0 comments on commit 0a64f4c

Please sign in to comment.