Skip to content

Commit 042fe07

Browse files
committed
Adjust alert message
1 parent fea3d10 commit 042fe07

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

java/ql/src/Performance/StringReplaceAllWithNonRegex.ql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212
import java
1313

14-
from StringReplaceAllCall replaceAllCall
14+
from StringReplaceAllCall replaceAllCall, StringLiteral firstArg
1515
where
16+
firstArg = replaceAllCall.getArgument(0) and
1617
//only contains characters that could be a simple string
17-
replaceAllCall.getArgument(0).(StringLiteral).getValue().regexpMatch("^[a-zA-Z0-9]+$")
18+
firstArg.getValue().regexpMatch("^[a-zA-Z0-9]+$")
1819
select replaceAllCall,
19-
"Call to 'replaceAll' uses an argument comprised of plain string characters only."
20+
"This call to 'replaceAll' should be a call `replace` as its $@ is not a regular expression.",
21+
firstArg, "first argument"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| Test.java:4:14:4:36 | replaceAll(...) | Call to 'replaceAll' uses an argument comprised of plain string characters only. |
1+
| Test.java:4:14:4:36 | replaceAll(...) | This call to 'replaceAll' should be a call `replace` as its $@ is not a regular expression. | Test.java:4:28:4:30 | "t" | first argument |

0 commit comments

Comments
 (0)