Prefer if case over switch

Motivation:

There are quite a few `switch`es that cover just two cases. Explicitly state this via an `if case` + `else` structure.

Modifications:

Changes something like:

switch a {
case .b:
  return c
default:
  return d
}

to

if case .b = a {
  return c
} else {
  return d
}

Result:

This should prevent misinterpretation and thus potential bugs in the future.
This commit is contained in:
Bas Broek authored and Norman Maurer committed 2018-03-19 14:45:32 +01:00
1 parent 4c89a4e675
commit a095decbc2
11 files changed
+46 -69

No files matched your search

+1 -4
View File
@@ -155,11 +155,8 @@ public final class HTTPResponseDecoder: HTTPDecoder<HTTPClientResponsePart>, Cha
}
public func write(ctx: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise<Void>?) {
switch unwrapOutboundIn(data) {
case .head(let head):
if case .head(let head) = unwrapOutboundIn(data) {
methods.append(head.method)
default:
break
}
ctx.write(data, promise: promise)