Skip to content

Commit 510ae0c

Browse files
committed
fix: suppress Codacy warnings for StringBuilder fields
- Add @SuppressWarnings for PMD and SonarQube patterns - Add @SuppressFBWarnings for SpotBugs - Add codacy-disable comments - StringBuilder fields are safe: cleared after each XML element and capacity trimmed periodically Signed-off-by: dmiales <dmiales@gmail.com>
1 parent 35c177c commit 510ae0c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/src/main/java/com/owncloud/android/lib/resources/files/PropFindSaxHandler.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import java.util.List;
2121
import java.util.Locale;
2222

23+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
24+
2325
/**
2426
* SAX Handler for parsing WebDAV PROPFIND responses.
2527
* Handles streaming XML parsing to avoid OutOfMemoryError for large folders.
@@ -69,6 +71,9 @@ public class PropFindSaxHandler extends DefaultHandler {
6971
private final List<Object> files = new ArrayList<>();
7072
private RemoteFile currentFile;
7173
// StringBuilder is cleared after each XML element in endElement(), preventing memory accumulation
74+
// codacy-disable: StringBuffers can grow quite a lot - safe because cleared after each element
75+
@SuppressWarnings({"PMD.AvoidStringBufferField", "squid:S1642"})
76+
@SuppressFBWarnings(value = "DM_STRING_CTOR", justification = "StringBuilder is cleared after each XML element and capacity is trimmed periodically to prevent memory leaks")
7277
private final StringBuilder currentText = new StringBuilder(INITIAL_STRING_BUILDER_CAPACITY);
7378
private boolean inResponse = false;
7479
private boolean inProp = false;
@@ -87,6 +92,9 @@ public class PropFindSaxHandler extends DefaultHandler {
8792
// Lock information
8893
private boolean inLock = false;
8994
// StringBuilder is cleared after each lock element is processed, preventing memory accumulation
95+
// codacy-disable: StringBuffers can grow quite a lot - safe because cleared after each element
96+
@SuppressWarnings({"PMD.AvoidStringBufferField", "squid:S1642"})
97+
@SuppressFBWarnings(value = "DM_STRING_CTOR", justification = "StringBuilder is cleared after each lock element and capacity is trimmed periodically to prevent memory leaks")
9098
private StringBuilder lockText = new StringBuilder(INITIAL_STRING_BUILDER_CAPACITY);
9199

92100
public PropFindSaxHandler() {

0 commit comments

Comments
 (0)