From 053a52e2f649d594c6db363e81d3a01ebf58b1d9 Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Wed, 11 Jan 2023 16:52:36 +0200 Subject: [PATCH] Fix Google Java Format tests and return code, and show output only if changed (#3810) --- .../{google_java_format_bad_1.java => gjf_bad_1.java} | 0 .../{google_java_format_bad_2.java => gjf_bad_2.java} | 0 .automation/test/google_java_format/gjf_good_1.java | 7 +++++++ .../{google_java_format_good_2.java => gjf_good_2.java} | 1 - .../google_java_format/google_java_format_good_1.java | 9 --------- lib/linter.sh | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) rename .automation/test/google_java_format/{google_java_format_bad_1.java => gjf_bad_1.java} (100%) rename .automation/test/google_java_format/{google_java_format_bad_2.java => gjf_bad_2.java} (100%) create mode 100644 .automation/test/google_java_format/gjf_good_1.java rename .automation/test/google_java_format/{google_java_format_good_2.java => gjf_good_2.java} (99%) delete mode 100644 .automation/test/google_java_format/google_java_format_good_1.java diff --git a/.automation/test/google_java_format/google_java_format_bad_1.java b/.automation/test/google_java_format/gjf_bad_1.java similarity index 100% rename from .automation/test/google_java_format/google_java_format_bad_1.java rename to .automation/test/google_java_format/gjf_bad_1.java diff --git a/.automation/test/google_java_format/google_java_format_bad_2.java b/.automation/test/google_java_format/gjf_bad_2.java similarity index 100% rename from .automation/test/google_java_format/google_java_format_bad_2.java rename to .automation/test/google_java_format/gjf_bad_2.java diff --git a/.automation/test/google_java_format/gjf_good_1.java b/.automation/test/google_java_format/gjf_good_1.java new file mode 100644 index 00000000..d067507e --- /dev/null +++ b/.automation/test/google_java_format/gjf_good_1.java @@ -0,0 +1,7 @@ +/** Represents a good Java file. */ +public static class JavaGood { + // Prints "Hello, World" to the terminal window. + private void helloWorld() { + System.out.println("Hello, World"); + } +} diff --git a/.automation/test/google_java_format/google_java_format_good_2.java b/.automation/test/google_java_format/gjf_good_2.java similarity index 99% rename from .automation/test/google_java_format/google_java_format_good_2.java rename to .automation/test/google_java_format/gjf_good_2.java index 376cef1f..6c0763c4 100644 --- a/.automation/test/google_java_format/google_java_format_good_2.java +++ b/.automation/test/google_java_format/gjf_good_2.java @@ -9,5 +9,4 @@ public class Application { public static void main(final String[] args) { SpringApplication.run(Application.class, args); } - } diff --git a/.automation/test/google_java_format/google_java_format_good_1.java b/.automation/test/google_java_format/google_java_format_good_1.java deleted file mode 100644 index 70f50e7c..00000000 --- a/.automation/test/google_java_format/google_java_format_good_1.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Represents a good Java file. -*/ -public static class JavaGood { - // Prints "Hello, World" to the terminal window. - private void helloWorld() { - System.out.println("Hello, World"); - } -} diff --git a/lib/linter.sh b/lib/linter.sh index 345c594e..683dfcb9 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -911,7 +911,7 @@ fi LINTER_COMMANDS_ARRAY['GITLEAKS']="gitleaks detect --no-banner --no-git -c ${GITLEAKS_LINTER_RULES} -v -s" LINTER_COMMANDS_ARRAY['GHERKIN']="gherkin-lint -c ${GHERKIN_LINTER_RULES}" LINTER_COMMANDS_ARRAY['GO']="golangci-lint run --fast -c ${GO_LINTER_RULES}" -LINTER_COMMANDS_ARRAY['GOOGLE_JAVA_FORMAT']="java -jar /usr/bin/google-java-format" +LINTER_COMMANDS_ARRAY['GOOGLE_JAVA_FORMAT']="java -jar /usr/bin/google-java-format --dry-run --set-exit-if-changed" LINTER_COMMANDS_ARRAY['GROOVY']="npm-groovy-lint -c ${GROOVY_LINTER_RULES} --failon warning --no-insight" LINTER_COMMANDS_ARRAY['HTML']="htmlhint --config ${HTML_LINTER_RULES}" LINTER_COMMANDS_ARRAY['JAVA']="java -jar /usr/bin/checkstyle -c ${JAVA_LINTER_RULES}"