style: include ENMI_EQUALS_ON_ENUM (#5189)

This commit is contained in:
Piotr Idzik 2024-05-28 21:03:52 +02:00 committed by GitHub
parent 1a98ebe36b
commit 2cda944643
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 5 deletions

View File

@ -222,9 +222,6 @@
<Match>
<Bug pattern="FCBL_FIELD_COULD_BE_LOCAL" />
</Match>
<Match>
<Bug pattern="ENMI_EQUALS_ON_ENUM" />
</Match>
<Match>
<Bug pattern="IMC_IMMATURE_CLASS_VAR_NAME" />
</Match>

View File

@ -124,14 +124,14 @@ class LWWElementSet {
* @return True if the first element's timestamp is greater or the bias is ADDS and timestamps are equal.
*/
public boolean compareTimestamps(Element e, Element other) {
if (!e.bias.equals(other.bias)) {
if (e.bias != other.bias) {
throw new IllegalArgumentException("Invalid bias value");
}
Bias bias = e.bias;
int timestampComparison = Integer.compare(e.timestamp, other.timestamp);
if (timestampComparison == 0) {
return !bias.equals(Bias.ADDS);
return bias != Bias.ADDS;
}
return timestampComparison < 0;
}