Skip to content

Commit 45c2605

Browse files
Fix SpotBugs warnings for EC_UNRELATED_TYPES and EQ_ALWAYS_FALSE (#4367)
* Fix EC_UNRELATED_TYPES in XYChart.java by comparing font face IDs (int) instead of comparing string representation to int. * Fix EQ_ALWAYS_FALSE in NetworkManager.java by implementing identity equality instead of always returning false. * Update generate-quality-report.py to enforce these rules in the future. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 73565cb commit 45c2605

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,9 @@ def main() -> None:
771771
"FE_FLOATING_POINT_EQUALITY",
772772
"FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER",
773773
"SA_FIELD_SELF_ASSIGNMENT",
774-
"UC_USELESS_CONDITION"
774+
"UC_USELESS_CONDITION",
775+
"EC_UNRELATED_TYPES",
776+
"EQ_ALWAYS_FALSE"
775777
}
776778
violations = [
777779
f for f in spotbugs.findings

CodenameOne/src/com/codename1/charts/views/XYChart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void draw(Canvas canvas, int x, int y, int width, int height, Paint paint
125125
if (paint.getTypeface() == null
126126
|| (mRenderer.getTextTypeface() != null && paint.getTypeface().equals(
127127
mRenderer.getTextTypeface()))
128-
|| !paint.getTypeface().toString().equals(mRenderer.getTextTypefaceName())
128+
|| paint.getTypeface().getFace() != mRenderer.getTextTypefaceName()
129129
|| paint.getTypeface().getStyle() != mRenderer.getTextTypefaceStyle()) {
130130
if (mRenderer.getTextTypeface() != null) {
131131
paint.setTypeface(mRenderer.getTextTypeface());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ private void retryWithDifferentAPN() {
10611061
}
10621062

10631063
public boolean equals(Object o) {
1064-
return false;
1064+
return this == o;
10651065
}
10661066

10671067
}

0 commit comments

Comments
 (0)