nicklockwood / SwiftFormat

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

False-positive on unusedArguments #1696

Closed romdevios closed 1 month ago

romdevios commented 1 month ago

Parameter in this code counts as unused because placed on the next lines after the same named parameter created.

func someFunction(with parameter: Int) -> Int {
    let parameter = max(
        200,
        parameter
    )
    return parameter
}

Formatted to and not compiling anymore:

func someFunction(with _: Int) -> Int {
    let parameter = max(
        200,
        parameter
    )
    return parameter
}
nicklockwood commented 1 month ago

@romdevios thanks for reporting this, I'll get it fixed. A workaround for now seems to be to put the expression all on one line:

let parameter = max(200, parameter)
nicklockwood commented 1 month ago

@romdevios fixed in 0.53.10