rspec/rules/S131/scala/rule.adoc
2020-12-21 15:38:52 +01:00

23 lines
493 B
Plaintext

The requirement for a final `+case _+` clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken.
== Noncompliant Code Example
----
param match {
case 1 => doSomething
case 2 => doSomethingElse
}
----
== Compliant Solution
----
param match {
case 1 => doSomething
case 2 => doSomethingElse
case _ => throw new IllegalArgumentException(s"Unexpected param: $param")
}
----
include::../see.adoc[]