Closed protocol7 closed 6 days ago
Thanks for the clear runnable bug report @protocol7 ! Should fit right into UseStringReplaceTest.java. Would you be open to creating a draft pull request using just these failing tests?
Looks like we could then next add a new conditional that checks there's no special characters in the replacement string, and if so skip making changes and return invocation
early.
https://github.com/openrewrite/rewrite-static-analysis/blob/8a196e2a5d6236457d302e1df9fc7b41c000c9d3/src/main/java/org/openrewrite/staticanalysis/UseStringReplace.java#L84-L89
PR for this here: https://github.com/openrewrite/rewrite-static-analysis/pull/306
\
and$
in the replacement string ofString.replaceAll()
has special meaning (https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/regex/Matcher.html#replaceAll(java.lang.String)) and should not be rewritten.What version of OpenRewrite are you using?
What is the smallest, simplest way to reproduce the problem?