rspec/rules/S3923/scala/rule.adoc

39 lines
861 B
Plaintext
Raw Normal View History

2021-01-27 13:42:22 +01:00
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.
2020-06-30 12:48:39 +02:00
== Noncompliant Code Example
----
if (b == 0) { // Noncompliant
doSomething
} else {
doSomething
}
i match { // Noncompliant
case 1 => doSomething
case 2 => doSomething
case 3 => doSomething
case _ => doSomething
}
----
== Exceptions
2021-01-27 13:42:22 +01:00
This rule does not apply to ``++if++`` chains without ``++else++``-s, or to ``++match++``-es without ``++case _++`` alternatives.
2020-06-30 12:48:39 +02:00
2021-02-02 15:02:10 +01:00
2020-06-30 12:48:39 +02:00
----
if (b == 0) {
doSomething
} else if (b == 1) {
doSomething
}
----
ifdef::env-github,rspecator-view[]
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]