Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -e
set -o pipefail

./gradlew --console=colored checkstyleMain checkstyleTest
./gradlew --console=colored compileJava compileTestJava
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ jobs:
shell: bash
- name: Build package
run: ./gradlew --console=colored build -x test
env:
GITHUB_USER_NAME: ${{ github.actor }}
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: aboutbits/github-actions-docker/build-push@v1
with:
username: ${{ github.actor }}
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@ jobs:
:operator:test
--fail-fast
-Dquarkus.test.profile=test-pg${{ matrix.postgres-version }}
env:
GITHUB_USER_NAME: ${{ github.actor }}
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
### PostgreSQL Operator ###
config/
# Written by the fabric8 Kubernetes client when the tests run against the Dev Service
operator/.kube/

Expand All @@ -17,7 +16,6 @@ operator/.kube/
.idea/*
!.idea/codeStyles
!.idea/.gitignore
!.idea/checkstyle-idea.xml
!.idea/encodings.xml
!.idea/misc.xml
!.idea/sqldialects.xml
Expand Down
25 changes: 0 additions & 25 deletions .idea/checkstyle-idea.xml

This file was deleted.

15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,6 @@ To build the project, the following prerequisites must be met:

### Setup

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.

Follow https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry
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.

If it does not exist yet, create a file `~/.gradle/gradle.properties` in your home directory and add the following lines.

```properties
gpr.user=<your_github_user>
# The token generated above
gpr.key=<your_github_token>
```

Then call:

```bash
make init

Expand Down
49 changes: 2 additions & 47 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.errorprone
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
idea
java
checkstyle
id("io.quarkus").apply(false)
alias(libs.plugins.axionReleasePlugin)
alias(libs.plugins.errorPronePlugin)
Expand All @@ -31,20 +29,10 @@ version = scmVersion.version
allprojects {
group = "it.aboutbits.postgresql"
version = rootProject.version

tasks.withType<Checkstyle>().configureEach {
dependsOn(":checkstyleExtractConfig")

reports {
html.required = false
xml.required = false
}
}
}

subprojects {
apply(plugin = "java")
apply(plugin = "checkstyle")
apply(plugin = rootProject.libs.plugins.errorPronePlugin.get().pluginId)

java {
Expand Down Expand Up @@ -82,10 +70,8 @@ subprojects {
options.compilerArgs.add("-parameters")

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

Expand Down Expand Up @@ -126,34 +112,3 @@ subprojects {
}
}
}

val checkstyleConfig: Configuration by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
}

dependencies {
/**
* AboutBits Libraries
*/
checkstyleConfig(libs.checkstyleConfig)
}

tasks.register<Copy>("checkstyleExtractConfig") {
description = "Extracts the AboutBits Checkstyle configuration from the classpath."
group = JavaBasePlugin.CHECK_TASK_NAME

from(zipTree(checkstyleConfig.singleFile)) {
include("checkstyle.xml", "checkstyle-suppressions.xml")
}
into(layout.projectDirectory.dir("config/checkstyle/"))
}

checkstyle {
toolVersion = libs.versions.checkstyle.get()
isShowViolations = true
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
configProperties = mapOf(
"suppressionFile" to rootProject.file("config/checkstyle/checkstyle-suppressions.xml")
)
}
117 changes: 117 additions & 0 deletions errorprone.args
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Error Prone and NullAway configuration.
#
# build.gradle.kts reads this file through options.errorprone.argumentFiles.
#
# Rules for this file:
# 1. Write one flag per line.
# 2. Write a check as the Xep prefix, then the check name, then the severity.
# A severity is ERROR, WARN or OFF. Omit the severity to keep the default.
# 3. Write a check option as the XepOpt prefix, then the key, then the value.
# 4. Never write an "at" sign in a comment. Error Prone reads it as a file reference.
# 5. Never start a comment word with a dash. Error Prone reads it as a flag.
# 6. This file cannot reference a second argument file.

# Nullness
-Xep:NullAway:ERROR
-XepOpt:NullAway:AnnotatedPackages=it.aboutbits.postgresql
-XepOpt:NullAway:JSpecifyMode=true
-Xep:AnnotationPosition:ERROR
-Xep:EqualsMissingNullable:ERROR
-Xep:MultipleNullnessAnnotations:ERROR
-Xep:RequireExplicitNullMarking:ERROR

# Javadoc
-Xep:AlmostJavadoc:ERROR
-Xep:DepAnn:ERROR
-Xep:EmptyBlockTag:ERROR
-Xep:EscapedEntity:ERROR
-Xep:InvalidBlockTag:ERROR
-Xep:InvalidInlineTag:ERROR
-Xep:InvalidLink:ERROR
-Xep:InvalidParam:ERROR
-Xep:InvalidThrows:ERROR
-Xep:MalformedInlineTag:ERROR
-Xep:MissingSummary:ERROR
-Xep:NotJavadoc:ERROR
-Xep:PreferThrowsTag:ERROR
-Xep:UnescapedEntity:ERROR
-Xep:UnrecognisedJavadocTag:ERROR

# Imports
-Xep:BadImport:ERROR
-Xep:RemoveUnusedImports:ERROR
-Xep:UnnecessaryStaticImport:ERROR
-Xep:WildcardImport:ERROR

# Naming and source layout
-Xep:ClassName:ERROR
-Xep:ConstantField:ERROR
-Xep:DefaultPackage:ERROR
-Xep:MultipleTopLevelClasses:ERROR
-Xep:PackageLocation:ERROR

# Blocks, statements and switches
-Xep:EmptyCatch:ERROR
-Xep:EmptyIf:ERROR
-Xep:EmptyTopLevelDeclaration:ERROR
-Xep:MissingBraces:ERROR
-Xep:MissingCasesInEnumSwitch:ERROR
-Xep:MissingDefault:ERROR
-Xep:MultiVariableDeclaration:ERROR
-Xep:SwitchDefault:ERROR
-Xep:UseEnumSwitch:ERROR

# Class design
-Xep:InterfaceWithOnlyStatics:ERROR
-Xep:MutablePublicArray:ERROR
-Xep:PrivateConstructorForUtilityClass:ERROR
-Xep:ProtectedMembersInFinalClass:ERROR
-Xep:TooManyParameters:ERROR

# Correctness
-Xep:AmbiguousMethodReference:ERROR
-Xep:AssignmentExpression:ERROR
-Xep:BadInstanceof:ERROR
-Xep:CheckReturnValue:ERROR
-Xep:EqualsIncompatibleType:ERROR
-Xep:FallThrough:ERROR
-Xep:Finally:ERROR
-Xep:FunctionalInterfaceClash:ERROR
-Xep:HidingField:ERROR
# Important due to performance reasons, see
# https://github.com/uber/NullAway/wiki/Configuration#perform-exhaustive-override-checks
-Xep:MissingOverride:ERROR
-Xep:MockNotUsedInProduction:ERROR
-Xep:NarrowingCompoundAssignment:ERROR
-Xep:Overrides:ERROR
-Xep:PrimitiveArrayPassedToVarargsMethod:ERROR
-Xep:ReferenceEquality:ERROR
-Xep:SelfComparison:ERROR
-Xep:StaticQualifiedUsingExpression:ERROR
-Xep:SymbolToString:ERROR
-Xep:TypeToString:ERROR
-Xep:UnusedException:ERROR
-Xep:UnusedMethod:ERROR
-Xep:UnusedNestedClass:ERROR
-Xep:UnusedVariable:ERROR

# Redundant code and house style
-Xep:BooleanLiteral:ERROR
-Xep:ComplexBooleanConstant:ERROR
-Xep:ExplicitArrayForVarargs:ERROR
-Xep:LongLiteralLowerCaseSuffix:ERROR
-Xep:MixedArrayDimensions:ERROR
-Xep:StringConcatToTextBlock:ERROR
-Xep:TryWithResourcesVariable:ERROR
-Xep:UnnecessaryAnonymousClass:ERROR
-Xep:UnnecessaryAssignment:ERROR
-Xep:UnnecessaryBoxedAssignment:ERROR
-Xep:UnnecessaryBoxedVariable:ERROR
-Xep:UnnecessaryFinal:ERROR
-Xep:UnnecessaryLambda:ERROR
-Xep:UnnecessaryMethodReference:ERROR
-Xep:UnnecessaryParentheses:ERROR
-Xep:Varifier:ERROR

# Turn off as this check is too noisy
-Xep:StringSplitter:OFF
19 changes: 2 additions & 17 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
[versions]
## AboutBits Libraries ##
checkstyleConfig = "2.0.0-RC2"

# Axion Release Plugin #
axionReleasePlugin = "1.21.1"

Expand All @@ -17,8 +14,8 @@ scram-client = "3.2"
assertj = "3.27.7"
checkstyle = "13.4.2"
datafaker = "2.5.4"
errorProne = "2.49.0"
errorPronePlugin = "5.1.0"
errorProne = "2.50.0"
errorPronePlugin = "5.1.1"
nullAway = "0.13.4"

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

[libraries]
## AboutBits Libraries ##

# https://github.com/aboutbits/java-checkstyle-config
checkstyleConfig = { group = "it.aboutbits", name = "java-checkstyle-config", version.ref = "checkstyleConfig" }

## Libraries ##

# jOOQ #
# https://www.jooq.org/
# https://www.jooq.org/download/versions
Expand Down Expand Up @@ -87,11 +77,6 @@ scram-client = { group = "com.ongres.scram", name = "scram-client", version.ref
# https://mvnrepository.com/artifact/org.assertj/assertj-core
assertj = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" }

# https://checkstyle.org/
# https://github.com/checkstyle/checkstyle
# https://mvnrepository.com/artifact/com.puppycrawl.tools/checkstyle
checkstyle = { group = "com.puppycrawl.tools", name = "checkstyle", version.ref = "checkstyle" }

# https://datafaker.net/
# https://github.com/datafaker-net/datafaker
# https://mvnrepository.com/artifact/net.datafaker/datafaker
Expand Down
3 changes: 3 additions & 0 deletions lombok.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ lombok.addNullAnnotations = jspecify

# Required for NullAway
lombok.addLombokGeneratedAnnotation = true

# Enable CheckReturnValue annotation on generated code for Error Prone and static analysis
lombok.checkReturnValueAnnotation = lombok
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ protected CRStatus newStatus() {
return new CRStatus();
}

@SuppressWarnings({"checkstyle:MethodLength", "java:S3776"})
@SuppressWarnings("java:S3776")
private UpdateControl<Grant> reconcileInTransaction(
DSLContext tx,
Grant resource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class GrantService {
/// @param tx The DSLContext for database operations.
/// @param spec The GrantSpec containing the specification details.
/// @return A map with object names as keys and lists of Privilege as values.
@SuppressWarnings("checkstyle:MethodLength")
public Map<String, Set<Privilege>> determineCurrentObjectPrivileges(
DSLContext tx,
GrantSpec spec
Expand Down Expand Up @@ -216,7 +215,7 @@ public Map<String, Set<Privilege>> determineCurrentObjectPrivileges(
/// @param spec the GrantSpec object containing specifications about the target database objects and privileges
/// @return a map where the keys represent object names and the values indicate ownership status,
/// or `null` if the object does not exist
@SuppressWarnings({"checkstyle:MethodLength", "java:S3776"})
@SuppressWarnings("java:S3776")
public Map<String, @Nullable Boolean> determineObjectExistenceAndOwnership(
DSLContext tx,
GrantSpec spec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@
);
}

@SuppressWarnings("checkstyle:MethodLength")
@ParameterizedTest
@MethodSource("provideAllSupportedPrivileges")
@DisplayName("Should grant and revoke privileges on all tables")
Expand Down Expand Up @@ -1058,7 +1057,6 @@
);
}

@SuppressWarnings("checkstyle:MethodLength")
@Test
@DisplayName("Should grant and revoke privileges on all sequences")
void grantOnAllSequences() {
Expand Down Expand Up @@ -1296,7 +1294,7 @@
) {
try (var dsl = postgreSQLContextFactory.getDSLContext(clusterConnection, databaseName)) {
dsl.createTable(quotedName(schemaName, tableName))
.column("id", SQLDataType.BIGINT.identity(true))

Check warning on line 1297 in operator/src/test/java/it/aboutbits/postgresql/crd/grant/GrantReconcilerTest.java

View workflow job for this annotation

GitHub Actions / Tests / Tests (PostgreSQL 18)

[removal] identity(boolean) in DataType has been deprecated and marked for removal

Check warning on line 1297 in operator/src/test/java/it/aboutbits/postgresql/crd/grant/GrantReconcilerTest.java

View workflow job for this annotation

GitHub Actions / Tests / Tests (PostgreSQL 16)

[removal] identity(boolean) in DataType has been deprecated and marked for removal

Check warning on line 1297 in operator/src/test/java/it/aboutbits/postgresql/crd/grant/GrantReconcilerTest.java

View workflow job for this annotation

GitHub Actions / Tests / Tests (PostgreSQL 15)

[removal] identity(boolean) in DataType has been deprecated and marked for removal

Check warning on line 1297 in operator/src/test/java/it/aboutbits/postgresql/crd/grant/GrantReconcilerTest.java

View workflow job for this annotation

GitHub Actions / Tests / Tests (PostgreSQL 17)

[removal] identity(boolean) in DataType has been deprecated and marked for removal
.execute();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ void deleteRole_removesFromDatabase() {
.until(() -> !roleService.roleExists(dsl, role.getSpec()));
}

private @Nullable <T> T getRoleFlagValue(
private <T> @Nullable T getRoleFlagValue(
DSLContext dsl,
String roleName,
Field<T> field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class HelmTest {
this.rootValuesAlias = rootValuesAlias;
}

@SuppressWarnings("checkstyle:MethodLength")
@Test
@DisplayName("When the Helm chart is installed, the operator deployment should be created")
void helmInstall_createsDeployment() throws IOException {
Expand Down
Loading