A pattern lists the same alternative twice in one choice, so the second can never be what matches

tx0/python:regex-duplicate-alternativedefaultwarningreliability/strings-and-regexdepth fastbug

What it finds

In (jpg|png|jpg) the second jpg is never tried with success, as the first one already matched the same text. It is usually a typo for a different alternative.

From the rule's source, regex_duplicate_alternative.rs.

Example from the rule's tests
import re a = re.compile(r"\.(jpg|png|jpg)$")tx0 reports: this pattern offers the same alternative twiceb = re.compile(r"\.(jpg|png|gif)$")
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 in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/python:regex-duplicate-alternative" = "off"

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-duplicate-alternative] reason="..."

tx0 explain tx0/python:regex-duplicate-alternative shows the same in the terminal. Found a false positive? Report it.