rspec/rules/S5850/python/rule.adoc

36 lines
367 B
Plaintext
Raw Normal View History

== Why is this an issue?
include::../description.adoc[]
=== Noncompliant code example
2022-02-04 17:28:24 +01:00
[source,python]
----
r"^a|b|c$"
----
=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,python]
----
r"^(?:a|b|c)$"
----
or
2022-02-04 17:28:24 +01:00
[source,python]
----
r"^a$|^b$|^c$"
----
or, if you do want the anchors to only apply to ``a`` and ``c`` respectively:
2022-02-04 17:28:24 +01:00
[source,python]
----
r"(?:^a)|b|(?:c$)"
----