From 8103d9f4f93305f741ba22b7b87dafc4920280f2 Mon Sep 17 00:00:00 2001 From: Chen Dai Date: Wed, 17 Aug 2022 16:14:11 -0700 Subject: [PATCH] Bump Checkstyle version to latest (#767) * Bump checkstyle version and fix violations Signed-off-by: Chen Dai * Fix checkstyle violations in test code Signed-off-by: Chen Dai Signed-off-by: Chen Dai --- build.gradle | 4 +-- config/checkstyle/google_checks.xml | 2 +- .../opensearch/sql/analysis/AnalyzerTest.java | 8 +++--- .../logical/LogicalPlanNodeVisitorTest.java | 4 +-- .../storage/script/core/ExpressionScript.java | 2 +- .../OpenSearchExecutionProtectorTest.java | 28 ++++++++++--------- .../sql/protocol/response/format/Format.java | 1 + 7 files changed, 26 insertions(+), 23 deletions(-) diff --git a/build.gradle b/build.gradle index 8a2f9046bf..855ec748bc 100644 --- a/build.gradle +++ b/build.gradle @@ -127,11 +127,11 @@ jacocoTestCoverageVerification { check.dependsOn jacocoTestCoverageVerification // TODO: fix code style in main and test source code -subprojects { +allprojects { apply plugin: 'checkstyle' checkstyle { configFile rootProject.file("config/checkstyle/google_checks.xml") - toolVersion "8.29" + toolVersion "10.3.2" configProperties = [ "org.checkstyle.google.suppressionfilter.config": rootProject.file("config/checkstyle/suppressions.xml")] ignoreFailures = false diff --git a/config/checkstyle/google_checks.xml b/config/checkstyle/google_checks.xml index 28a15230b5..a0c7d90fd9 100644 --- a/config/checkstyle/google_checks.xml +++ b/config/checkstyle/google_checks.xml @@ -279,7 +279,7 @@ value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/> - + diff --git a/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTest.java b/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTest.java index b9de96b30a..d4d72dd1d7 100644 --- a/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTest.java +++ b/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTest.java @@ -736,11 +736,11 @@ public void kmeanns_relation() { public void ad_batchRCF_relation() { Map argumentMap = new HashMap() {{ - put("shingle_size", new Literal(8, DataType.INTEGER)); - }}; + put("shingle_size", new Literal(8, DataType.INTEGER)); + }}; assertAnalyzeEqual( - new LogicalAD(LogicalPlanDSL.relation("schema"), argumentMap), - new AD(AstDSL.relation("schema"), argumentMap) + new LogicalAD(LogicalPlanDSL.relation("schema"), argumentMap), + new AD(AstDSL.relation("schema"), argumentMap) ); } diff --git a/core/src/test/java/org/opensearch/sql/planner/logical/LogicalPlanNodeVisitorTest.java b/core/src/test/java/org/opensearch/sql/planner/logical/LogicalPlanNodeVisitorTest.java index e899351d4f..1b81856296 100644 --- a/core/src/test/java/org/opensearch/sql/planner/logical/LogicalPlanNodeVisitorTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/logical/LogicalPlanNodeVisitorTest.java @@ -134,8 +134,8 @@ public void testAbstractPlanNodeVisitorShouldReturnNull() { put("shingle_size", new Literal(8, DataType.INTEGER)); put("time_decay", new Literal(0.0001, DataType.DOUBLE)); put("time_field", new Literal(null, DataType.STRING)); - } - }); + } + }); assertNull(ad.accept(new LogicalPlanNodeVisitor() { }, null)); } diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/core/ExpressionScript.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/core/ExpressionScript.java index 116d196fc3..acf147b975 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/core/ExpressionScript.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/core/ExpressionScript.java @@ -71,7 +71,7 @@ public ExpressionScript(Expression expression) { * Evaluate on the doc generate by the doc provider. * @param docProvider doc provider. * @param evaluator evaluator - * @return + * @return expr value */ public ExprValue execute(Supplier>> docProvider, BiFunction() {{ - put("centroids", new Literal(3, DataType.INTEGER)); - put("iterations", new Literal(2, DataType.INTEGER)); - put("distance_type", new Literal(null, DataType.STRING)); - } - }, nodeClient); + new HashMap() {{ + put("centroids", new Literal(3, DataType.INTEGER)); + put("iterations", new Literal(2, DataType.INTEGER)); + put("distance_type", new Literal(null, DataType.STRING)); + }}, + nodeClient + ); assertEquals(executionProtector.doProtect(mlCommonsOperator), executionProtector.visitMLCommons(mlCommonsOperator, null)); @@ -279,13 +280,14 @@ public void testVisitAD() { NodeClient nodeClient = mock(NodeClient.class); ADOperator adOperator = new ADOperator( - values(emptyList()), - new HashMap() {{ - put("shingle_size", new Literal(8, DataType.INTEGER)); - put("time_decay", new Literal(0.0001, DataType.DOUBLE)); - put("time_field", new Literal(null, DataType.STRING)); - } - }, nodeClient); + values(emptyList()), + new HashMap() {{ + put("shingle_size", new Literal(8, DataType.INTEGER)); + put("time_decay", new Literal(0.0001, DataType.DOUBLE)); + put("time_field", new Literal(null, DataType.STRING)); + }}, + nodeClient + ); assertEquals(executionProtector.doProtect(adOperator), executionProtector.visitAD(adOperator, null)); diff --git a/protocol/src/main/java/org/opensearch/sql/protocol/response/format/Format.java b/protocol/src/main/java/org/opensearch/sql/protocol/response/format/Format.java index 2ba08747b4..4291c09df0 100644 --- a/protocol/src/main/java/org/opensearch/sql/protocol/response/format/Format.java +++ b/protocol/src/main/java/org/opensearch/sql/protocol/response/format/Format.java @@ -24,6 +24,7 @@ public enum Format { private final String formatName; private static final Map ALL_FORMATS; + static { ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); for (Format format : Format.values()) {