Skip to content

Commit a3d4210

Browse files
committed
Cleanup 'switch ()' -> 'switch true'
1 parent 6be8b23 commit a3d4210

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

Sources/AppBundle/GlobalObserver.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ class GlobalObserver {
6262
try await resetManipulatedWithMouseIfPossible()
6363
let mouseLocation = mouseLocation
6464
let clickedMonitor = mouseLocation.monitorApproximation
65-
switch () {
65+
switch true {
6666
// Detect clicks on desktop of different monitors
67-
case _ where clickedMonitor.activeWorkspace != focus.workspace:
67+
case clickedMonitor.activeWorkspace != focus.workspace:
6868
_ = try await runSession(.globalObserverLeftMouseUp, token) {
6969
clickedMonitor.activeWorkspace.focusWorkspace()
7070
}

Sources/AppBundle/command/impl/ListModesCommand.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ struct ListModesCommand: Command {
77

88
func run(_ env: CmdEnv, _ io: CmdIo) -> Bool {
99
let modes: [String] = args.current ? [activeMode ?? mainModeId] : config.modes.keys.sorted()
10-
return switch () {
11-
case _ where args.outputOnlyCount:
10+
return switch true {
11+
case args.outputOnlyCount:
1212
io.out("\(modes.count)")
13-
case _ where args.json:
13+
case args.json:
1414
JSONEncoder.aeroSpaceDefault.encodeToString(modes.map { ["mode-id": $0] }).map(io.out)
1515
?? io.err("Failed to encode JSON")
1616
default:

Sources/AppBundle/ui/TrayMenuModel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public class TrayMenuModel: ObservableObject {
2626
TrayMenuModel.shared.workspaces = Workspace.all.map {
2727
let apps = $0.allLeafWindowsRecursive.map { $0.app.name?.takeIf { !$0.isEmpty } }.filterNotNil().toSet()
2828
let dash = " - "
29-
let suffix = switch () {
30-
case _ where !apps.isEmpty: dash + apps.sorted().joinTruncating(separator: ", ", length: 25)
31-
case _ where $0.isVisible: dash + $0.workspaceMonitor.name
29+
let suffix = switch true {
30+
case !apps.isEmpty: dash + apps.sorted().joinTruncating(separator: ", ", length: 25)
31+
case $0.isVisible: dash + $0.workspaceMonitor.name
3232
default: ""
3333
}
3434
return WorkspaceViewModel(

Sources/AppBundle/util/AxUiElementMockEx.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ enum AxUiElementWindowType: String {
148148
case popup
149149

150150
static func new(isWindow: Bool, isDialog: () -> Bool) -> AxUiElementWindowType {
151-
switch () {
152-
case _ where !isWindow: .popup
153-
case _ where isDialog(): .dialog
151+
switch true {
152+
case !isWindow: .popup
153+
case isDialog(): .dialog
154154
default: .window
155155
}
156156
}

Sources/AppBundle/util/appBundleUtil.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ extension CGFloat {
128128
}
129129

130130
func coerceIn(_ range: ClosedRange<CGFloat>) -> CGFloat {
131-
switch () {
132-
case _ where self > range.upperBound: range.upperBound
133-
case _ where self < range.lowerBound: range.lowerBound
131+
switch true {
132+
case self > range.upperBound: range.upperBound
133+
case self < range.lowerBound: range.lowerBound
134134
default: self
135135
}
136136
}

Sources/Common/cmdArgs/impl/ResizeCmdArgs.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ private func parseDimension(arg: String, nextArgs: inout [String]) -> Parsed<Res
5151

5252
private func parseUnits(arg: String, nextArgs: inout [String]) -> Parsed<ResizeCmdArgs.Units> {
5353
if let number = UInt(arg.removePrefix("+").removePrefix("-")) {
54-
switch () {
55-
case _ where arg.starts(with: "+"): .success(.add(number))
56-
case _ where arg.starts(with: "-"): .success(.subtract(number))
54+
switch true {
55+
case arg.starts(with: "+"): .success(.add(number))
56+
case arg.starts(with: "-"): .success(.subtract(number))
5757
default: .success(.set(number))
5858
}
5959
} else {

Sources/Common/cmdArgs/splitArgs.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ extension [String] {
5656
let containsWhitespaces = $0.rangeOfCharacter(from: .whitespacesAndNewlines) != nil
5757
let containsSingleQuote = $0.contains("'")
5858
let containsDoubleQuote = $0.contains("\"")
59-
return switch () {
60-
case _ where containsDoubleQuote && !containsSingleQuote:
59+
return switch true {
60+
case containsDoubleQuote && !containsSingleQuote:
6161
$0.quoted(with: "'")
62-
case _ where containsSingleQuote && !containsDoubleQuote:
62+
case containsSingleQuote && !containsDoubleQuote:
6363
$0.quoted(with: "\"")
64-
case _ where containsSingleQuote && containsDoubleQuote:
64+
case containsSingleQuote && containsDoubleQuote:
6565
// Technically shouldn't be possible according to splitArgs
6666
$0.replacing("'", with: "\\'").replacing("\"", with: "\\\"").quoted(with: "\"")
67-
case _ where containsWhitespaces:
67+
case containsWhitespaces:
6868
$0.quoted(with: "'")
6969
default:
7070
$0

0 commit comments

Comments
 (0)