From 1ed2679870190b43ea3c810f9a4cb9cd7a15b84f Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 2 May 2022 13:53:10 -0400 Subject: [PATCH] Run `check` in CI rather than build This also checks style. Update to checkstyle 10.2 while I'm here and clean up all existing style violations (mainly missing docs comments on public classes). --- .github/workflows/test.yml | 2 +- build.gradle | 6 +- config/checkstyle/google_checks.xml | 160 ++++++++++-------- .../brightspots/rcv/GuiApplication.java | 2 +- .../brightspots/rcv/GuiConfigController.java | 3 + .../rcv/GuiTiebreakerController.java | 3 + .../java/network/brightspots/rcv/Main.java | 3 + .../brightspots/rcv/RawContestConfig.java | 22 ++- 8 files changed, 118 insertions(+), 83 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 95d4e549a..b360421f2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,4 +16,4 @@ jobs: java-version: '17' distribution: 'temurin' - name: Test with Gradle - run: ./gradlew build + run: ./gradlew check diff --git a/build.gradle b/build.gradle index 8b29f746a..c54a605f5 100644 --- a/build.gradle +++ b/build.gradle @@ -35,11 +35,13 @@ application { // ### Checkstyle plugin settings checkstyle { - toolVersion = "8.36.2" + toolVersion = '10.2' // Keep the below file updated along with subsequent versions of Checkstyle (make sure to choose // the tag matching the toolVersion above): - // https://github.com/checkstyle/checkstyle/blob/checkstyle-8.36.2/src/main/resources/google_checks.xml + // https://github.com/checkstyle/checkstyle/blob/checkstyle-10.2/src/main/resources/google_checks.xml configFile = file("$projectDir/config/checkstyle/google_checks.xml") + maxWarnings = 0 + ignoreFailures = false } System.setProperty( "org.checkstyle.google.suppressionfilter.config", "$projectDir/config/checkstyle/checkstyle-suppressions.xml") diff --git a/config/checkstyle/google_checks.xml b/config/checkstyle/google_checks.xml index 651247499..b26ce4297 100644 --- a/config/checkstyle/google_checks.xml +++ b/config/checkstyle/google_checks.xml @@ -1,7 +1,7 @@ + "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> - + + + + + + + + + + + + - + + + + + + + - + @@ -35,9 +51,9 @@ + value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/> + value="Consider using special escape sequence instead of octal value or Unicode escaped value."/> @@ -52,15 +68,15 @@ + value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/> + value="LITERAL_DO, LITERAL_ELSE, LITERAL_FOR, LITERAL_IF, LITERAL_WHILE"/> @@ -88,8 +104,9 @@ + value="COMMA, SEMI, TYPECAST, LITERAL_IF, LITERAL_ELSE, LITERAL_RETURN, + LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, LITERAL_FINALLY, DO_WHILE, ELLIPSIS, + LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_CATCH, LAMBDA"/> @@ -99,7 +116,7 @@ + value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/> + value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/> @@ -120,7 +137,7 @@ @@ -136,13 +153,13 @@ - + - + @@ -155,78 +172,83 @@ + value="Package name ''{0}'' must match pattern ''{1}''."/> + value="Type name ''{0}'' must match pattern ''{1}''."/> + value="Member name ''{0}'' must match pattern ''{1}''."/> + value="Parameter name ''{0}'' must match pattern ''{1}''."/> + value="Lambda parameter name ''{0}'' must match pattern ''{1}''."/> + value="Catch parameter name ''{0}'' must match pattern ''{1}''."/> + value="Local variable name ''{0}'' must match pattern ''{1}''."/> - + + value="Class type name ''{0}'' must match pattern ''{1}''."/> - + + + value="Record component name ''{0}'' must match pattern ''{1}''."/> + + + + value="Method type name ''{0}'' must match pattern ''{1}''."/> + value="Interface type name ''{0}'' must match pattern ''{1}''."/> + value="GenericWhitespace ''{0}'' is followed by whitespace."/> + value="GenericWhitespace ''{0}'' is preceded with whitespace."/> + value="GenericWhitespace ''{0}'' should followed by whitespace."/> + value="GenericWhitespace ''{0}'' is not preceded with whitespace."/> - + @@ -236,10 +258,11 @@ + @@ -250,18 +273,18 @@ + value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, + LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR, METHOD_REF, + TYPE_EXTENSION_AND "/> @@ -289,17 +313,17 @@ + value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/> + value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/> - + @@ -312,14 +336,19 @@ + + + + + - - - + value="Method name ''{0}'' must match pattern ''{1}''."/> + @@ -328,26 +357,9 @@ - + - - - - - - - - - - - - - - - - - diff --git a/src/main/java/network/brightspots/rcv/GuiApplication.java b/src/main/java/network/brightspots/rcv/GuiApplication.java index 6d923ea4c..2d78e4edb 100644 --- a/src/main/java/network/brightspots/rcv/GuiApplication.java +++ b/src/main/java/network/brightspots/rcv/GuiApplication.java @@ -27,7 +27,7 @@ import javafx.stage.Stage; @SuppressWarnings("WeakerAccess") -public class GuiApplication extends Application { +class GuiApplication extends Application { private static final int STAGE_HEIGHT = 1000; private static final int STAGE_WIDTH = 1200; diff --git a/src/main/java/network/brightspots/rcv/GuiConfigController.java b/src/main/java/network/brightspots/rcv/GuiConfigController.java index 0ee955bea..2185617dc 100644 --- a/src/main/java/network/brightspots/rcv/GuiConfigController.java +++ b/src/main/java/network/brightspots/rcv/GuiConfigController.java @@ -72,6 +72,9 @@ import network.brightspots.rcv.Tabulator.TiebreakMode; import network.brightspots.rcv.Tabulator.WinnerElectionMode; +/** + * View controller for config layout. + */ @SuppressWarnings({"WeakerAccess"}) public class GuiConfigController implements Initializable { diff --git a/src/main/java/network/brightspots/rcv/GuiTiebreakerController.java b/src/main/java/network/brightspots/rcv/GuiTiebreakerController.java index b5c4b10b7..42affe55c 100644 --- a/src/main/java/network/brightspots/rcv/GuiTiebreakerController.java +++ b/src/main/java/network/brightspots/rcv/GuiTiebreakerController.java @@ -26,6 +26,9 @@ import javafx.scene.control.ListView; import javafx.stage.Stage; +/** + * View controller for tiebreaker layout. + */ @SuppressWarnings("WeakerAccess") public class GuiTiebreakerController { diff --git a/src/main/java/network/brightspots/rcv/Main.java b/src/main/java/network/brightspots/rcv/Main.java index 94691a717..7291fcf77 100644 --- a/src/main/java/network/brightspots/rcv/Main.java +++ b/src/main/java/network/brightspots/rcv/Main.java @@ -25,6 +25,9 @@ import java.util.ArrayList; import java.util.List; +/** + * Main entry point to the RCV tabulator program. + */ @SuppressWarnings("WeakerAccess") public class Main extends GuiApplication { diff --git a/src/main/java/network/brightspots/rcv/RawContestConfig.java b/src/main/java/network/brightspots/rcv/RawContestConfig.java index 57003fb23..ceddffd6f 100644 --- a/src/main/java/network/brightspots/rcv/RawContestConfig.java +++ b/src/main/java/network/brightspots/rcv/RawContestConfig.java @@ -27,6 +27,9 @@ import com.fasterxml.jackson.annotation.JsonInclude; import java.util.List; +/** + * Contest configuration that can be serialized and deserialized. + */ @SuppressWarnings("WeakerAccess") @JsonIgnoreProperties(ignoreUnknown = true) public class RawContestConfig { @@ -40,7 +43,9 @@ public class RawContestConfig { RawContestConfig() { } - // OutputSettings: encapsulates the output settings + /** + * Output settings that can be serialized and deserialized. + */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) public static class OutputSettings { @@ -54,8 +59,11 @@ public static class OutputSettings { public boolean generateCdfJson; } - // CvrSource: encapsulates a source cast vote record file - // all indexes are 1-based + /** + * Source cast vote record file that can be serialized and deserialized. + * + *

All indexes are 1-based.

+ */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) public static class CvrSource { @@ -200,7 +208,9 @@ public void setTreatBlankAsUndeclaredWriteIn(boolean treatBlankAsUndeclaredWrite } } - // Candidate encapsulates data for each candidate in a contest + /** + * Contest candidate data that can be serialized and deserialized. + */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) public static class Candidate { @@ -243,7 +253,9 @@ public void setExcluded(boolean excluded) { } } - // ContestRules: encapsulates the set of rules required to perform contest tabulation + /** + * Contest rules necessary for tabulation that can be serialized and deserialized. + */ @SuppressWarnings({"unused", "RedundantSuppression"}) @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL)