-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UseStringReplace
should not rewrite when special replacement string
#301
Comments
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 rewrite-static-analysis/src/main/java/org/openrewrite/staticanalysis/UseStringReplace.java Lines 84 to 89 in 8a196e2
|
UseStringReplace
should not rewrite when special replacement string
…ring If the replacement string of String.replaceAll contains $ or \, we should not rewrite it as these indicate special replacements: https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/regex/Matcher.html#replaceAll(java.lang.String) Fixes openrewrite#301
…ring If the replacement string of String.replaceAll contains $ or \, we should not rewrite it as these indicate special replacements: https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/regex/Matcher.html#replaceAll(java.lang.String) Fixes openrewrite#301
PR for this here: #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?
The text was updated successfully, but these errors were encountered: