Adjust alert message

This commit is contained in:
Owen Mansel-Chan
2025-03-25 11:50:42 +00:00
parent fea3d10b97
commit 042fe07494
2 changed files with 6 additions and 4 deletions

View File

@@ -11,9 +11,11 @@
import java
from StringReplaceAllCall replaceAllCall
from StringReplaceAllCall replaceAllCall, StringLiteral firstArg
where
firstArg = replaceAllCall.getArgument(0) and
//only contains characters that could be a simple string
replaceAllCall.getArgument(0).(StringLiteral).getValue().regexpMatch("^[a-zA-Z0-9]+$")
firstArg.getValue().regexpMatch("^[a-zA-Z0-9]+$")
select replaceAllCall,
"Call to 'replaceAll' uses an argument comprised of plain string characters only."
"This call to 'replaceAll' should be a call `replace` as its $@ is not a regular expression.",
firstArg, "first argument"

View File

@@ -1 +1 @@
| Test.java:4:14:4:36 | replaceAll(...) | Call to 'replaceAll' uses an argument comprised of plain string characters only. |
| 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 |