nicklockwood / SwiftFormat

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

Bug with unusedArguments rule #1613

Closed mnazirov closed 5 months ago

mnazirov commented 5 months ago

Hi. I have noticed in my project that the function argument is replaced by the _ symbol even though the parameter is used in the function. After that, an error appears Cannot find 'filter' in scope

The problem goes away if you add the displayable parameter isFilter(with: ...) to the passed function.

Tested it on a version 0.53.0

func convert(
-   filter: Filter,
+  filter _: Filter,
    accounts: [Account],
    total: MulticurrencyTotal?,
    outgoingTotal: MulticurrencyTotal?
) -> History? {
    guard
        let firstParameter = incomingTotal?.currency,
        let secondParameter = outgoingTotal?.currency,
        isFilter(filter, accounts: accounts)
    else {
        return nil
    }
    return History(firstParameter, secondParameter)
}

func isFilter(_ filter: Filter, accounts: [Account]) -> Bool {
    ...
}
nicklockwood commented 5 months ago

@mnazirov fixed in 0.53.1