rspec/rules/S5855/python/rule.adoc
2023-08-04 16:18:23 +02:00

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".*"
----