Conditional Returns on Newline

Conditional statements should always return on the next line

  • Identifier: conditional_returns_on_newline
  • Enabled by default: No
  • Supports autocorrection: No
  • Kind: style
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning
    if_only false

Non Triggering Examples

guard true else {
 return true
}
guard true,
 let x = true else {
 return true
}
if true else {
 return true
}
if true,
 let x = true else {
 return true
}
if textField.returnKeyType == .Next {
if true { // return }
guard something
else { return }

Triggering Examples

guard true else { return }
if true { return }
if true { break } else { return }
if true { break } else {       return }
if true { return "YES" } else { return "NO" }
guard condition else { XCTFail(); return }