nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.62k stars 623 forks source link

Rule idea: collapseConditions #1728

Open nicklockwood opened 2 weeks ago

nicklockwood commented 2 weeks ago

Collapse nested if statements or sequential guard statements into a single statement:

if foo {
  if bar {

  }
}

guard foo else {
  return
}
guard bar else {
  return
}

becomes

if foo, bar {

}

guard foo, bar else {
  return
}