rspec/rules/S5855/java/rule.adoc
2023-08-04 16:18:23 +02:00

42 lines
769 B
Plaintext

This rule raises an issue when multiple branches of a regex alternative match the same input.
== Why is this an issue?
include::../description.adoc[]
=== Code examples
==== Noncompliant code example
[source,java,diff-id=1,diff-type=noncompliant]
----
"[ab]|a" // Noncompliant: the "|a" is redundant because "[ab]" already matches "a"
".*|a" // Noncompliant: .* matches everything, so any other alternative is redundant
----
==== Compliant solution
[source,java,diff-id=1,diff-type=compliant]
----
"[ab]"
".*"
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove or rework this redundant alternative
=== Highlighting
The redundant alternative
endif::env-github,rspecator-view[]