From 44f8ba339f9a6d557317d260faf78ad73d95bc60 Mon Sep 17 00:00:00 2001 From: Dai MIKURUBE Date: Fri, 26 Apr 2024 17:45:31 +0900 Subject: [PATCH 1/2] Checkstyle with checkstyle 9.3 --- build.gradle | 6 +- config/checkstyle/README.md | 9 +- ...ssions.xml => checkstyle-suppressions.xml} | 1 + config/checkstyle/checkstyle.xml | 540 +++++++++++------- config/checkstyle/google_checks.xml | 535 ++++++++++------- embulk-guess-json/build.gradle | 6 +- gradle/libs.versions.toml | 2 + 7 files changed, 677 insertions(+), 422 deletions(-) rename config/checkstyle/{suppressions.xml => checkstyle-suppressions.xml} (89%) diff --git a/build.gradle b/build.gradle index 6e16cbccf..814331408 100644 --- a/build.gradle +++ b/build.gradle @@ -195,11 +195,11 @@ tasks.withType(Checkstyle) { } checkstyle { - toolVersion "8.7" + toolVersion = libs.versions.checkstyle.get() configFile = file("${rootProject.projectDir}/config/checkstyle/checkstyle.xml") configProperties = [ - "checkstyle.config.path": file("${projectDir}/config/checkstyle") + "org.checkstyle.google.suppressionfilter.config": file("${rootProject.projectDir}/config/checkstyle/checkstyle-suppressions.xml"), ] ignoreFailures = false - maxWarnings = 0 // https://github.com/gradle/gradle/issues/881 + maxWarnings = 0 } diff --git a/config/checkstyle/README.md b/config/checkstyle/README.md index efa34b9e0..403c7363c 100644 --- a/config/checkstyle/README.md +++ b/config/checkstyle/README.md @@ -1,12 +1,11 @@ Checkstyle for the Embulk project ================================== -* google_check.xml: Downloaded from: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml - * Commit: 60f41e3c16e6c94b0bf8c2e5e4b4accf4ad394ab +* google_check.xml: Downloaded from: https://github.com/checkstyle/checkstyle/blob/checkstyle-9.3/src/main/resources/google_checks.xml + * Commit: 5c1903792f8432243cc8ae5cd79a03a004d3c09c * checkstyle.xml: Customized from google_check.xml. - * To enable suppressions through suppressions.xml. + * To enable suppressions through checkstyle-suppressions.xml. * To enable suppressions with @SuppressWarnings. - * To accept package names with underscores. * To indent with 4-column spaces. - * To limit columns to 180 characters, which will be shortened later. + * To limit columns to 180 characters. * To reject unused imports. diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/checkstyle-suppressions.xml similarity index 89% rename from config/checkstyle/suppressions.xml rename to config/checkstyle/checkstyle-suppressions.xml index 087253ac6..aefd4d6b2 100644 --- a/config/checkstyle/suppressions.xml +++ b/config/checkstyle/checkstyle-suppressions.xml @@ -8,6 +8,7 @@ + diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index e31da0870..c70b0c4ac 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -1,242 +1,368 @@ + "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> - + - + - + + + + + + + + + + + - - - - + - + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + - - - - + + + - - - - + + + + + + + - - - - - + + + - - - - + + + + + + + - - - - + + + + + + + + + + + - - - - + + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/config/checkstyle/google_checks.xml b/config/checkstyle/google_checks.xml index a6fc40b5f..515a844ac 100644 --- a/config/checkstyle/google_checks.xml +++ b/config/checkstyle/google_checks.xml @@ -1,237 +1,364 @@ + "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> - + - + - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - + + + - - - - + + + - - - - + + + + + + + - - - - - + + + - - - - + + + + + + + - - - - + + + + + + + + + + + - - - - + + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + diff --git a/embulk-guess-json/build.gradle b/embulk-guess-json/build.gradle index 2aac02230..b2832a6d1 100644 --- a/embulk-guess-json/build.gradle +++ b/embulk-guess-json/build.gradle @@ -156,11 +156,11 @@ tasks.withType(Checkstyle) { } checkstyle { - toolVersion "8.7" + toolVersion = libs.versions.checkstyle.get() configFile = file("${rootProject.projectDir}/config/checkstyle/checkstyle.xml") configProperties = [ - "checkstyle.config.path": file("${rootProject.projectDir}/config/checkstyle") + "org.checkstyle.google.suppressionfilter.config": file("${rootProject.projectDir}/config/checkstyle/checkstyle-suppressions.xml"), ] ignoreFailures = false - maxWarnings = 0 // https://github.com/gradle/gradle/issues/881 + maxWarnings = 0 } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2503f77d7..237fc376e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,6 +20,8 @@ embulk-util-timestamp = "0.2.2" junit4 = "4.13.2" embulk-core = "0.11.0" +checkstyle = "9.3" + [libraries] embulk-spi = { group = "org.embulk", name = "embulk-spi", version.ref = "embulk-spi" } From 75989c9387d31399d8b6fabc9b5623fd0d745090 Mon Sep 17 00:00:00 2001 From: Dai MIKURUBE Date: Fri, 26 Apr 2024 17:48:44 +0900 Subject: [PATCH 2/2] Suppress checkstyle warnings --- src/test/java/org/embulk/parser/json/TestJsonParserPlugin.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/embulk/parser/json/TestJsonParserPlugin.java b/src/test/java/org/embulk/parser/json/TestJsonParserPlugin.java index caafeea46..8a7504138 100644 --- a/src/test/java/org/embulk/parser/json/TestJsonParserPlugin.java +++ b/src/test/java/org/embulk/parser/json/TestJsonParserPlugin.java @@ -77,6 +77,7 @@ public void checkDefaultValues() { assertEquals(JsonParserPlugin.InvalidEscapeStringPolicy.PASSTHROUGH, task.getInvalidEscapeStringPolicy()); } + @SuppressWarnings("checkstyle:Indentation") @Test public void readNormalJson() throws Exception { transaction(config, fileInput( @@ -227,6 +228,7 @@ public void useUnEscapeInvalidEscapeString() throws Exception { assertEquals(JsonString.of("b"), object.get("a")); } + @SuppressWarnings("checkstyle:Indentation") @Test public void checkInvalidEscapeStringFunction() { //PASSTHROUGH