Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

vertical_whitespace_between_cases not triggering when using @unknown before default #3511

Open
2 tasks done
revolter opened this issue Feb 2, 2021 · 0 comments · May be fixed by #5843
Open
2 tasks done

vertical_whitespace_between_cases not triggering when using @unknown before default #3511

revolter opened this issue Feb 2, 2021 · 0 comments · May be fixed by #5843
Labels
bug Unexpected and reproducible misbehavior.

Comments

@revolter
Copy link
Contributor

revolter commented Feb 2, 2021

New Issue Checklist

Describe the bug

The vertical_whitespace_between_cases rule doesn't trigger when using @unknown before default in a switch.

Complete output when running SwiftLint, including the stack trace and command used
> ./swiftlint lint
Linting Swift files in current working directory
Linting 'Test2.swift' (1/2)
Linting 'Test1.swift' (2/2)
/Users/revolt/Downloads/swiftlint-unknown/Test1.swift:11:1: warning: Vertical Whitespace Between Cases Violation: Include a single empty line between switch cases. (vertical_whitespace_between_cases)
/Users/revolt/Downloads/swiftlint-unknown/Test2.swift:11:1: warning: Vertical Whitespace Between Cases Violation: Include a single empty line between switch cases. (vertical_whitespace_between_cases)
/Users/revolt/Downloads/swiftlint-unknown/Test2.swift:13:1: warning: Vertical Whitespace Between Cases Violation: Include a single empty line between switch cases. (vertical_whitespace_between_cases)
Done linting! Found 3 violations, 0 serious in 2 files.

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.43.0-rc.2
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? https://github.com/realm/SwiftLint/releases/download/0.43.0-rc.2/portable_swiftlint.zip
  • Paste your configuration file:
opt_in_rules:
    - vertical_whitespace_between_cases
  • Are you using nested configurations? No
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcodebuild -version)? Xcode 12.2 Build version 12B45b
  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
    to quickly test if your example is really demonstrating the issue. If your example is more
    complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.

Test1.swift:

enum Test {
    case first
    case second
}

let test = Test.first

switch test {
case .first:
    print("first")
case .second:
    print("second")
@unknown default:
    print("default")
}

Test2.swift (that works correctly):

enum Test {
    case first
    case second
}

let test = Test.first

switch test {
case .first:
    print("first")
case .second:
    print("second")
default:
    print("default")
}
@jpsim jpsim added the bug Unexpected and reproducible misbehavior. label Feb 24, 2021
jaredgrubb pushed a commit to jaredgrubb/SwiftLint that referenced this issue Oct 29, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants