SwiftFormat
SwiftFormat copied to clipboard
A parameter is incorrectly ignored
The following snippet causes SwiftFormat to break the code:
func urlTestContains(path: String, strict _: Bool = true) -> Bool {
let path = if path.hasSuffix("/") { path } else { "\(path)/" }
return false
}
It does not detect that the path variable is used, and it will insert_ to the function signature.
I am sorry I could not describe the issue any better and could not verify if it was previously reported. Please have a look.
I am using swiftformat version 0.53.8.
Thank you.
Should be fixed by https://github.com/nicklockwood/SwiftFormat/pull/1687
@RussBaz fix landed in 0.53.9
Hi again. It seems like this issue has resurfaced for me. I am using 0.54.3. Can you check this?
I can't reproduce this issue with the func urlTestContains sample code above, can you share new sample code that demonstrates the problem?
This seems to reproduce my problem:
enum Sample {
func invite(lang: String, randomValue: Int) -> String {
let flag: String? = if randomValue > 0 { "hello" } else { nil }
let lang = if let flag { flag } else { lang }
return lang
}
}
lang will be incorrectly replaced with lang _ in the function signature.
Thanks for the sample code, here's a fix: https://github.com/nicklockwood/SwiftFormat/pull/1815