Non-terminal use of '\s' escape sequence
Reports \s
escape sequences anywhere except at text-block line endings or within a series of several escaped spaces. Such usages can be confusing or a mistake, especially if the string is interpreted as a regular expression. The \s
escape sequence is intended to encode a space at the end of text-block lines where normal spaces are trimmed. In other locations, as well as in regular string or char literals, \s
is identical to an ordinary space character (" "
).
Example:
Here it's likely that "\\s+"
was intended (to match any whitespace character). If not, using str.matches(" +")
would be less confusing.
A quick-fix is provided that replaces \s
escapes with space characters.
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
EscapedSpace- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
This inspection depends on the Java feature ''\s' escape sequences', which is available since Java 15.
New in 2022.3
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Java, 243.23126 |