Skip to content

Commit bd5b84c

Browse files
Fix SpotBugs EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS warnings (#4355)
Fixed logic in URL.equals and Result.equals to compare correct types. Removed incompatible type check in PropertyIndex.equals. Updated generate-quality-report.py to fail on this violation. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 6c47754 commit bd5b84c

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

.github/scripts/generate-quality-report.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,8 @@ def main() -> None:
762762
"RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE",
763763
"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR",
764764
"SF_SWITCH_NO_DEFAULT",
765-
"DM_DEFAULT_ENCODING"
765+
"DM_DEFAULT_ENCODING",
766+
"EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS"
766767
}
767768
violations = [
768769
f for f in spotbugs.findings

CodenameOne/src/com/codename1/io/URL.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public java.lang.String getFile() {
101101
}
102102

103103
public boolean equals(java.lang.Object o) {
104-
return o instanceof URL && ((URL) o).u.equals(o);
104+
return o instanceof URL && u.equals(((URL) o).u);
105105
}
106106

107107
public synchronized int hashCode() {

CodenameOne/src/com/codename1/processing/Result.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,10 @@ public int hashCode() {
311311
* @see Object#equals(Object)
312312
*/
313313
public boolean equals(final Object other) {
314-
return root.equals(other);
314+
if (other instanceof Result) {
315+
return root.equals(((Result) other).root);
316+
}
317+
return false;
315318
}
316319

317320
/**

CodenameOne/src/com/codename1/properties/PropertyIndex.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,6 @@ public boolean equals(Object o) {
838838
return true;
839839
}
840840
}
841-
if (o instanceof PropertyBusinessObject) {
842-
return equals(((PropertyBusinessObject) o).getPropertyIndex());
843-
}
844841
return false;
845842
}
846843

0 commit comments

Comments
 (0)