Skip to content

Commit 054aeff

Browse files
gavinkingsebersole
authored andcommitted
completely remove checkstyle and replace it with a simple regex check
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.
1 parent 4f9035e commit 054aeff

File tree

12 files changed

+36
-336
lines changed

12 files changed

+36
-336
lines changed

Diff for: .github/workflows/atlas.yml

-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,5 @@ jobs:
113113
name: test-reports-java11-${{ matrix.rdbms }}
114114
path: |
115115
./**/target/reports/tests/
116-
./**/target/reports/checkstyle/
117116
- name: Omit produced artifacts from build cache
118117
run: ./ci/before-cache.sh

Diff for: .github/workflows/contributor-build.yml

-1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,5 @@ jobs:
121121
name: test-reports-java11-${{ matrix.rdbms }}
122122
path: |
123123
./**/target/reports/tests/
124-
./**/target/reports/checkstyle/
125124
- name: Omit produced artifacts from build cache
126125
run: ./ci/before-cache.sh

Diff for: .idea/inspectionProfiles/Project_Default.xml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: CONTRIBUTING.md

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ Do your thing!
8383
up the related commits and display them on the JIRA issue
8484
* Make sure you have added the necessary tests for your changes
8585
* Run _all_ the tests to ensure nothing else was accidentally broken
86-
* Make sure your source does not violate the _checkstyles_
8786

8887
_Before committing, if you want to pull in the latest upstream changes (highly
8988
appreciated btw), please use rebasing rather than merging. Merging creates

Diff for: ci/build.sh

-5
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ elif [ "$RDBMS" == "informix" ]; then
7676
goal="-Pdb=informix"
7777
fi
7878

79-
# Disable checkstyle
80-
#if [ -n "$goal" ]; then
81-
goal="$goal -x checkstyleMain -DPOPULATE_REMOTE=true"
82-
#fi
83-
8479
function logAndExec() {
8580
echo 1>&2 "Executing:" "${@}"
8681
exec "${@}"

Diff for: gradle/java-module.gradle

+33-21
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ apply plugin: 'de.thetaphi.forbiddenapis'
3636
apply plugin: 'com.diffplug.spotless'
3737

3838
apply plugin: "jacoco"
39-
apply plugin: 'checkstyle'
4039
apply plugin: 'build-dashboard'
4140
apply plugin: 'project-report'
4241

@@ -448,26 +447,37 @@ tasks.copyResourcesToIntelliJOutFolder.mustRunAfter processTestResources
448447
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
449448
// Report configs
450449

451-
checkstyle {
452-
it.sourceSets = [ project.sourceSets.main ]
453-
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle.xml' )
454-
showViolations = false
455-
}
456-
457-
// exclude generated java sources - by explicitly setting the base source dir
458-
tasks.checkstyleMain.source = 'src/main/java'
459-
tasks.checkstyleMain
460-
.exclude('org/hibernate/processor/util/NullnessUtil.java')
461-
.exclude('org/hibernate/internal/util/NullnessUtil.java')
462-
// For some big files we need more heap memory than the default 512m for parsing
463-
tasks.checkstyleMain.maxHeapSize = "640m"
464-
465-
// define a second checkstyle task for checking non-fatal violations
466-
task nonFatalCheckstyle(type:Checkstyle) {
467-
source = project.sourceSets.main.java
468-
classpath = project.configurations.checkstyle
469-
showViolations = false
470-
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle-non-fatal.xml' )
450+
task enforceRules {
451+
doLast {
452+
def illegalImport = ~/^import (sun|java.awt|org.slf4j)/
453+
def missingNewline = ~/^\s*}\s*(else|catch|finally)/
454+
def lowerEll = ~/\b\d+l\b/
455+
def errors = 0
456+
def tree = fileTree("src/main/java/")
457+
tree.include "**/*.java"
458+
tree.each { file ->
459+
def lineNum = 0
460+
def shortName = file.path.substring(rootDir.path.length())
461+
file.eachLine { line ->
462+
lineNum++
463+
if (line =~ illegalImport) {
464+
errors++
465+
logger.error("Illegal import in ${shortName}\n${lineNum}: ${line}")
466+
}
467+
if (line =~ missingNewline) {
468+
errors++
469+
logger.error("Missing newline in ${shortName}\n${lineNum}: ${line}")
470+
}
471+
if (line =~ lowerEll) {
472+
errors++
473+
logger.error("Lowercase long literal in ${shortName}\n${lineNum}: ${line}")
474+
}
475+
}
476+
}
477+
if ( errors>0 ) {
478+
throw new GradleException("Code rules were violated ($errors problems)")
479+
}
480+
}
471481
}
472482

473483
spotless {
@@ -483,6 +493,8 @@ spotless {
483493
}
484494
}
485495

496+
tasks.spotlessApply.dependsOn enforceRules
497+
486498

487499
class CompilerStubsArgumentProvider implements CommandLineArgumentProvider {
488500

Diff for: hibernate-integrationtest-java-modules/hibernate-integrationtest-java-modules.gradle

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ apply from: rootProject.file( 'gradle/java-module.gradle' )
1414
java.modularity.inferModulePath = true
1515

1616

17-
// Checkstyle fails for module-info
18-
checkstyleMain.exclude '**/module-info.java'
19-
2017
dependencies {
2118
api project( ':hibernate-core' )
2219
api project( ':hibernate-envers' )

Diff for: hibernate-testing/hibernate-testing.gradle

-3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,3 @@ dependencies {
4949
annotationProcessor project( ':hibernate-processor' )
5050
}
5151

52-
tasks.checkstyleMain {
53-
exclude '**/org/hibernate/orm/test/legacy/**'
54-
}

Diff for: release/jenkins-release-process.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ First, a list of resources you will need access to in order to perform a release
1515

1616
== Steps
1717

18-
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
18+
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
1919
2. Mark the version as released in Jira
2020
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
2121
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:

Diff for: shared/config/checkstyle/checkstyle-non-fatal.xml

-186
This file was deleted.

0 commit comments

Comments
 (0)