rspec/rules/S6002/python/rule.adoc
2023-08-04 16:12:40 +02:00

40 lines
621 B
Plaintext

:lookahead: python/lookahead.adoc
This rule raises an issue when a regex lookahead contradicts the rest of the regex.
== Why is this an issue?
include::../description.adoc[]
=== Code examples
==== Noncompliant code example
[source,python]
----
r"(?=a)b" # Noncompliant, the same character can't be equal to 'a' and 'b' at the same time
----
==== Compliant solution
[source,python]
----
r"(?<=a)b"
r"a(?=b)"
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
endif::env-github,rspecator-view[]