Skip to content

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

Closed

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

Activity

  1. added
    bug
    on Oct 31, 2025
  2. jshier commented on Nov 1, 2025

    @jshier
    ContributorAuthor

    This can be worked around, or perhaps fixed if you're okay with the style, by putting a newline after the #if.

    #if DEBUG
    
    case .b: print("b")
    #endif
  3. self-assigned this
    on Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions