Java: Add initial version of string replaceAll with no regex query

This commit is contained in:
Owen Mansel-Chan
2025-03-21 16:28:20 +00:00
parent d2a4f1e17a
commit 041adcd63a
5 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1 @@
| Test.java:4:14:4:36 | replaceAll(...) | Call to 'replaceAll' uses an argument comprised of plain string characters only. |

View File

@@ -0,0 +1 @@
Performance/StringReplaceAllWithNonRegex.ql

View File

@@ -0,0 +1,7 @@
public class Test {
void f() {
String s1 = "test";
s1 = s1.replaceAll("t", "x"); // NON_COMPLIANT
s1 = s1.replaceAll(".*", "x"); // COMPLIANT
}
}