2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2022-02-02 16:59:48 +01:00
|
|
|
include::../description.adoc[]
|
2022-03-24 17:23:48 +01:00
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2022-03-24 17:23:48 +01:00
|
|
|
|
|
|
|
[source,python]
|
|
|
|
----
|
|
|
|
r"(?:number)\d{2}"
|
|
|
|
----
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2022-03-24 17:23:48 +01:00
|
|
|
|
|
|
|
[source,python]
|
|
|
|
----
|
|
|
|
r"number\d{2}"
|
|
|
|
r"(?:number)?\d{2}"
|
|
|
|
----
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Exceptions
|
2022-03-24 17:23:48 +01:00
|
|
|
|
|
|
|
This rule does not report an issue if the non-capturing group is an alternation.
|
|
|
|
|
|
|
|
[source,python]
|
|
|
|
----
|
|
|
|
r"(?:number|string)"
|
|
|
|
----
|
|
|
|
|
|
|
|
include::../implementation.adoc[]
|