A regular expression has a quantifier {1}, which changes nothing, or {0}, which removes its part
What it finds
a{1} matches the same as a, and a{0} matches nothing, as if a were not there. The first is noise; the second usually a mistake.
Reported is a quantifier {1}, {1,1}, {0} or {0,0}.
From the rule's source, regex_redundant_quantifier.rs.
import java.util.regex.Pattern; class Quantifiers { Pattern a = Pattern.compile("ab{1}c");tx0 reports: {1} changes nothing Pattern b = Pattern.compile("ab{0}c");tx0 reports: {0} removes the part before it Pattern c = Pattern.compile("ab{2}c");} 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/java:regex-redundant-quantifier" = "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-redundant-quantifier] reason="..."tx0 explain tx0/java:regex-redundant-quantifier shows the same in the terminal. Found a false positive? Report it.