
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
53 lines
1.0 KiB
Plaintext
53 lines
1.0 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Having all branches in a ``++match++`` or ``++if++`` chain with the same implementation is an error. Either a copy-paste error was made and something different should be executed, or there shouldn't be a ``++match++``/``++if++`` chain at all.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,scala]
|
|
----
|
|
if (b == 0) { // Noncompliant
|
|
doSomething
|
|
} else {
|
|
doSomething
|
|
}
|
|
|
|
i match { // Noncompliant
|
|
case 1 => doSomething
|
|
case 2 => doSomething
|
|
case 3 => doSomething
|
|
case _ => doSomething
|
|
}
|
|
----
|
|
|
|
=== Exceptions
|
|
|
|
This rule does not apply to ``++if++`` chains without ``++else++``-s, or to ``++match++``-es without ``++case _++`` alternatives.
|
|
|
|
|
|
[source,scala]
|
|
----
|
|
if (b == 0) {
|
|
doSomething
|
|
} else if (b == 1) {
|
|
doSomething
|
|
}
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|