How to column-align conditions inn if and guard statements in Xcode

Viewed 234

Google Swift Style Guide suggest if we use chained if let or guard let, then every let should have the same indentation. If I use CMD + I in Xcode to indent the lets are not aligned. How to change the Xcode config to column-aligns conditions in guard and if statements? How to add such rule to Swift-Lint?

Default alignment in Xcode:

if let value = aValueReturnedByAVeryLongOptionalThing(),
    let value2 = aDifferentValueReturnedByAVeryLongOptionalThing() {
  doSomething()
}

guard let value = aValueReturnedByAVeryLongOptionalThing(),
    let value2 = aDifferentValueReturnedByAVeryLongOptionalThing() else {
  doSomething()
}

Desired alignment:

if let value = aValueReturnedByAVeryLongOptionalThing(),
   let value2 = aDifferentValueReturnedByAVeryLongOptionalThing() {
  doSomething()
}

guard let value = aValueReturnedByAVeryLongOptionalThing(),
      let value2 = aDifferentValueReturnedByAVeryLongOptionalThing() else {
  doSomething()
}

Source section : Control Flow Statements

0 Answers
Related