Skip to content

Commit ba0ac8a

Browse files
DougGregorxedin
authored andcommitted
Remove yet more uses of switch expressions
1 parent 89c2854 commit ba0ac8a

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

Sources/SwiftRefactor/PackageManifest/AddTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ fileprivate extension TargetDescription.Dependency {
328328
case .target(name: let name),
329329
.byName(name: let name),
330330
.product(name: let name, package: _):
331-
name
331+
return name
332332
}
333333
}
334334
}

Sources/SwiftRefactor/PackageManifest/ManifestEditError.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ extension ManifestEditError: CustomStringConvertible {
2525
public var description: String {
2626
switch self {
2727
case .cannotFindPackage:
28-
"invalid manifest: unable to find 'Package' declaration"
28+
return "invalid manifest: unable to find 'Package' declaration"
2929
case .cannotFindTargets:
30-
"unable to find package targets in manifest"
30+
return "unable to find package targets in manifest"
3131
case .cannotFindTarget(targetName: let name):
32-
"unable to find target named '\(name)' in package"
32+
return "unable to find target named '\(name)' in package"
3333
case .cannotFindArrayLiteralArgument(argumentName: let name, node: _):
34-
"unable to find array literal for '\(name)' argument"
34+
return "unable to find array literal for '\(name)' argument"
3535
}
3636
}
3737
}

Sources/SwiftRefactor/PackageManifest/PackageDependency.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public enum PackageDependency: Sendable {
6868
extension PackageDependency: ManifestSyntaxRepresentable {
6969
func asSyntax() -> ExprSyntax {
7070
switch self {
71-
case .fileSystem(let filesystem): filesystem.asSyntax()
72-
case .sourceControl(let sourceControl): sourceControl.asSyntax()
73-
case .registry(let registry): registry.asSyntax()
71+
case .fileSystem(let filesystem): return filesystem.asSyntax()
72+
case .sourceControl(let sourceControl): return sourceControl.asSyntax()
73+
case .registry(let registry): return registry.asSyntax()
7474
}
7575
}
7676
}

Sources/SwiftRefactor/PackageManifest/ProductDescription.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ extension ProductDescription: ManifestSyntaxRepresentable {
4242
/// to check the precondition.
4343
private var functionName: String {
4444
switch type {
45-
case .executable: "executable"
46-
case .library(_): "library"
47-
case .macro: "macro"
48-
case .plugin: "plugin"
49-
case .snippet: "snippet"
50-
case .test: "test"
45+
case .executable: return "executable"
46+
case .library(_): return "library"
47+
case .macro: return "macro"
48+
case .plugin: return "plugin"
49+
case .snippet: return "snippet"
50+
case .test: return "test"
5151
}
5252
}
5353

Sources/SwiftRefactor/PackageManifest/TargetDescription.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ extension TargetDescription: ManifestSyntaxRepresentable {
7575
/// The function name in the package manifest.
7676
private var functionName: String {
7777
switch type {
78-
case .binary: "binaryTarget"
79-
case .executable: "executableTarget"
80-
case .library: "target"
81-
case .macro: "macro"
82-
case .plugin: "plugin"
83-
case .system: "systemLibrary"
84-
case .test: "testTarget"
78+
case .binary: return "binaryTarget"
79+
case .executable: return "executableTarget"
80+
case .library: return "target"
81+
case .macro: return "macro"
82+
case .plugin: return "plugin"
83+
case .system: return "systemLibrary"
84+
case .test: return "testTarget"
8585
}
8686
}
8787

0 commit comments

Comments
 (0)