An unbounded repetition in a regular expression repeats a part that can match nothing
What it finds
(a*)* and (x?)+ repeat a part that can match the empty string. The repetition adds nothing that its body does not already match, and makes the matcher try the empty match again and again; it usually means a * or ? slipped into the body.
Reported is an unbounded repetition whose body can match the empty string but contains something that matches characters.
From the rule's source, regex_patterns.rs.
val words = Regex("(a*)*b")tx0 reports: a repetition repeats a part that can match nothingval fine = Regex("(a+)*b")val optional = Regex("(a*)?b") 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:
[rules]
"tx0/kotlin:regex-empty-repeat" = "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/kotlin:regex-empty-repeat] reason="..."tx0 explain tx0/kotlin:regex-empty-repeat shows the same in the terminal. Found a false positive? Report it.