A regular expression holds several spaces in a row, which are hard to count

tx0/java:regex-repeated-spacesstrictwarningstyle

What it finds

"a b" asks for exactly three spaces, which a reader can hardly count, and which an editor may change. a {3}b says the same plainly.

Reported is a run of two or more literal spaces in a pattern.

From the rule's source, regex_repeated_spaces.rs.

Example from the rule's tests
class Spaces {  String[] split(String line) {    String[] a = line.split("a   b");tx0 reports: several spaces in a row    String[] b = line.split("a {3}b");    return a.length > 0 ? a : b;  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:regex-repeated-spaces" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:regex-repeated-spaces] reason="..."

tx0 explain tx0/java:regex-repeated-spaces shows the same in the terminal. Found a false positive? Report it.