Skip to content

Commit 8b68d95

Browse files
authored
Merge pull request github#19560 from owen-mc/java/add-stringreplaceallwithnonregex-test
Java: Add test showing correct usage
2 parents 4995137 + 79453cc commit 8b68d95

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

java/ql/src/Performance/StringReplaceAllWithNonRegex.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class Test {
1818
String s1 = "test";
1919
s1 = s1.replaceAll("t", "x"); // NON_COMPLIANT
2020
s1 = s1.replaceAll(".*", "x"); // COMPLIANT
21+
s1 = s1.replace("t", "x"); // COMPLIANT
2122
}
2223
}
2324

java/ql/test/query-tests/StringReplaceAllWithNonRegex/Test.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ void f() {
33
String s1 = "test";
44
s1 = s1.replaceAll("t", "x"); // $ Alert // NON_COMPLIANT
55
s1 = s1.replaceAll(".*", "x"); // COMPLIANT
6+
s1 = s1.replace("t", "x"); // COMPLIANT
67
}
78
}

0 commit comments

Comments
 (0)