Skip to content

fix: handle boolean return value from File.delete() in Enunciate#6

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260331-032526-e8b93dfc
Open

fix: handle boolean return value from File.delete() in Enunciate#6
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260331-032526-e8b93dfc

Conversation

@sonarqube-agent

Copy link
Copy Markdown

Addressed SonarQube issue S899 by properly checking the boolean return value of tempDir.delete(). The fix wraps the delete call in a conditional check and logs a warning when deletion fails, ensuring file operations are properly validated instead of ignoring potential failures.

View Project in SonarCloud


Fixed Issues

java:S899 - Do something with the "boolean" value returned by "delete". • MINORView issue

Location: core/src/main/java/com/webcohesion/enunciate/Enunciate.java:288

Why is this an issue?

When the return value of a function call contains the operation status code, this value should be tested to make sure the operation completed successfully.

What changed

This hunk fixes the bug where the boolean return value of tempDir.delete() was being ignored. The static analysis rule requires that the status code returned by java.io.File operations like delete() must be checked. The fix wraps the call in an if (!tempDir.delete()) check and logs a warning message when the deletion fails, ensuring the return value is properly handled.

--- a/core/src/main/java/com/webcohesion/enunciate/Enunciate.java
+++ b/core/src/main/java/com/webcohesion/enunciate/Enunciate.java
@@ -288,1 +288,3 @@ public class Enunciate implements Runnable {
-    tempDir.delete();
+    if (!tempDir.delete()) {
+      getLogger().warn("Failed to delete temp file %s", tempDir);
+    }

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZZmtiWq2HDYqP_XyoAn for java:S899 rule

Generated by SonarQube Agent (task: 7ce5db39-7aa2-4d0b-a296-e574076e6051)
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant