From 6d1d93b146f81d8e2d70041510915f086dbfcd1a Mon Sep 17 00:00:00 2001 From: Jan Ouwens Date: Tue, 10 Oct 2023 11:46:52 +0200 Subject: [PATCH 1/4] Migrates from spotless to prettier-maven-plugin so we can start upgrading prettier-java again --- .prettierrc.yml | 1 - README.md | 2 +- pom.xml | 33 ++++++++------------------------- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/.prettierrc.yml b/.prettierrc.yml index e4135cfab..e4b60f57c 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -1,4 +1,3 @@ -# Changes here must be reflected in pom.xml tabWidth: 4 printWidth: 100 trailingComma: "none" diff --git a/README.md b/README.md index 24f40420f..49c3d7421 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ There are several Maven profiles that can be enabled or disabled: ## Formatting -EqualsVerifier uses [Prettier-Java](https://github.com/jhipster/prettier-java) through [Spotless](https://github.com/diffplug/spotless) to format Java files. You can call it using `mvn` (without any parameters), which will also run the tests and all the other static analysis. Or run `mvn spotless:apply` to only run the formatter. +EqualsVerifier uses [Prettier-Java](https://github.com/jhipster/prettier-java) through [prettier-maven-plugin](https://github.com/HubSpot/prettier-maven-plugin) to format Java files. You can call it using `mvn clean verify`, or run `mvn prettier:write` to only run the formatter. ## Modules diff --git a/pom.xml b/pom.xml index 1c43dd503..8afa254ae 100644 --- a/pom.xml +++ b/pom.xml @@ -107,9 +107,8 @@ 1.15.0 4.7.3.6 4.7.3 - 2.40.0 - 2.2.0 - 2.8.8 + 0.21 + 2.3.1 @@ -290,38 +289,22 @@ - com.diffplug.spotless - spotless-maven-plugin - ${version.spotless.maven} + com.hubspot.maven.plugins + prettier-maven-plugin + ${version.prettier.maven} - - - - src/*/java/**/*.java - - - - ${version.spotless.prettier} - ${version.spotless.prettier-java} - - - - 4 - 100 - none - - - - + ${version.prettier-java.maven} + validate check + com.groupcdg From 6525d5ed20ba5294d7d571e9202586877ddf3735 Mon Sep 17 00:00:00 2001 From: Jan Ouwens Date: Tue, 10 Oct 2023 11:48:44 +0200 Subject: [PATCH 2/4] Removes explicit node download from Workflow because prettier-maven-plugin does that --- .github/workflows/ci.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75f92d81a..be35b622b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,15 +61,9 @@ jobs: with: distribution: ${{ matrix.dist }} java-version: ${{ matrix.java }} - - name: 'Set up node' # Needed for formatting with prettier - if: ${{ !(matrix.experimental && github.event_name == 'pull_request') }} - uses: actions/setup-node@v3 - with: - node-version: 12 - name: 'Display JDK version' if: ${{ !(matrix.experimental && github.event_name == 'pull_request') }} run: java -version - name: 'Run Maven' if: ${{ !(matrix.experimental && github.event_name == 'pull_request') }} - # Don't clean, or whatever was cached in target/spotless-node-modules-prettier-format is lost - run: mvn verify ${{ matrix.flags }} + run: mvn clean verify ${{ matrix.flags }} From a3246612e0cb7173d4edd068eaa5bb017b0468da Mon Sep 17 00:00:00 2001 From: Jan Ouwens Date: Tue, 10 Oct 2023 11:52:00 +0200 Subject: [PATCH 3/4] Reformats after prettier-java update --- .../extended_contract/SealedTypesTest.java | 3 ++- .../checkers/fieldchecks/SignificantFieldCheck.java | 6 ++---- .../internal/reflection/RecordObjectAccessor.java | 8 ++++---- .../integration/basic_contract/TransitivityTest.java | 12 ++++-------- .../prefabvalues/TypeTagParameterizedTest.java | 6 ++++-- .../equalsverifier/testhelpers/types/TypeHelper.java | 6 ++---- 6 files changed, 18 insertions(+), 23 deletions(-) diff --git a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesTest.java b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesTest.java index dfe514072..6d86e3aff 100644 --- a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesTest.java +++ b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesTest.java @@ -169,7 +169,8 @@ public SealedTypeContainer( @Override public boolean equals(Object obj) { return ( - obj instanceof SealedTypeContainer other && + obj instanceof + SealedTypeContainer other && Objects.equals(sealedWithFinalChild, other.sealedWithFinalChild) && Objects.equals(sealedWithNonsealedChild, other.sealedWithNonsealedChild) ); diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/checkers/fieldchecks/SignificantFieldCheck.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/checkers/fieldchecks/SignificantFieldCheck.java index 00e9df361..3199b058b 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/checkers/fieldchecks/SignificantFieldCheck.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/checkers/fieldchecks/SignificantFieldCheck.java @@ -172,10 +172,8 @@ private void assertFieldShouldBeIgnored( private boolean shouldAllFieldsBeUsed(FieldAccessor fieldAccessor) { return ( !warningsToSuppress.contains(Warning.ALL_FIELDS_SHOULD_BE_USED) && - !( - warningsToSuppress.contains(Warning.ALL_NONFINAL_FIELDS_SHOULD_BE_USED) && - !fieldAccessor.fieldIsFinal() - ) + !(warningsToSuppress.contains(Warning.ALL_NONFINAL_FIELDS_SHOULD_BE_USED) && + !fieldAccessor.fieldIsFinal()) ); } diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/RecordObjectAccessor.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/RecordObjectAccessor.java index 06db38261..57c1f8bb0 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/RecordObjectAccessor.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/RecordObjectAccessor.java @@ -172,13 +172,13 @@ private String buildMessage(Throwable e, Class type, List params) { String msg = prefix; if (hasZeros) { msg += - "\n If the record does not accept 0 or false as a value for its constructor parameters," + - " consider suppressing Warning.ZERO_FIELDS."; + "\n If the record does not accept 0 or false as a value for its constructor parameters," + + " consider suppressing Warning.ZERO_FIELDS."; } if (hasSomethingElse) { msg += - "\n If the record does not accept any of the given values for its constructor parameters," + - " consider providing prefab values for the types of those fields."; + "\n If the record does not accept any of the given values for its constructor parameters," + + " consider providing prefab values for the types of those fields."; } return msg; } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/TransitivityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/TransitivityTest.java index 929b49bc0..23510c710 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/TransitivityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/TransitivityTest.java @@ -268,8 +268,7 @@ public boolean equals(Object obj) { } ThreeFieldsUsingAndOr other = (ThreeFieldsUsingAndOr) obj; return ( - Objects.equals(f, other.f) && - Objects.equals(g, other.g) || + (Objects.equals(f, other.f) && Objects.equals(g, other.g)) || Objects.equals(h, other.h) ); } @@ -300,8 +299,7 @@ public boolean equals(Object obj) { ThreeFieldsUsingOrAnd other = (ThreeFieldsUsingOrAnd) obj; return ( Objects.equals(f, other.f) || - Objects.equals(g, other.g) && - Objects.equals(h, other.h) + (Objects.equals(g, other.g) && Objects.equals(h, other.h)) ); } @@ -372,10 +370,8 @@ public boolean equals(Object obj) { FiveFieldsUsingAndsAndOrs other = (FiveFieldsUsingAndsAndOrs) obj; return ( Objects.equals(f, other.f) || - Objects.equals(g, other.g) && - Objects.equals(h, other.h) || - Objects.equals(i, other.i) && - Objects.equals(j, other.j) + (Objects.equals(g, other.g) && Objects.equals(h, other.h)) || + (Objects.equals(i, other.i) && Objects.equals(j, other.j)) ); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/prefabvalues/TypeTagParameterizedTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/prefabvalues/TypeTagParameterizedTest.java index 94c4a5078..eb5a66e2c 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/prefabvalues/TypeTagParameterizedTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/prefabvalues/TypeTagParameterizedTest.java @@ -27,8 +27,10 @@ public class TypeTagParameterizedTest { private final Map> fieldWithNestedTypeParameters = null; @SuppressWarnings("unused") - private final Map, Map, Map>> fieldWithRidiculousTypeParameters = - null; + private final Map< + List, + Map, Map> + > fieldWithRidiculousTypeParameters = null; @SuppressWarnings({ "unused", "rawtypes" }) private final Map rawMapField = null; diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/testhelpers/types/TypeHelper.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/testhelpers/types/TypeHelper.java index a4c8fc6c6..3a69c625e 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/testhelpers/types/TypeHelper.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/testhelpers/types/TypeHelper.java @@ -66,11 +66,9 @@ public boolean equals(Object obj) { result &= Objects.equals(_Byte, other._Byte); result &= _Char == other._Char; result &= - _Double == null - ? other._Double == null - : Double.compare(_Double, other._Double) == 0; + _Double == null ? other._Double == null : Double.compare(_Double, other._Double) == 0; result &= - _Float == null ? other._Float == null : Float.compare(_Float, other._Float) == 0; + _Float == null ? other._Float == null : Float.compare(_Float, other._Float) == 0; result &= Objects.equals(_Int, other._Int); result &= Objects.equals(_Long, other._Long); result &= Objects.equals(_Short, other._Short); From 89d8e67b09875219400a6544d06444d3741a87da Mon Sep 17 00:00:00 2001 From: Jan Ouwens Date: Tue, 10 Oct 2023 11:55:22 +0200 Subject: [PATCH 4/4] Updates .git-blame-ignore-revs --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 9ba3f8340..01ee0ea7b 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -4,3 +4,5 @@ d698561e58fce0a498ccc9c43539046b5f9a6ddf # Prettier (initial run) a9aba4023da451dba32fcf7189348e3e063feaf4 +# Reformats after prettier-java update +a3246612e0cb7173d4edd068eaa5bb017b0468da