Skip to content

Commit

Permalink
Simplify Checkstyle configuration
Browse files Browse the repository at this point in the history
* Move `checkstyle-conventions.gradle` content to the `build.gradle` since it is short enough
* Remove `checkstyle-header.txt` and its handling in favor of Spring Javaformat out-of-the box logic
* Upgrade to Gradle `8.5`
* Remove suppression for `Javadoc*` checks since it is handled by Spring Javaformat
* Leave only `MissingJavadocMethodCheck` exclusion from `SpringChecks` since all others really make sense for our code quality
  • Loading branch information
artembilan committed Jan 3, 2024
1 parent 836708f commit c40d79a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 47 deletions.
21 changes: 19 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
plugins {
id 'base'
id 'io.spring.dependency-management' version '1.1.4'
id "io.spring.javaformat" version "${javaFormatVersion}" apply false
id 'io.spring.javaformat' version "${javaFormatVersion}"
id 'com.github.spotbugs' version '6.0.4'
id 'com.google.protobuf' version '0.9.4' apply false
}
Expand Down Expand Up @@ -66,8 +66,9 @@ configure(javaProjects) { subproject ->
apply plugin: 'java-library'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'checkstyle'
apply plugin: 'io.spring.javaformat'
apply from: "${rootDir}/publish-maven.gradle"
apply from: "${rootDir}/gradle/checkstyle-conventions.gradle"

sourceSets {
test {
Expand Down Expand Up @@ -138,6 +139,22 @@ configure(javaProjects) { subproject ->

[compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:all,-options,-processing', '-parameters']

checkstyle {
toolVersion = '10.3'
configDirectory = rootProject.file('etc/checkstyle')
ignoreFailures = true
}

dependencies {
// NOTE: We explicitly specify checkstyle dep before javaformat checkstyle due to antlr class mismatch
checkstyle("com.puppycrawl.tools:checkstyle:${checkstyle.toolVersion}")
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}")
}

tasks.named('checkFormatMain') {
exclude 'org/springframework/cloud/fn/object/detection/protos'
}

test {
maxHeapSize = '2g'
jvmArgs '-XX:+HeapDumpOnOutOfMemoryError'
Expand Down
17 changes: 0 additions & 17 deletions etc/checkstyle/checkstyle-header.txt

This file was deleted.

2 changes: 1 addition & 1 deletion etc/checkstyle/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress files="package-info\.java" checks=".*" />
<suppress files="[\\/]test[\\/]" checks="RequireThis|AvoidStaticImport|Javadoc*" />
<suppress files="[\\/]test[\\/]" checks="RequireThis|AvoidStaticImport" />
<suppress files="Proto" checks=".*"/>
</suppressions>
6 changes: 0 additions & 6 deletions etc/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@
<property name="file"
value="${config_loc}/checkstyle-suppressions.xml" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.header.RegexpHeaderCheck">
<property name="headerFile" value="${config_loc}/checkstyle-header.txt" />
<property name="fileExtensions" value="java" />
</module>
<module name="io.spring.javaformat.checkstyle.SpringChecks">
<property name="excludes" value="io.spring.javaformat.checkstyle.check.SpringHeaderCheck" />
<property name="excludes" value="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck" />
<property name="excludes" value="com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck" />
</module>
<module name="com.puppycrawl.tools.checkstyle.TreeWalker">
Expand Down
19 changes: 0 additions & 19 deletions gradle/checkstyle-conventions.gradle

This file was deleted.

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionSha256Sum=9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down

0 comments on commit c40d79a

Please sign in to comment.