Unused Control Flow Label

Unused control flow label should be removed

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

Non Triggering Examples

loop: while true { break loop }
loop: while true { continue loop }
loop:
    while true { break loop }
while true { break }
loop: for x in array { break loop }
label: switch number {
case 1: print("1")
case 2: print("2")
default: break label
}
loop: repeat {
    if x == 10 {
        break loop
    }
} while true

Triggering Examples

loop: while true { break }
loop: while true { break loop1 }
loop: while true { break outerLoop }
loop: for x in array { break }
label: switch number {
case 1: print("1")
case 2: print("2")
default: break
}
loop: repeat {
    if x == 10 {
        break
    }
} while true