Skip to content

Commit

Permalink
Merge branch 'replace-prettier-with-eclipse-formatter'
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Dec 12, 2024
2 parents 035d571 + 069c982 commit 2da23b4
Show file tree
Hide file tree
Showing 288 changed files with 6,146 additions and 8,548 deletions.
4 changes: 3 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Reformates code according to google-java-format rules
# Reformats code according to google-java-format rules
263194cec89d64eeedfb667bfe59c3edd03c711f
# Cleans up awkwardly formatterd code
d698561e58fce0a498ccc9c43539046b5f9a6ddf
# Prettier (initial run)
a9aba4023da451dba32fcf7189348e3e063feaf4
# Reformats after prettier-java update
a3246612e0cb7173d4edd068eaa5bb017b0468da
# Reformats according to Eclipse formatter
9d24f8eea0c4989649722d997d529bb25f7d0d4d
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Before you continue, please consider the following:

# NOTE

- Please run `mvn prettier:write` to format the code before opening a PR. Otherwise, GitHub Actions will complain at you 😉. Unfortunately, you will need to have Node installed to do so.
- Mutation tests will be run by [PITest](https://pitest.org/) after opening the PR. It will post comments in the PR for each issue found. Please take a look at them, but if the comments don't make sense, please don't worry about them.
- Please run `mvn spotless:apply` to format the code before opening a PR. Otherwise, GitHub Actions will complain at you 😉.
- Mutation tests will be run by [PITest](https://pitest.org/) after opening the PR. It will post comments in the PR for each issue found. Please take a look and fix what makes sense, but don't worry about the ones that don't.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ jobs:
if: ${{ !(matrix.experimental && github.event_name == 'pull_request') }}
uses: actions/cache@v4
with:
path: |
~/.m2/repository
target/spotless-node-modules-prettier-format
path: ~/.m2/repository
key: ${{ runner.os }}-mvn-${{ matrix.cache-id }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-mvn-${{ matrix.cache-id }}
Expand Down
4 changes: 0 additions & 4 deletions .prettierrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ There are several Maven profiles that can be enabled or disabled:

## Formatting

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.
EqualsVerifier uses [Spotless for Maven](https://github.com/diffplug/spotless/tree/main/plugin-maven) with a custom [Eclipse configuration](https://github.com/jqno/equalsverifier/blob/main/build/eclipse-formatter-config.xml) to format Java files. You can check formatting using `mvn clean verify`, or run `mvn spotless:apply` to fix any formatting issues automatically.

## Modules

Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions build/eclipse-formatter-config.importorder
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Organize Import Order
#Mon Dec 09 20:14:26 CET 2024
0=\#
1=java
2=
404 changes: 404 additions & 0 deletions build/eclipse-formatter-config.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javafx.collections.ObservableList;
import javafx.collections.ObservableMap;
import javafx.collections.ObservableSet;

import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.testhelpers.types.Point;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -79,20 +80,19 @@ static final class JavaFxApiClassesContainer {
private final StringProperty stringProperty;

public JavaFxApiClassesContainer(
ObservableList observableList,
ObservableMap observableMap,
ObservableSet observableSet,
BooleanProperty booleanProperty,
DoubleProperty doubleProperty,
FloatProperty floatProperty,
IntegerProperty integerProperty,
ListProperty listProperty,
LongProperty longProperty,
MapProperty mapProperty,
ObjectProperty objectProperty,
SetProperty setProperty,
StringProperty stringProperty
) {
ObservableList observableList,
ObservableMap observableMap,
ObservableSet observableSet,
BooleanProperty booleanProperty,
DoubleProperty doubleProperty,
FloatProperty floatProperty,
IntegerProperty integerProperty,
ListProperty listProperty,
LongProperty longProperty,
MapProperty mapProperty,
ObjectProperty objectProperty,
SetProperty setProperty,
StringProperty stringProperty) {
this.observableList = observableList;
this.observableMap = observableMap;
this.observableSet = observableSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,43 @@ public class PrefabValuesForFieldInRecordTest {
@Test
public void fail_whenRecordHasSinglePrecondition() {
ExpectedException
.when(() -> EqualsVerifier.forClass(SinglePrecondition.class).verify())
.assertFailure()
.assertMessageContains("Record:", "failed to run constructor", "[1]");
.when(() -> EqualsVerifier.forClass(SinglePrecondition.class).verify())
.assertFailure()
.assertMessageContains("Record:", "failed to run constructor", "[1]");
}

@Test
public void succeed_whenRecordHasSinglePrecondition_givenPrefabValuesForField() {
EqualsVerifier
.forClass(SinglePrecondition.class)
.withPrefabValuesForField("i", 111, 142)
.verify();
EqualsVerifier.forClass(SinglePrecondition.class).withPrefabValuesForField("i", 111, 142).verify();
}

@Test
public void fail_whenRecordHasDualPrecondition() {
ExpectedException
.when(() -> EqualsVerifier.forClass(DualPrecondition.class).verify())
.assertFailure()
.assertMessageContains("Record:", "failed to run constructor", "[1, 1]");
.when(() -> EqualsVerifier.forClass(DualPrecondition.class).verify())
.assertFailure()
.assertMessageContains("Record:", "failed to run constructor", "[1, 1]");
}

@Test
public void fail_whenRecordHasDualPrecondition_givenPrefabValuesForOnlyOneField() {
ExpectedException
.when(() ->
EqualsVerifier
.forClass(DualPrecondition.class)
.withPrefabValuesForField("x", 111, 142)
.verify()
)
.assertFailure()
.assertMessageContains("Record:", "failed to run constructor", "[111, 1]");
.when(
() -> EqualsVerifier
.forClass(DualPrecondition.class)
.withPrefabValuesForField("x", 111, 142)
.verify())
.assertFailure()
.assertMessageContains("Record:", "failed to run constructor", "[111, 1]");
}

@Test
public void succeed_whenRecordHasDualPrecondition_givenPrefabValueForBothFields() {
EqualsVerifier
.forClass(DualPrecondition.class)
.withPrefabValuesForField("x", 111, 142)
.withPrefabValuesForField("y", 505, 555)
.verify();
.forClass(DualPrecondition.class)
.withPrefabValuesForField("x", 111, 142)
.withPrefabValuesForField("y", 505, 555)
.verify();
}

record SinglePrecondition(int i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.io.Serializable;
import java.util.Objects;

import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import nl.jqno.equalsverifier.internal.reflection.RecordsHelper;
Expand Down Expand Up @@ -33,9 +34,9 @@ public void succeed_whenClassIsAPrivateRecord() {
@Test
public void fail_whenConstructorChecksNull() {
ExpectedException
.when(() -> EqualsVerifier.forClass(NullCheckingRecord.class).verify())
.assertFailure()
.assertMessageContains("Record:", "failed to run constructor", "Warning.NULL_FIELDS");
.when(() -> EqualsVerifier.forClass(NullCheckingRecord.class).verify())
.assertFailure()
.assertMessageContains("Record:", "failed to run constructor", "Warning.NULL_FIELDS");
}

@Test
Expand All @@ -46,33 +47,33 @@ public void succeed_whenConstructorChecksNull_givenSuppressedWarning() {
@Test
public void fail_whenConstructorChecksValue() {
ExpectedException
.when(() -> EqualsVerifier.forClass(ValueCheckingRecord.class).verify())
.assertFailure()
.assertMessageContains("Record:", "failed to run constructor", "prefab values");
.when(() -> EqualsVerifier.forClass(ValueCheckingRecord.class).verify())
.assertFailure()
.assertMessageContains("Record:", "failed to run constructor", "prefab values");
}

@Test
public void fail_whenRecordInvariantIsViolated_givenIntFieldIsModifiedInConstructor() {
ExpectedException
.when(() -> EqualsVerifier.forClass(BrokenInvariantIntFieldRecord.class).verify())
.assertFailure()
.assertMessageContains("Record invariant", "intField");
.when(() -> EqualsVerifier.forClass(BrokenInvariantIntFieldRecord.class).verify())
.assertFailure()
.assertMessageContains("Record invariant", "intField");
}

@Test
public void fail_whenRecordInvariantIsViolated_givenStringFieldIsModifiedInConstructor() {
ExpectedException
.when(() -> EqualsVerifier.forClass(BrokenInvariantStringFieldRecord.class).verify())
.assertFailure()
.assertMessageContains("Record invariant", "stringField");
.when(() -> EqualsVerifier.forClass(BrokenInvariantStringFieldRecord.class).verify())
.assertFailure()
.assertMessageContains("Record invariant", "stringField");
}

@Test
public void fail_whenRecordInvariantIsViolated_givenBothFieldsAreModifiedInConstructor() {
ExpectedException
.when(() -> EqualsVerifier.forClass(BrokenInvariantBothRecord.class).verify())
.assertFailure()
.assertMessageContains("Record invariant", "intField", "stringField");
.when(() -> EqualsVerifier.forClass(BrokenInvariantBothRecord.class).verify())
.assertFailure()
.assertMessageContains("Record invariant", "intField", "stringField");
}

@Test
Expand All @@ -83,41 +84,41 @@ public void succeed_whenRecordImplementsItsOwnEquals() {
@Test
public void fail_whenRecordImplementsItsOwnEquals_givenNotAllFieldsAreUsed() {
ExpectedException
.when(() -> EqualsVerifier.forClass(NotAllFieldsRecord.class).verify())
.assertFailure()
.assertMessageContains("Significant fields");
.when(() -> EqualsVerifier.forClass(NotAllFieldsRecord.class).verify())
.assertFailure()
.assertMessageContains("Significant fields");
}

@Test
public void fail_whenRecordConstructorThrows() {
ExpectedException
.when(() -> EqualsVerifier.forClass(ThrowingConstructorRecord.class).verify())
.assertFailure()
.assertMessageContains("Record", "failed to run constructor");
.when(() -> EqualsVerifier.forClass(ThrowingConstructorRecord.class).verify())
.assertFailure()
.assertMessageContains("Record", "failed to run constructor");
}

@Test
public void fail_whenRecordConstructorThrowsNpe() {
ExpectedException
.when(() -> EqualsVerifier.forClass(NullFieldRecord.class).verify())
.assertFailure()
.assertMessageContains("Record", "failed to run constructor");
.when(() -> EqualsVerifier.forClass(NullFieldRecord.class).verify())
.assertFailure()
.assertMessageContains("Record", "failed to run constructor");
}

@Test
public void fail_whenRecordAccessorThrows() {
ExpectedException
.when(() -> EqualsVerifier.forClass(ThrowingAccessorRecord.class).verify())
.assertFailure()
.assertMessageContains("Record", "failed to run accessor method");
.when(() -> EqualsVerifier.forClass(ThrowingAccessorRecord.class).verify())
.assertFailure()
.assertMessageContains("Record", "failed to run accessor method");
}

@Test
public void fail_whenRecordAccessorThrowsNpe() {
ExpectedException
.when(() -> EqualsVerifier.forClass(NullAccessorRecord.class).verify())
.assertFailure()
.assertMessageContains("Record", "failed to run accessor method", "s()");
.when(() -> EqualsVerifier.forClass(NullAccessorRecord.class).verify())
.assertFailure()
.assertMessageContains("Record", "failed to run accessor method", "s()");
}

@Test
Expand All @@ -128,9 +129,9 @@ public void succeed_whenRecordContainsStaticField() {
@Test
public void succeed_whenRecordValidatesInput_givenValidPrefabValues() {
EqualsVerifier
.forClass(ValidatingConstructorRecord.class)
.withPrefabValues(String.class, "valid-1", "valid-2")
.verify();
.forClass(ValidatingConstructorRecord.class)
.withPrefabValues(String.class, "valid-1", "valid-2")
.verify();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

import nl.jqno.equalsverifier.internal.reflection.ClassProbe;
import org.junit.jupiter.api.Test;
import org.objenesis.ObjenesisStd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertNotSame;

import java.util.LinkedHashSet;

import nl.jqno.equalsverifier.internal.instantiation.vintage.FactoryCache;
import nl.jqno.equalsverifier.internal.instantiation.vintage.VintageValueProvider;
import nl.jqno.equalsverifier.internal.reflection.Tuple;
Expand Down Expand Up @@ -32,11 +33,7 @@ public void setUp() {

@Test
public void redCopyHasTheSameValuesAsRed_whenSutContainsGenericValueThatNeedsToBeIdenticalInRedAndRedCopy() {
Tuple<?> tuple = factory.createValues(
new TypeTag(GenericRecordContainer.class),
valueProvider,
typeStack
);
Tuple<?> tuple = factory.createValues(new TypeTag(GenericRecordContainer.class), valueProvider, typeStack);

assertEquals(tuple.getRed(), tuple.getRedCopy());
assertNotSame(tuple.getRed(), tuple.getRedCopy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertSame;

import java.lang.reflect.Field;

import nl.jqno.equalsverifier.internal.reflection.FieldIterable;
import nl.jqno.equalsverifier.internal.reflection.Instantiator;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.lang.reflect.Constructor;
import java.util.LinkedHashSet;

import nl.jqno.equalsverifier.internal.instantiation.JavaApiPrefabValues;
import nl.jqno.equalsverifier.internal.instantiation.vintage.FactoryCache;
import nl.jqno.equalsverifier.internal.instantiation.vintage.VintageValueProvider;
Expand Down Expand Up @@ -37,14 +38,13 @@ public void scrambleLeavesOriginalUnaffected() throws Exception {
@Test
public void scramble() throws Exception {
Constructor<?> constructor = Point.class.getDeclaredConstructor(int.class, int.class);
factoryCache.put(
Point.class,
values(
constructor.newInstance(1, 2),
constructor.newInstance(2, 3),
constructor.newInstance(1, 2)
)
);
factoryCache
.put(
Point.class,
values(
constructor.newInstance(1, 2),
constructor.newInstance(2, 3),
constructor.newInstance(1, 2)));
Object original = constructor.newInstance(1, 2);

Object scrambled = doScramble(original);
Expand Down
Loading

0 comments on commit 2da23b4

Please sign in to comment.