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

40 lines
667 B
Plaintext

:lookahead: java/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,java]
----
Pattern.compile("(?=a)b"); // Noncompliant, the same character can't be equal to 'a' and 'b' at the same time
----
==== Compliant solution
[source,java]
----
Pattern.compile("(?<=a)b");
Pattern.compile("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[]