Skip to content

vertical_whitespace_between_cases false positive with #if but can't be disabled #6332

@jshier

Description

@jshier

New Issue Checklist

Bug Description

Using the vertical_whitespace_between_cases rule, it seems to get confused when wrapping cases in an #if check.

enum Limited {
  case a
  #if DEBUG
  case b
  #endif
}

let l = Limited.a

switch l {
  case .a: print("a")

  #if DEBUG
  case .b: print("b") // Vertical Whitespace Between Cases Violation: Include a single empty line between switch cases (vertical_whitespace_between_cases)
  #endif
}

Additionally, trying to disable the diagnostic with swiftlint:disable:this produces a "Superfluous Disable Command Violation" warning.

Environment

  • SwiftLint: 0.62.2
  • Xcode: Xcode 26.1 Build version 17B54
  • Installation method: CocoaPods

Metadata

Metadata

Assignees

Labels

bugUnexpected and reproducible misbehavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions