jqno / equalsverifier

EqualsVerifier can be used in Java unit tests to verify whether the contract for the equals and hashCode methods is met.
http://www.jqno.nl/equalsverifier
Apache License 2.0
708 stars 75 forks source link

[Feature] Disable warnings on Array.equals #1005

Open jandk opened 1 week ago

jandk commented 1 week ago

Describe the feature

When testing generated classes, we came across an issue where EqualsVerifier complained about arrays not using Arrays.equals. We could implement this, but we found no way to disable this warning.

We might just be missing something.

Describe the solution you'd like

A warning we could disable specifically for Arrays

Describe alternatives

No response

Additional context

No response

jqno commented 1 week ago

Hi!

I could add a way to disable the warning, and generated classes that you can't change could be a good reason to do so.

But I'm wondering, you say you could implement this. Does that mean you can change the code generation so that it does use Arrays.equals for the generated array? Because in general, that's what you want when comparing arrays. Using equals to compare arrays is like using == to compare strings; it's only true when they are the same object instance.