SwiftLint
SwiftLint copied to clipboard
`vertical_whitespace_between_cases` does not play nicely with `#if` guards
Describe the bug
vertical_whitespace_between_cases does not play nicely with #if guards, unexpectedly inserts an extra newline inside the guard.
Environment
disabled_rules:
- switch_case_alignment
opt_in_rules:
- vertical_whitespace_between_cases
Command
$ swiftlint --config rules.yml test.swift --fix
Correcting Swift files at paths test.swift
Correcting 'test.swift' (1/1)
test.swift:10:15 Corrected Vertical Whitespace Between Cases
Done inspecting 1 file for auto-correction!
Input (expected to be unchanged)
enum MyEnum {
case one
case two
}
let value = MyEnum.one
switch value {
case .one:
print("one")
#if arch(arm64)
case .two:
print("two")
#endif
}
Output (unexpected)
enum MyEnum {
case one
case two
}
let value = MyEnum.one
switch value {
case .one:
print("one")
#if arch(arm64)
case .two:
print("two")
#endif
}
:) would like to see a fix for this too. We have many #if's in our code that doesn't look nice currently with the rule.