Skip to content

Commit 53e4569

Browse files
committed
Silenced lint warnings in ContributedLibrary
Comparing strings with `==` operator triggers a lint4j warning. This refactoring avoids the use of `thisVersion == otherVersion`.
1 parent 0def104 commit 53e4569

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,13 @@ public boolean equals(Object obj) {
137137
String thisVersion = getParsedVersion();
138138
String otherVersion = ((ContributedLibrary) obj).getParsedVersion();
139139

140-
// Important: for legacy libs, versions are null. Two legacy libs must
140+
boolean versionEquals = (thisVersion != null && otherVersion != null
141+
&& thisVersion.equals(otherVersion));
142+
143+
// Important: for legacy libs, versions are null. Two legacy libs must
141144
// always pass this test.
142-
boolean versionEquals = thisVersion == otherVersion ||
143-
(thisVersion != null && otherVersion != null && thisVersion.equals(otherVersion));
145+
if (thisVersion == null && otherVersion == null)
146+
versionEquals = true;
144147

145148
String thisName = getName();
146149
String otherName = ((ContributedLibrary) obj).getName();

0 commit comments

Comments
 (0)