rspec/rules/S5857/php/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

44 lines
672 B
Plaintext

== Why is this an issue?
include::../description.adoc[]
=== Noncompliant code example
[source,php]
----
/<.+?>/
/".*?"/
----
=== Compliant solution
[source,php]
----
/<[^>]++>/
/"[^"]*+"/
----
or
[source,php]
----
/<[^>]+>/
/"[^"]*"/
----
=== Exceptions
This rule only applies in cases where the reluctant quantifier can easily be replaced with a negated character class. That means the repetition has to be terminated by a single character or character class. Patterns such as the following, where the alternatives without reluctant quantifiers are more complicated, are therefore not subject to this rule:
[source,php]
----
/<!--.*?-->/
-/\*.*?\*/-
----