diff --git a/build.gradle.kts b/build.gradle.kts index 3d80ead..e4ea3b9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,6 +69,11 @@ subprojects { options.encoding = "UTF-8" options.compilerArgs.add("-parameters") + // Source code: A category that an Error Prone check already owns is deliberately absent + options.compilerArgs.add("-Xlint:deprecation,removal,unchecked,cast,rawtypes,divzero,this-escape,identity,text-blocks,dangling-doc-comments,restricted") + // The build itself: command-line options, path entries, output file collisions + options.compilerArgs.add("-Xlint:options,path,output-file-clash") + options.errorprone { // The checks live in errorprone.args, see https://github.com/tbroyer/gradle-errorprone-plugin#argument-files argumentFiles.from(rootProject.layout.projectDirectory.file("errorprone.args")) diff --git a/operator/src/test/java/it/aboutbits/postgresql/crd/clusterconnection/ClusterConnectionReconcilerErrorTest.java b/operator/src/test/java/it/aboutbits/postgresql/crd/clusterconnection/ClusterConnectionReconcilerErrorTest.java index e45799a..8b91783 100644 --- a/operator/src/test/java/it/aboutbits/postgresql/crd/clusterconnection/ClusterConnectionReconcilerErrorTest.java +++ b/operator/src/test/java/it/aboutbits/postgresql/crd/clusterconnection/ClusterConnectionReconcilerErrorTest.java @@ -52,8 +52,9 @@ void setUp() { resource.setSpec(spec); resource.setMetadata(metadata); - //noinspection unchecked - context = mock(Context.class); + @SuppressWarnings("unchecked") + Context mockedContext = mock(Context.class); + context = mockedContext; } @Test diff --git a/operator/src/test/java/it/aboutbits/postgresql/crd/grant/GrantReconcilerTest.java b/operator/src/test/java/it/aboutbits/postgresql/crd/grant/GrantReconcilerTest.java index 80bcfe7..36b017f 100644 --- a/operator/src/test/java/it/aboutbits/postgresql/crd/grant/GrantReconcilerTest.java +++ b/operator/src/test/java/it/aboutbits/postgresql/crd/grant/GrantReconcilerTest.java @@ -1294,7 +1294,7 @@ private void createTableWithSerial( ) { try (var dsl = postgreSQLContextFactory.getDSLContext(clusterConnection, databaseName)) { dsl.createTable(quotedName(schemaName, tableName)) - .column("id", SQLDataType.BIGINT.identity(true)) + .column("id", SQLDataType.BIGINT.generatedByDefaultAsIdentity()) .execute(); } } diff --git a/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java b/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java index dac3efb..c53dd23 100644 --- a/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java +++ b/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java @@ -1,11 +1,13 @@ package it.aboutbits.postgresql.helm; +import com.fasterxml.jackson.databind.JsonNode; import io.fabric8.kubernetes.api.model.ConfigBuilder; import io.fabric8.kubernetes.api.model.LocalObjectReference; import io.fabric8.kubernetes.api.model.Volume; import io.fabric8.kubernetes.api.model.VolumeMount; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.client.KubernetesClient; +import io.fabric8.kubernetes.client.utils.KubernetesSerialization; import io.fabric8.kubernetes.client.utils.Serialization; import io.quarkus.test.junit.QuarkusTest; import io.smallrye.common.process.ProcessBuilder; @@ -35,6 +37,7 @@ @NullMarked class HelmTest { private static final String ENV_VAR_KUBECONFIG = "KUBECONFIG"; + private static final KubernetesSerialization KUBERNETES_SERIALIZATION = new KubernetesSerialization(); /// The Pod and Container list fields that the chart exposes as free-form Helm values. private static final List LIST_VALUES = List.of( @@ -84,21 +87,19 @@ void helmInstall_createsDeployment() throws IOException { // 1. Verify files exist and contain expected data // ./Chart.yaml @SuppressWarnings("unchecked") - Map chartMetadata = Serialization.yamlMapper() - .readValue( - chartPath.resolve("Chart.yaml").toFile(), - Map.class - ); + Map chartMetadata = KUBERNETES_SERIALIZATION.unmarshal( + Files.newInputStream(chartPath.resolve("Chart.yaml")), + Map.class + ); assertThat(chartMetadata.get("name")).isEqualTo(chartName); // ./values.yaml @SuppressWarnings("unchecked") - Map values = Serialization.yamlMapper() - .readValue( - chartPath.resolve("values.yaml").toFile(), - Map.class - ); + Map values = KUBERNETES_SERIALIZATION.unmarshal( + Files.newInputStream(chartPath.resolve("values.yaml")), + Map.class + ); assertThat(values).containsKey(rootValuesAlias); @@ -123,8 +124,10 @@ void helmInstall_createsDeployment() throws IOException { // ./values.schema.json // The type must be declared for every list value, otherwise the generated schema // falls back to `string` and `helm install` rejects a list. - var valuesSchema = Serialization.jsonMapper() - .readTree(chartPath.resolve("values.schema.json").toFile()); + var valuesSchema = KUBERNETES_SERIALIZATION.unmarshal( + Files.newInputStream(chartPath.resolve("values.schema.json")), + JsonNode.class + ); for (var listValue : LIST_VALUES) { var schemaProperty = valuesSchema.at("/properties/%s/properties/%s".formatted(