From cf2906000105cca71a914aaf614088e035616f2b Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Thu, 12 Dec 2019 02:38:33 +0700 Subject: [PATCH 1/2] Fail formatting check before tests execute By default, the spotless Maven plugin binds its check goal to the verify phase (late in the lifecycle, after integration tests). Because we currently only run `mvn test` for CI, it doesn't proceed as far as verify so missed formatting is not caught by CI. This binds the check to an earlier phase, in between test-compile and test, so that it will fail before `mvn test` but not disrupt your dev workflow of compiling main and test sources as you work. This strikes a good compromise on failing fast for code standards without being _too_ nagging. For the complete lifecycle reference, see: https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index 8e4ed7d459a..d822d367b8d 100644 --- a/pom.xml +++ b/pom.xml @@ -384,6 +384,16 @@ + + + + spotless-check + process-test-classes + + check + + + org.apache.maven.plugins From ec0a6da4d35e9ad44aa9177c865769f938917025 Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Sun, 23 Feb 2020 21:08:49 +0700 Subject: [PATCH 2/2] Apply spotless formatting --- .../main/java/feast/core/util/PipelineUtil.java | 1 - .../test/java/feast/ingestion/ImportJobTest.java | 15 +++++++-------- .../feast/serving/specs/CachedSpecService.java | 6 +----- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/feast/core/util/PipelineUtil.java b/core/src/main/java/feast/core/util/PipelineUtil.java index 71cbc892bd1..8a84caf672c 100644 --- a/core/src/main/java/feast/core/util/PipelineUtil.java +++ b/core/src/main/java/feast/core/util/PipelineUtil.java @@ -72,5 +72,4 @@ private static List getClasspathFiles() { .map(entry -> new File(entry).getPath()) .collect(Collectors.toList()); } - } diff --git a/ingestion/src/test/java/feast/ingestion/ImportJobTest.java b/ingestion/src/test/java/feast/ingestion/ImportJobTest.java index 58ecae8f045..1148fa40422 100644 --- a/ingestion/src/test/java/feast/ingestion/ImportJobTest.java +++ b/ingestion/src/test/java/feast/ingestion/ImportJobTest.java @@ -32,14 +32,12 @@ import feast.core.StoreProto.Store.Subscription; import feast.ingestion.options.BZip2Compressor; import feast.ingestion.options.ImportOptions; -import feast.ingestion.options.OptionByteConverter; import feast.storage.RedisProto.RedisKey; import feast.test.TestUtil; import feast.test.TestUtil.LocalKafka; import feast.test.TestUtil.LocalRedis; import feast.types.FeatureRowProto.FeatureRow; import feast.types.ValueProto.ValueType.Enum; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -51,7 +49,6 @@ import org.apache.beam.sdk.PipelineResult; import org.apache.beam.sdk.PipelineResult.State; import org.apache.beam.sdk.options.PipelineOptionsFactory; -import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; import org.apache.kafka.common.serialization.ByteArraySerializer; import org.joda.time.Duration; import org.junit.AfterClass; @@ -166,11 +163,13 @@ public void runPipeline_ShouldWriteToRedisCorrectlyGivenValidSpecAndFeatureRow() .build(); ImportOptions options = PipelineOptionsFactory.create().as(ImportOptions.class); - BZip2Compressor compressor = new BZip2Compressor<>(option -> { - JsonFormat.Printer printer = - JsonFormat.printer().omittingInsignificantWhitespace().printingEnumsAsInts(); - return printer.print(option).getBytes(); - }); + BZip2Compressor compressor = + new BZip2Compressor<>( + option -> { + JsonFormat.Printer printer = + JsonFormat.printer().omittingInsignificantWhitespace().printingEnumsAsInts(); + return printer.print(option).getBytes(); + }); options.setFeatureSetJson(compressor.compress(spec)); options.setStoreJson(Collections.singletonList(JsonFormat.printer().print(redis))); options.setProject(""); diff --git a/serving/src/main/java/feast/serving/specs/CachedSpecService.java b/serving/src/main/java/feast/serving/specs/CachedSpecService.java index 1184f6da95a..35119589b27 100644 --- a/serving/src/main/java/feast/serving/specs/CachedSpecService.java +++ b/serving/src/main/java/feast/serving/specs/CachedSpecService.java @@ -195,11 +195,7 @@ private Map getFeatureToFeatureSetMapping( HashMap mapping = new HashMap<>(); featureSets.values().stream() - .collect( - groupingBy( - featureSet -> - Pair.of( - featureSet.getProject(), featureSet.getName()))) + .collect(groupingBy(featureSet -> Pair.of(featureSet.getProject(), featureSet.getName()))) .forEach( (group, groupedFeatureSets) -> { groupedFeatureSets =