A regular expression has more groups, alternatives, classes and quantifiers than the configured limit
What it finds
Each group, alternative, class and quantifier is something a reader has to keep in mind; past a point a pattern is easier to get wrong than to read. Splitting it, building it from named parts, or using re.VERBOSE with comments helps. The limit is the parameter max (default 20).
From the rule's source, regex_hard_to_read.rs.
import re a = re.compile(r"(a|b|c|d|e|f)(g|h|i|j|k|l)(m|n|o|p|q|r)[a-z]+[0-9]*")tx0 reports: this pattern has 22 parts to follow, more than 20b = re.compile(r"(a|b)+") Turn it on, off or suppress it
The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:regex-hard-to-read" = "note"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/python:regex-hard-to-read] reason="..."tx0 explain tx0/python:regex-hard-to-read shows the same in the terminal. Found a false positive? Report it.