Skip to content

Commit 5c0027c

Browse files
committed
replace Checkstyle with ErrorProne
1 parent 0bcd728 commit 5c0027c

16 files changed

Lines changed: 128 additions & 147 deletions

File tree

.githooks/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
set -e
44
set -o pipefail
55

6-
./gradlew --console=colored checkstyleMain checkstyleTest
6+
./gradlew --console=colored compileJava compileTestJava

.github/workflows/release.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ jobs:
4444
shell: bash
4545
- name: Build package
4646
run: ./gradlew --console=colored build -x test
47-
env:
48-
GITHUB_USER_NAME: ${{ github.actor }}
49-
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5047
- uses: aboutbits/github-actions-docker/build-push@v1
5148
with:
5249
username: ${{ github.actor }}

.github/workflows/test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,3 @@ jobs:
2525
:operator:test
2626
--fail-fast
2727
-Dquarkus.test.profile=test-pg${{ matrix.postgres-version }}
28-
env:
29-
GITHUB_USER_NAME: ${{ github.actor }}
30-
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
### PostgreSQL Operator ###
2-
config/
32
# Written by the fabric8 Kubernetes client when the tests run against the Dev Service
43
operator/.kube/
54

@@ -17,7 +16,6 @@ operator/.kube/
1716
.idea/*
1817
!.idea/codeStyles
1918
!.idea/.gitignore
20-
!.idea/checkstyle-idea.xml
2119
!.idea/encodings.xml
2220
!.idea/misc.xml
2321
!.idea/sqldialects.xml

.idea/checkstyle-idea.xml

Lines changed: 0 additions & 25 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -222,21 +222,6 @@ To build the project, the following prerequisites must be met:
222222
223223
### Setup
224224
225-
To get started, you first need to configure the GitHub Gradle Packages registry to be able to pull the [AbouBits Java Checkstyle Config](https://github.com/aboutbits/java-checkstyle-config) from the GitHub Packages registry.
226-
227-
Follow https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry
228-
The guide basically tells you to click on `Generate new token (classic)` on https://github.com/settings/tokens, add the permission `read:packages` and copy the token which we need below.
229-
230-
If it does not exist yet, create a file `~/.gradle/gradle.properties` in your home directory and add the following lines.
231-
232-
```properties
233-
gpr.user=<your_github_user>
234-
# The token generated above
235-
gpr.key=<your_github_token>
236-
```
237-
238-
Then call:
239-
240225
```bash
241226
make init
242227

build.gradle.kts

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import net.ltgt.gradle.errorprone.CheckSeverity
21
import net.ltgt.gradle.errorprone.errorprone
32
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
43
import org.gradle.api.tasks.testing.logging.TestLogEvent
54

65
plugins {
76
idea
87
java
9-
checkstyle
108
id("io.quarkus").apply(false)
119
alias(libs.plugins.axionReleasePlugin)
1210
alias(libs.plugins.errorPronePlugin)
@@ -31,20 +29,10 @@ version = scmVersion.version
3129
allprojects {
3230
group = "it.aboutbits.postgresql"
3331
version = rootProject.version
34-
35-
tasks.withType<Checkstyle>().configureEach {
36-
dependsOn(":checkstyleExtractConfig")
37-
38-
reports {
39-
html.required = false
40-
xml.required = false
41-
}
42-
}
4332
}
4433

4534
subprojects {
4635
apply(plugin = "java")
47-
apply(plugin = "checkstyle")
4836
apply(plugin = rootProject.libs.plugins.errorPronePlugin.get().pluginId)
4937

5038
java {
@@ -82,10 +70,8 @@ subprojects {
8270
options.compilerArgs.add("-parameters")
8371

8472
options.errorprone {
85-
check("NullAway", CheckSeverity.ERROR)
86-
check("RequireExplicitNullMarking", CheckSeverity.ERROR)
87-
option("NullAway:AnnotatedPackages", "it.aboutbits.postgresql")
88-
option("NullAway:JSpecifyMode", "true")
73+
// The checks live in errorprone.args, see https://github.com/tbroyer/gradle-errorprone-plugin#argument-files
74+
argumentFiles.from(rootProject.layout.projectDirectory.file("errorprone.args"))
8975
}
9076
}
9177

@@ -126,34 +112,3 @@ subprojects {
126112
}
127113
}
128114
}
129-
130-
val checkstyleConfig: Configuration by configurations.creating {
131-
isCanBeConsumed = false
132-
isCanBeResolved = true
133-
}
134-
135-
dependencies {
136-
/**
137-
* AboutBits Libraries
138-
*/
139-
checkstyleConfig(libs.checkstyleConfig)
140-
}
141-
142-
tasks.register<Copy>("checkstyleExtractConfig") {
143-
description = "Extracts the AboutBits Checkstyle configuration from the classpath."
144-
group = JavaBasePlugin.CHECK_TASK_NAME
145-
146-
from(zipTree(checkstyleConfig.singleFile)) {
147-
include("checkstyle.xml", "checkstyle-suppressions.xml")
148-
}
149-
into(layout.projectDirectory.dir("config/checkstyle/"))
150-
}
151-
152-
checkstyle {
153-
toolVersion = libs.versions.checkstyle.get()
154-
isShowViolations = true
155-
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
156-
configProperties = mapOf(
157-
"suppressionFile" to rootProject.file("config/checkstyle/checkstyle-suppressions.xml")
158-
)
159-
}

errorprone.args

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Error Prone and NullAway configuration.
2+
#
3+
# build.gradle.kts reads this file through options.errorprone.argumentFiles.
4+
#
5+
# Rules for this file:
6+
# 1. Write one flag per line.
7+
# 2. Write a check as the Xep prefix, then the check name, then the severity.
8+
# A severity is ERROR, WARN or OFF. Omit the severity to keep the default.
9+
# 3. Write a check option as the XepOpt prefix, then the key, then the value.
10+
# 4. Never write an "at" sign in a comment. Error Prone reads it as a file reference.
11+
# 5. Never start a comment word with a dash. Error Prone reads it as a flag.
12+
# 6. This file cannot reference a second argument file.
13+
14+
# Nullness
15+
-Xep:NullAway:ERROR
16+
-XepOpt:NullAway:AnnotatedPackages=it.aboutbits.postgresql
17+
-XepOpt:NullAway:JSpecifyMode=true
18+
-Xep:AnnotationPosition:ERROR
19+
-Xep:EqualsMissingNullable:ERROR
20+
-Xep:MultipleNullnessAnnotations:ERROR
21+
-Xep:RequireExplicitNullMarking:ERROR
22+
23+
# Javadoc
24+
-Xep:AlmostJavadoc:ERROR
25+
-Xep:DepAnn:ERROR
26+
-Xep:EmptyBlockTag:ERROR
27+
-Xep:EscapedEntity:ERROR
28+
-Xep:InvalidBlockTag:ERROR
29+
-Xep:InvalidInlineTag:ERROR
30+
-Xep:InvalidLink:ERROR
31+
-Xep:InvalidParam:ERROR
32+
-Xep:InvalidThrows:ERROR
33+
-Xep:MalformedInlineTag:ERROR
34+
-Xep:MissingSummary:ERROR
35+
-Xep:NotJavadoc:ERROR
36+
-Xep:PreferThrowsTag:ERROR
37+
-Xep:UnescapedEntity:ERROR
38+
-Xep:UnrecognisedJavadocTag:ERROR
39+
40+
# Imports
41+
-Xep:BadImport:ERROR
42+
-Xep:RemoveUnusedImports:ERROR
43+
-Xep:UnnecessaryStaticImport:ERROR
44+
-Xep:WildcardImport:ERROR
45+
46+
# Naming and source layout
47+
-Xep:ClassName:ERROR
48+
-Xep:ConstantField:ERROR
49+
-Xep:DefaultPackage:ERROR
50+
-Xep:MultipleTopLevelClasses:ERROR
51+
-Xep:PackageLocation:ERROR
52+
53+
# Blocks, statements and switches
54+
-Xep:EmptyCatch:ERROR
55+
-Xep:EmptyIf:ERROR
56+
-Xep:EmptyTopLevelDeclaration:ERROR
57+
-Xep:MissingBraces:ERROR
58+
-Xep:MissingCasesInEnumSwitch:ERROR
59+
-Xep:MissingDefault:ERROR
60+
-Xep:MultiVariableDeclaration:ERROR
61+
-Xep:SwitchDefault:ERROR
62+
-Xep:UseEnumSwitch:ERROR
63+
64+
# Class design
65+
-Xep:InterfaceWithOnlyStatics:ERROR
66+
-Xep:MutablePublicArray:ERROR
67+
-Xep:PrivateConstructorForUtilityClass:ERROR
68+
-Xep:ProtectedMembersInFinalClass:ERROR
69+
-Xep:TooManyParameters:ERROR
70+
71+
# Correctness
72+
-Xep:AmbiguousMethodReference:ERROR
73+
-Xep:AssignmentExpression:ERROR
74+
-Xep:BadInstanceof:ERROR
75+
-Xep:CheckReturnValue:ERROR
76+
-Xep:EqualsIncompatibleType:ERROR
77+
-Xep:FallThrough:ERROR
78+
-Xep:Finally:ERROR
79+
-Xep:FunctionalInterfaceClash:ERROR
80+
-Xep:HidingField:ERROR
81+
# Important due to performance reasons, see
82+
# https://github.com/uber/NullAway/wiki/Configuration#perform-exhaustive-override-checks
83+
-Xep:MissingOverride:ERROR
84+
-Xep:MockNotUsedInProduction:ERROR
85+
-Xep:NarrowingCompoundAssignment:ERROR
86+
-Xep:Overrides:ERROR
87+
-Xep:PrimitiveArrayPassedToVarargsMethod:ERROR
88+
-Xep:ReferenceEquality:ERROR
89+
-Xep:SelfComparison:ERROR
90+
-Xep:StaticQualifiedUsingExpression:ERROR
91+
-Xep:SymbolToString:ERROR
92+
-Xep:TypeToString:ERROR
93+
-Xep:UnusedException:ERROR
94+
-Xep:UnusedMethod:ERROR
95+
-Xep:UnusedNestedClass:ERROR
96+
-Xep:UnusedVariable:ERROR
97+
98+
# Redundant code and house style
99+
-Xep:BooleanLiteral:ERROR
100+
-Xep:ComplexBooleanConstant:ERROR
101+
-Xep:ExplicitArrayForVarargs:ERROR
102+
-Xep:LongLiteralLowerCaseSuffix:ERROR
103+
-Xep:MixedArrayDimensions:ERROR
104+
-Xep:StringConcatToTextBlock:ERROR
105+
-Xep:TryWithResourcesVariable:ERROR
106+
-Xep:UnnecessaryAnonymousClass:ERROR
107+
-Xep:UnnecessaryAssignment:ERROR
108+
-Xep:UnnecessaryBoxedAssignment:ERROR
109+
-Xep:UnnecessaryBoxedVariable:ERROR
110+
-Xep:UnnecessaryFinal:ERROR
111+
-Xep:UnnecessaryLambda:ERROR
112+
-Xep:UnnecessaryMethodReference:ERROR
113+
-Xep:UnnecessaryParentheses:ERROR
114+
-Xep:Varifier:ERROR
115+
116+
# Turn off as this check is too noisy
117+
-Xep:StringSplitter:OFF

gradle/libs.versions.toml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
[versions]
2-
## AboutBits Libraries ##
3-
checkstyleConfig = "2.0.0-RC2"
4-
52
# Axion Release Plugin #
63
axionReleasePlugin = "1.21.1"
74

@@ -17,8 +14,8 @@ scram-client = "3.2"
1714
assertj = "3.27.7"
1815
checkstyle = "13.4.2"
1916
datafaker = "2.5.4"
20-
errorProne = "2.49.0"
21-
errorPronePlugin = "5.1.0"
17+
errorProne = "2.50.0"
18+
errorPronePlugin = "5.1.1"
2219
nullAway = "0.13.4"
2320

2421
[plugins]
@@ -36,13 +33,6 @@ errorPronePlugin = { id = "net.ltgt.errorprone", version.ref = "errorPronePlugin
3633
jooqPlugin = { id = "org.jooq.jooq-codegen-gradle", version.ref = "jooq" }
3734

3835
[libraries]
39-
## AboutBits Libraries ##
40-
41-
# https://github.com/aboutbits/java-checkstyle-config
42-
checkstyleConfig = { group = "it.aboutbits", name = "java-checkstyle-config", version.ref = "checkstyleConfig" }
43-
44-
## Libraries ##
45-
4636
# jOOQ #
4737
# https://www.jooq.org/
4838
# https://www.jooq.org/download/versions
@@ -87,11 +77,6 @@ scram-client = { group = "com.ongres.scram", name = "scram-client", version.ref
8777
# https://mvnrepository.com/artifact/org.assertj/assertj-core
8878
assertj = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" }
8979

90-
# https://checkstyle.org/
91-
# https://github.com/checkstyle/checkstyle
92-
# https://mvnrepository.com/artifact/com.puppycrawl.tools/checkstyle
93-
checkstyle = { group = "com.puppycrawl.tools", name = "checkstyle", version.ref = "checkstyle" }
94-
9580
# https://datafaker.net/
9681
# https://github.com/datafaker-net/datafaker
9782
# https://mvnrepository.com/artifact/net.datafaker/datafaker

lombok.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ lombok.addNullAnnotations = jspecify
77

88
# Required for NullAway
99
lombok.addLombokGeneratedAnnotation = true
10+
11+
# Enable CheckReturnValue annotation on generated code for Error Prone and static analysis
12+
lombok.checkReturnValueAnnotation = lombok

0 commit comments

Comments
 (0)