Skip to content

Commit 1a5e7c8

Browse files
Fix 5.8 compatibility (#118)
* Revert "Ran `swiftformat .` on main. No other changes. (#117)" This reverts commit 7590bea. * Relax minimum Swift version requirement to 5.8 We still use Swift 5.8 in our CI as a bootstrap compiler. * Exclude the Vendor directory from formatting * Ran `swiftformat .` for new 5.8 lang version and excluding Vendor
1 parent 7590bea commit 1a5e7c8

20 files changed

+473
-464
lines changed

.swiftformat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
# Insert explicit `self` where applicable.
1515
--self insert
1616

17-
--swiftversion 5.9
17+
--exclude Sources/Helpers/Vendor
18+
19+
--swiftversion 5.8

Sources/AsyncProcess/FileContentStream.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ private final class ReadIntoAsyncChannelHandler: ChannelDuplexHandler {
183183
private var shouldRead: Bool {
184184
switch self.state {
185185
case .idle:
186-
true
186+
return true
187187
case .error:
188-
false
188+
return false
189189
case .sending:
190-
false
190+
return false
191191
}
192192
}
193193

Sources/AsyncProcess/ProcessExecutor+Convenience.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ public struct OutputLoggingSettings: Sendable {
3737
func logMessage(line: String) -> Logger.Message {
3838
switch self.to {
3939
case .logMessage:
40-
"\(line)"
40+
return "\(line)"
4141
case .metadata(logMessage: let message, key: _):
42-
message
42+
return message
4343
}
4444
}
4545

4646
func metadata(stream: ProcessOutputStream, line: String) -> Logger.Metadata {
4747
switch self.to {
4848
case .logMessage:
49-
["stream": "\(stream.description)"]
49+
return ["stream": "\(stream.description)"]
5050
case .metadata(logMessage: _, let key):
51-
[key: "\(line)"]
51+
return [key: "\(line)"]
5252
}
5353
}
5454
}

Sources/AsyncProcess/ProcessExecutor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public struct ProcessOutputStream: Sendable & Hashable & CustomStringConvertible
3333
public var description: String {
3434
switch self.backing {
3535
case .standardOutput:
36-
"stdout"
36+
return "stdout"
3737
case .standardError:
38-
"stderr"
38+
return "stderr"
3939
}
4040
}
4141
}

Sources/GeneratorCLI/GeneratorCLI.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,12 @@ extension GeneratorCLI {
203203
"deprecated: Please explicity specify the subcommand to run. For example: $ swift-sdk-generator make-linux-sdk"
204204
)
205205
}
206-
let linuxDistributionDefaultVersion = switch self.linuxDistributionName {
206+
let linuxDistributionDefaultVersion: String
207+
switch self.linuxDistributionName {
207208
case .rhel:
208-
"ubi9"
209+
linuxDistributionDefaultVersion = "ubi9"
209210
case .ubuntu:
210-
"22.04"
211+
linuxDistributionDefaultVersion = "22.04"
211212
}
212213
let linuxDistributionVersion = self.linuxDistributionVersion ?? linuxDistributionDefaultVersion
213214
let linuxDistribution = try LinuxDistribution(name: linuxDistributionName, version: linuxDistributionVersion)

Sources/GeneratorEngine/Cache/SQLite.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ public final class SQLite {
135135
var pathString: String {
136136
switch self {
137137
case let .path(path):
138-
path.string
138+
return path.string
139139
case .memory:
140-
":memory:"
140+
return ":memory:"
141141
case .temporary:
142-
""
142+
return ""
143143
}
144144
}
145145
}

Sources/GeneratorEngine/FileSystem/FileSystem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ enum FileSystemError: Error {
2828
extension Error {
2929
func attach(path: FilePath) -> any Error {
3030
if let error = self as? Errno {
31-
FileSystemError.systemError(path, error)
31+
return FileSystemError.systemError(path, error)
3232
} else {
33-
self
33+
return self
3434
}
3535
}
3636
}

Sources/GeneratorEngine/FileSystem/OpenReadableFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public struct OpenReadableFile {
2525
func read() async throws -> ReadableFileStream {
2626
switch self.fileHandle {
2727
case let .local(fileDescriptor):
28-
ReadableFileStream.local(.init(fileDescriptor: fileDescriptor, readChunkSize: self.readChunkSize))
28+
return ReadableFileStream.local(.init(fileDescriptor: fileDescriptor, readChunkSize: self.readChunkSize))
2929
case let .virtual(array):
30-
ReadableFileStream.virtual(.init(bytes: array))
30+
return ReadableFileStream.virtual(.init(bytes: array))
3131
}
3232
}
3333

Sources/GeneratorEngine/FileSystem/ReadableFileStream.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ public enum ReadableFileStream: AsyncSequence {
2525
public func next() async throws -> [UInt8]? {
2626
switch self {
2727
case let .local(local):
28-
try await local.next()
28+
return try await local.next()
2929
case let .virtual(virtual):
30-
try await virtual.next()
30+
return try await virtual.next()
3131
}
3232
}
3333
}
3434

3535
public func makeAsyncIterator() -> Iterator {
3636
switch self {
3737
case let .local(local):
38-
.local(local.makeAsyncIterator())
38+
return .local(local.makeAsyncIterator())
3939
case let .virtual(virtual):
40-
.virtual(virtual.makeAsyncIterator())
40+
return .virtual(virtual.makeAsyncIterator())
4141
}
4242
}
4343
}

0 commit comments

Comments
 (0)