Skip to content

Commit

Permalink
completely remove checkstyle and replace it with a simple regex check
Browse files Browse the repository at this point in the history
This is ~ 2 orders of magnitude faster on my machine, so it can be
executed as part of the compileJava task. Also, it actually logs the
failures, instead of making me go hunt for them in some generated
HTML-based report.
  • Loading branch information
gavinking committed Sep 27, 2024
1 parent 1e43182 commit f0f9deb
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 336 deletions.
1 change: 0 additions & 1 deletion .github/workflows/atlas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,5 @@ jobs:
name: test-reports-java11-${{ matrix.rdbms }}
path: |
./**/target/reports/tests/
./**/target/reports/checkstyle/
- name: Omit produced artifacts from build cache
run: ./ci/before-cache.sh
1 change: 0 additions & 1 deletion .github/workflows/contributor-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,5 @@ jobs:
name: test-reports-java11-${{ matrix.rdbms }}
path: |
./**/target/reports/tests/
./**/target/reports/checkstyle/
- name: Omit produced artifacts from build cache
run: ./ci/before-cache.sh
4 changes: 2 additions & 2 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ Do your thing!
up the related commits and display them on the JIRA issue
* Make sure you have added the necessary tests for your changes
* Run _all_ the tests to ensure nothing else was accidentally broken
* Make sure your source does not violate the _checkstyles_

_Before committing, if you want to pull in the latest upstream changes (highly
appreciated btw), please use rebasing rather than merging. Merging creates
Expand Down
5 changes: 0 additions & 5 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ elif [ "$RDBMS" == "informix" ]; then
goal="-Pdb=informix"
fi

# Disable checkstyle
#if [ -n "$goal" ]; then
goal="$goal -x checkstyleMain -DPOPULATE_REMOTE=true"
#fi

function logAndExec() {
echo 1>&2 "Executing:" "${@}"
exec "${@}"
Expand Down
54 changes: 33 additions & 21 deletions gradle/java-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ apply plugin: 'de.thetaphi.forbiddenapis'
apply plugin: 'com.diffplug.spotless'

apply plugin: "jacoco"
apply plugin: 'checkstyle'
apply plugin: 'build-dashboard'
apply plugin: 'project-report'

Expand Down Expand Up @@ -448,26 +447,37 @@ tasks.copyResourcesToIntelliJOutFolder.mustRunAfter processTestResources
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Report configs

checkstyle {
it.sourceSets = [ project.sourceSets.main ]
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle.xml' )
showViolations = false
}

// exclude generated java sources - by explicitly setting the base source dir
tasks.checkstyleMain.source = 'src/main/java'
tasks.checkstyleMain
.exclude('org/hibernate/processor/util/NullnessUtil.java')
.exclude('org/hibernate/internal/util/NullnessUtil.java')
// For some big files we need more heap memory than the default 512m for parsing
tasks.checkstyleMain.maxHeapSize = "640m"

// define a second checkstyle task for checking non-fatal violations
task nonFatalCheckstyle(type:Checkstyle) {
source = project.sourceSets.main.java
classpath = project.configurations.checkstyle
showViolations = false
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle-non-fatal.xml' )
task enforceRules {
doLast {
def illegalImport = /^import (sun|java.awt|org.slf4j).*/
def missingNewline = /^\s*}\s*(else|catch|finally).*/
def lowerEll = /.*\b\d+l\b.*/
def errors = 0
def tree = fileTree("src/main/java/")
tree.include "**/*.java"
tree.each { file ->
def lineNum = 0
def shortName = file.path.substring(rootDir.path.length())
file.eachLine { line ->
lineNum++
if (line ==~ illegalImport) {
errors++
logger.error("Illegal import in ${shortName}\n${lineNum}: ${line}")
}
if (line ==~ missingNewline) {
errors++
logger.error("Missing newline in ${shortName}\n${lineNum}: ${line}")
}
if (line ==~ lowerEll) {
errors++
logger.error("Lowercase long literal in ${shortName}\n${lineNum}: ${line}")
}
}
}
if ( errors>0 ) {
throw new GradleException("Code rules were violated ($errors problems)")
}
}
}

spotless {
Expand All @@ -483,6 +493,8 @@ spotless {
}
}

tasks.spotlessApply.dependsOn enforceRules


class CompilerStubsArgumentProvider implements CommandLineArgumentProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ apply from: rootProject.file( 'gradle/java-module.gradle' )
java.modularity.inferModulePath = true


// Checkstyle fails for module-info
checkstyleMain.exclude '**/module-info.java'

dependencies {
api project( ':hibernate-core' )
api project( ':hibernate-envers' )
Expand Down
3 changes: 0 additions & 3 deletions hibernate-testing/hibernate-testing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,3 @@ dependencies {
annotationProcessor project( ':hibernate-processor' )
}

tasks.checkstyleMain {
exclude '**/org/hibernate/orm/test/legacy/**'
}
2 changes: 1 addition & 1 deletion release/jenkins-release-process.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ First, a list of resources you will need access to in order to perform a release

== Steps

1. Perform `./gradlew preVerifyRelease` locally (after pulling all upstream changes). The Jenkins job does only the release steps, and we need to make sure tests and checkstyle especially are ok
1. Perform `./gradlew preVerifyRelease` locally (after pulling all upstream changes). The Jenkins job does only the release steps, and we need to make sure tests are ok
2. Mark the version as released in Jira
3. Close all issues associated with the version as closed. Be sure to remove the version from any issues that are not resolved (e.g. rejected) - the Jira "release notes" mechanism includes all issues with that version as the fix-for regardless of the resolution
4. Start the https://ci.hibernate.org/view/Release/job/hibernate-orm-release-jdk17/[Jenkins job]. It is a parameterized build - Jenkins will prompt user for needed information:
Expand Down
186 changes: 0 additions & 186 deletions shared/config/checkstyle/checkstyle-non-fatal.xml

This file was deleted.

Loading

0 comments on commit f0f9deb

Please sign in to comment.