Pattern Matching Keywords

Combine multiple pattern matching bindings by moving keywords out of tuples

  • Identifier: pattern_matching_keywords
  • Enabled by default: No
  • Supports autocorrection: No
  • Kind: idiomatic
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning

Non Triggering Examples

switch foo {
    default: break
}
switch foo {
    case 1: break
}
switch foo {
    case bar: break
}
switch foo {
    case let (x, y): break
}
switch foo {
    case .foo(let x): break
}
switch foo {
    case let .foo(x, y): break
}
switch foo {
    case .foo(let x), .bar(let x): break
}
switch foo {
    case .foo(let x, var y): break
}
switch foo {
    case var (x, y): break
}
switch foo {
    case .foo(var x): break
}
switch foo {
    case var .foo(x, y): break
}
switch foo {
    case (y, let x, z): break
}

Triggering Examples

switch foo {
    case (let x,  let y): break
}
switch foo {
    case (let x,  let y, .foo): break
}
switch foo {
    case (let x,  let y, _): break
}
switch foo {
    case (let x,  let y, f()): break
}
switch foo {
    case (let x,  let y, s.f()): break
}
switch foo {
    case (let x,  let y, s.t): break
}
switch foo {
    case .foo(let x, let y): break
}
switch foo {
    case (.yamlParsing(let x), .yamlParsing(let y)): break
}
switch foo {
    case (var x,  var y): break
}
switch foo {
    case .foo(var x, var y): break
}
switch foo {
    case (.yamlParsing(var x), .yamlParsing(var y)): break
}