Use Collection.isEmpty() to test if collections are empty (#9072)

Fix issue S1155 'Collection.isEmpty()' should be used to test for emptiness
This commit is contained in:
jean pierre Lerbscher authored and GitHub committed 2024-03-26 09:13:21 -06:00
1 parent e4079f71c1
commit c729b41763
7 files changed
+11 -11

No files matched your search

+3 -3
View File
@@ -345,21 +345,21 @@ public final class FilePath implements SerializableOnlyOverRemoting {
String token = tokens.get(i);
if (token.equals(".")) {
tokens.remove(i);
if (tokens.size() > 0)
if (!tokens.isEmpty())
tokens.remove(i > 0 ? i - 1 : i);
} else if (token.equals("..")) {
if (i == 0) {
// If absolute path, just remove: /../something
// If relative path, not collapsible so leave as-is
tokens.remove(0);
if (tokens.size() > 0) token += tokens.remove(0);
if (!tokens.isEmpty()) token += tokens.remove(0);
if (!isAbsolute) buf.append(token);
} else {
// Normalize: remove something/.. plus separator before/after
i -= 2;
for (int j = 0; j < 3; j++) tokens.remove(i);
if (i > 0) tokens.remove(i - 1);
else if (tokens.size() > 0) tokens.remove(0);
else if (!tokens.isEmpty()) tokens.remove(0);
}
} else
i += 2;