nicklockwood / SwiftFormat

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

Add `redundantNestedConditional` rule #1620

Open nicklockwood opened 5 months ago

nicklockwood commented 5 months ago

Examples:

// redundant `if`
for x in y {
    if z {
        ...
    }
}

// simplified
for x in y where z {
    ...
}
// redundant nested `if`
if x {
    if y {
        ...
    }
}

// simplified
if x, y {
    ...
}
// redundant braces
if x {

} else {
    if y {
        ...
    }
}

// simplified
if x {
    ...
} else if y {

}