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,php,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
"/[ab]|a/" // Noncompliant: the "|a" is redundant because "[ab]" already matches "a"
|
|
"/.*|a/" // Noncompliant: .* matches everything, so any other alternative is redundant
|
|
----
|
|
|
|
|
|
==== Compliant solution
|
|
|
|
[source,php,diff-id=1,diff-type=compliant]
|
|
----
|
|
"/[ab]/"
|
|
"/.*/"
|
|
----
|