Conversation
...nts/api/api-modules-javascript/src/main/resources/META-INF/dirigible/modules/src/db/query.ts
Fixed
Show fixed
Hide fixed
| continue; | ||
| } | ||
|
|
||
| try (Connection connection = dataSource.getConnection()) { |
Check notice
Code scanning / CodeQL
Inefficient empty string test Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 22 hours ago
In general, to fix this category of issue you should replace s.equals("") or "".equals(s) with either s.isEmpty() (preferred in Java 6+) or s.length() == 0 when s is known to be non-null. In contexts where you must guard against null, keep the guard (s != null && s.isEmpty()).
In this specific case, line is obtained from StringTokenizer.nextToken(), which never returns null, so line.trim() is also guaranteed non-null. Therefore, the most direct and clear fix is to replace "".equals(line.trim()) with line.trim().isEmpty(). This change preserves behavior (skip tokens that are only whitespace) and matches the codebase’s existing pattern of using length-based or isEmpty() emptiness checks. No new imports or helper methods are needed. The only region to change is line 240 in components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/service/DatabaseExecutionService.java.
| @@ -237,7 +237,7 @@ | ||
| StringTokenizer tokenizer = new StringTokenizer(sql, getDelimiter(sql)); | ||
| while (tokenizer.hasMoreTokens()) { | ||
| String line = tokenizer.nextToken(); | ||
| if ("".equals(line.trim())) { | ||
| if (line.trim().isEmpty()) { | ||
| continue; | ||
| } | ||
|
|
// Export CSV
const sql = "SELECT * FROM DIRIGIBLE_EXTENSIONS WHERE EXTENSION_EXTENSIONPOINT_NAME = :editor";
query.exportCsv(sql, [{ "name": "editor", "type": "VARCHAR", "value": "platform-editors" }], "SystemDB", "my-export-file");