Files
Bart van Helvertandintellij-monorepo-bot cfbf199e71 [java] Add ReplaceAllNonRegex inspection
Adds an inspection with a quickfix that suggests replacing `String#replaceAll` that doesn't pass regular expressions with `String#replace`. #IDEA-288385 Fixed


(cherry picked from commit e4bf212ae5693754c5a3dd51d9f5c578a5490e39)

IJ-MR-186138

GitOrigin-RevId: 8e2ad43e460b08f02529093e3f0d61a31e7d4efd
2025-12-24 10:54:58 +00:00

8 lines
625 B
Java

public class SimplePositive {
void m(String s) {
s = s.<warning descr="Call to 'replaceAll()' with a non-regex pattern can be replaced with 'replace()'"><caret>replaceAll</warning>("abc", "x");
s = s.<warning descr="Call to 'replaceAll()' with a non-regex pattern can be replaced with 'replace()'">replaceAll</warning>("-", "/");
s = s.<warning descr="Call to 'replaceAll()' with a non-regex pattern can be replaced with 'replace()'">replaceAll</warning>(" ", "_");
s = s.<warning descr="Call to 'replaceAll()' with a non-regex pattern can be replaced with 'replace()'">replaceAll</warning>("]", "a");
}
}