25 lines
534 B
Plaintext
25 lines
534 B
Plaintext
This rule raises an issue when multiple branches of a regex alternative match the same input.
|
|
|
|
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,python,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
r"[ab]|a" # Noncompliant: the "|a" is redundant because "[ab]" already matches "a"
|
|
r".*|a" # Noncompliant: .* matches everything, so any other alternative is redundant
|
|
----
|
|
|
|
|
|
==== Compliant solution
|
|
|
|
[source,python,diff-id=1,diff-type=compliant]
|
|
----
|
|
r"[ab]"
|
|
r".*"
|
|
----
|