rspec/rules/S6395/java/rule.adoc

30 lines
453 B
Plaintext
Raw Normal View History

== Why is this an issue?
include::../description.adoc[]
=== Noncompliant code example
[source,java]
----
"(?:number)\\d{2}"
----
=== Compliant solution
[source,java]
----
"number\\d{2}" // it is anyway required
"(?:number)?\\d{2}" // it is in fact optional
----
=== Exceptions
This rule does not report an issue if the non-capturing group is an alternation.
[source,java]
----
"(?:number|string)"
----
include::../implementation.adoc[]