diff --git a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorCopyingTest.java b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorCopyingTest.java index 9c44be00d..bd8d42ee2 100644 --- a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorCopyingTest.java +++ b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorCopyingTest.java @@ -11,7 +11,7 @@ class RecordObjectAccessorCopyingTest { - private Objenesis objenesis = new ObjenesisStd(); + private final Objenesis objenesis = new ObjenesisStd(); @Test void copyHappyPath() { diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/checkers/SignatureChecker.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/checkers/SignatureChecker.java index d48142105..8542cc5d3 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/checkers/SignatureChecker.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/checkers/SignatureChecker.java @@ -41,7 +41,7 @@ private List getEqualsMethods() { List result = new ArrayList<>(); for (Method method : type.getDeclaredMethods()) { - if (method.getName().equals("equals") && !Modifier.isStatic(method.getModifiers())) { + if ("equals".equals(method.getName()) && !Modifier.isStatic(method.getModifiers())) { result.add(method); } } diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/AwtFactoryProvider.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/AwtFactoryProvider.java index 898f43940..b7319ad31 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/AwtFactoryProvider.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/AwtFactoryProvider.java @@ -17,6 +17,7 @@ public final class AwtFactoryProvider implements FactoryProvider { private static final int CS_RED = ColorSpace.CS_sRGB; private static final int CS_BLUE = ColorSpace.CS_LINEAR_RGB; + @Override public FactoryCache getFactoryCache() { FactoryCache cache = new FactoryCache(); diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/GuavaFactoryProvider.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/GuavaFactoryProvider.java index 40867acbd..3270f5ea2 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/GuavaFactoryProvider.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/GuavaFactoryProvider.java @@ -17,6 +17,7 @@ public final class GuavaFactoryProvider implements FactoryProvider { private static final Comparator OBJECT_COMPARATOR = Comparator.comparingInt(Object::hashCode); + @Override public FactoryCache getFactoryCache() { FactoryCache cache = new FactoryCache(); diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaFxFactoryProvider.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaFxFactoryProvider.java index 3daa9ba8e..ef8f4b737 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaFxFactoryProvider.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaFxFactoryProvider.java @@ -25,6 +25,7 @@ public final class JavaFxFactoryProvider implements FactoryProvider { * As long as there's no easy dependency for JavaFX to rely on in Maven, we can't refer to the actual types, and * have to go around it with String representations of the type names. */ + @Override public FactoryCache getFactoryCache() { FactoryCache cache = new FactoryCache(); diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaxFactoryProvider.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaxFactoryProvider.java index 8be1c35ba..e4246e98f 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaxFactoryProvider.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaxFactoryProvider.java @@ -9,6 +9,7 @@ public final class JavaxFactoryProvider implements FactoryProvider { + @Override public FactoryCache getFactoryCache() { FactoryCache cache = new FactoryCache(); diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JodaFactoryProvider.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JodaFactoryProvider.java index fbc378e65..a2bc692bd 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JodaFactoryProvider.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JodaFactoryProvider.java @@ -9,6 +9,7 @@ public final class JodaFactoryProvider implements FactoryProvider { + @Override public FactoryCache getFactoryCache() { FactoryCache cache = new FactoryCache(); diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/RmiFactoryProvider.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/RmiFactoryProvider.java index 6779a6717..f53213348 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/RmiFactoryProvider.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/RmiFactoryProvider.java @@ -9,6 +9,7 @@ public final class RmiFactoryProvider implements FactoryProvider { + @Override public FactoryCache getFactoryCache() { FactoryCache cache = new FactoryCache(); diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/annotations/AnnotationProperties.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/annotations/AnnotationProperties.java index 085a04069..35c61611c 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/annotations/AnnotationProperties.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/reflection/annotations/AnnotationProperties.java @@ -14,8 +14,8 @@ public class AnnotationProperties { private final String className; - private Map enumValues = new HashMap<>(); - private Map> arrayValues = new HashMap<>(); + private final Map enumValues = new HashMap<>(); + private final Map> arrayValues = new HashMap<>(); /** * Constructor. diff --git a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/util/Formatter.java b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/util/Formatter.java index 09580671e..4b3e561fe 100644 --- a/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/util/Formatter.java +++ b/equalsverifier-core/src/main/java/nl/jqno/equalsverifier/internal/util/Formatter.java @@ -15,7 +15,7 @@ public final class Formatter { private final String message; - private Object[] objects; + private final Object[] objects; /** Private constructor. Call {@link #of(String, Object...)} to instantiate. */ private Formatter(String message, Object... objects) { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/EclipseGetClassPoint.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/EclipseGetClassPoint.java index 8d4fade64..517888c26 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/EclipseGetClassPoint.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/EclipseGetClassPoint.java @@ -24,7 +24,7 @@ public EclipseGetClassPoint(int x, int y, Color color) { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((color == null) ? 0 : color.hashCode()); + result = prime * result + (color == null ? 0 : color.hashCode()); result = prime * result + x; result = prime * result + y; return result; diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/EclipseInstanceOfPoint.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/EclipseInstanceOfPoint.java index 372d5d294..e3c3d9bf0 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/EclipseInstanceOfPoint.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/EclipseInstanceOfPoint.java @@ -24,7 +24,7 @@ public EclipseInstanceOfPoint(int x, int y, Color color) { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((color == null) ? 0 : color.hashCode()); + result = prime * result + (color == null ? 0 : color.hashCode()); result = prime * result + x; result = prime * result + y; return result; diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/LombokCanEqual.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/LombokCanEqual.java index ab576321f..b94358dc0 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/LombokCanEqual.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/LombokCanEqual.java @@ -99,6 +99,7 @@ public boolean equals(final java.lang.Object o) { return true; } + @Override @java.lang.SuppressWarnings("all") public boolean canEqual(final java.lang.Object other) { return other instanceof LombokCanEqual.ColorPoint; 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 9ff377515..eb32006f5 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 @@ -250,7 +250,7 @@ public boolean equals(Object obj) { return false; } ThreeFieldsUsingAndOr other = (ThreeFieldsUsingAndOr) obj; - return (Objects.equals(f, other.f) && Objects.equals(g, other.g) || Objects.equals(h, other.h)); + return Objects.equals(f, other.f) && Objects.equals(g, other.g) || Objects.equals(h, other.h); } @Override diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExtendedReflexivityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExtendedReflexivityTest.java index 01cc47476..a5a0637c5 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExtendedReflexivityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExtendedReflexivityTest.java @@ -311,6 +311,7 @@ public int hashCode() { } interface InterfaceWithEquals { + @Override boolean equals(Object obj); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignatureTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignatureTest.java index c0913f137..933877e9d 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignatureTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignatureTest.java @@ -200,6 +200,7 @@ static final class StaticEqualsMethod { this.i = i; } + @Override public boolean equals(Object obj) { if (!(obj instanceof StaticEqualsMethod)) { return false; diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java index 5ed625627..7649e6bf6 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java @@ -52,7 +52,7 @@ void reportReturnsTheSameInformationAsVerify() { assertThat(reported.length).isEqualTo(verified.length + 1); for (int i = 0; i < verified.length; i++) { - if (!verified[i].getMethodName().equals("verify")) { + if (!"verify".equals(verified[i].getMethodName())) { // When the `verify` method is reached, the stacktraces start to diverge. break; } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/SubjectCreatorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/SubjectCreatorTest.java index 9661a30f6..57cdcb98a 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/SubjectCreatorTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/SubjectCreatorTest.java @@ -25,10 +25,10 @@ class SubjectCreatorTest { private static final String S_RED = "abc"; private static final String S_BLUE = "xyz"; - private Configuration config = ConfigurationHelper.emptyConfiguration(SomeClass.class); - private ValueProvider valueProvider = new SubjectCreatorTestValueProvider(); - private FieldCache fieldCache = new FieldCache(); - private Objenesis objenesis = new ObjenesisStd(); + private final Configuration config = ConfigurationHelper.emptyConfiguration(SomeClass.class); + private final ValueProvider valueProvider = new SubjectCreatorTestValueProvider(); + private final FieldCache fieldCache = new FieldCache(); + private final Objenesis objenesis = new ObjenesisStd(); private SubjectCreator sut = new SubjectCreator<>(config, valueProvider, fieldCache, objenesis); private Field fieldX; @@ -197,6 +197,7 @@ void noValueFound() { static class SubjectCreatorTestValueProvider implements ValueProvider { + @Override @SuppressWarnings("unchecked") public Optional> provide(TypeTag tag) { if (int.class.equals(tag.getType())) { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderTest.java index ba5fac828..15a8a49cd 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderTest.java @@ -24,8 +24,8 @@ class VintageValueProviderTest { private static final TypeTag POINT_TAG = new TypeTag(Point.class); private static final TypeTag INT_TAG = new TypeTag(int.class); - private Objenesis objenesis = new ObjenesisStd(); - private FactoryCache factoryCache = new FactoryCache(); + private final Objenesis objenesis = new ObjenesisStd(); + private final FactoryCache factoryCache = new FactoryCache(); private VintageValueProvider vp; @BeforeEach @@ -170,6 +170,7 @@ public NpeThrowing(int i) { this.i = i; } + @Override public boolean equals(Object obj) { if (obj == null) { throw new NullPointerException(); @@ -180,6 +181,7 @@ public boolean equals(Object obj) { return i == ((NpeThrowing) obj).i; } + @Override public int hashCode() { return i; } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleFactoryTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleFactoryTest.java index c30ab531d..acbadc8e6 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleFactoryTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleFactoryTest.java @@ -6,7 +6,7 @@ class SimpleFactoryTest { - private SimpleFactory factory = new SimpleFactory<>("red", "blue", new String("red")); + private final SimpleFactory factory = new SimpleFactory<>("red", "blue", new String("red")); @Test void createRed() { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorCopyingTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorCopyingTest.java index 98a77cf6c..a0e24de03 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorCopyingTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorCopyingTest.java @@ -15,7 +15,7 @@ class InPlaceObjectAccessorCopyingTest { - private Objenesis objenesis = new ObjenesisStd(); + private final Objenesis objenesis = new ObjenesisStd(); @Test void copyHappyPath() { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldCacheTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldCacheTest.java index f967a8d17..f44a53ec5 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldCacheTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldCacheTest.java @@ -10,13 +10,13 @@ class FieldCacheTest { - private String stringField = "string"; + private final String stringField = "string"; private final Tuple stringValues = Tuple.of("red", "blue", "red"); - private String intField = "int"; + private final String intField = "int"; private final Tuple intValues = Tuple.of(1, 2, 1); - private FieldCache cache = new FieldCache(); + private final FieldCache cache = new FieldCache(); @Test void putAndGetTuple() { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/InstantiatorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/InstantiatorTest.java index c787e3b4b..e898e17e1 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/InstantiatorTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/InstantiatorTest.java @@ -21,7 +21,7 @@ class InstantiatorTest { - private Objenesis objenesis = new ObjenesisStd(); + private final Objenesis objenesis = new ObjenesisStd(); @Test void instantiateClass() { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TupleTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TupleTest.java index de46a6040..b6cb42ebc 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TupleTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TupleTest.java @@ -8,7 +8,7 @@ class TupleTest { - private Tuple tuple = Tuple.of("red", "blue", new String("red")); + private final Tuple tuple = Tuple.of("red", "blue", new String("red")); @Test void equalsAndHashCode() {