Skip to content

Commit e398853

Browse files
committed
style: run swiftformat
1 parent 37b68d2 commit e398853

25 files changed

+303
-280
lines changed

Examples/Examples/Auth/GoogleSignIn.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Created by Guilherme Souza on 22/12/23.
66
//
77

8-
import SwiftUI
98
import AuthenticationServices
9+
import SwiftUI
1010

1111
struct GoogleSignIn: View {
1212
@Environment(\.webAuthenticationSession) var webAuthenticationSession

Examples/Examples/ExamplesApp.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@ struct ExamplesApp: App {
2121
let supabase = SupabaseClient(
2222
supabaseURL: Secrets.supabaseURL,
2323
supabaseKey: Secrets.supabaseAnonKey,
24-
options: .init(auth: .init(storage: KeychainLocalStorage(service: "supabase.gotrue.swift", accessGroup: nil)))
24+
options: .init(auth: .init(storage: KeychainLocalStorage(
25+
service: "supabase.gotrue.swift",
26+
accessGroup: nil
27+
)))
2528
)

Examples/UserManagement/Supabase.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ import Supabase
1111
let supabase = SupabaseClient(
1212
supabaseURL: URL(string: "https://PROJECT_ID.supabase.co")!,
1313
supabaseKey: "YOUR_SUPABASE_ANON_KEY",
14-
options: .init(auth: .init(storage: KeychainLocalStorage(service: "supabase.gotrue.swift", accessGroup: nil)))
14+
options: .init(auth: .init(storage: KeychainLocalStorage(
15+
service: "supabase.gotrue.swift",
16+
accessGroup: nil
17+
)))
1518
)

Package.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ var goTrueDependencies: [Target.Dependency] = [
1818
]
1919

2020
#if !os(Windows) && !os(Linux)
21-
dependencies += [
22-
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess", from: "4.2.2"),
23-
]
24-
goTrueDependencies += [
25-
.product(name: "KeychainAccess", package: "KeychainAccess"),
26-
]
21+
dependencies += [
22+
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess", from: "4.2.2"),
23+
]
24+
goTrueDependencies += [
25+
.product(name: "KeychainAccess", package: "KeychainAccess"),
26+
]
2727
#endif
2828

2929
let package = Package(
Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
import Foundation
22

3-
// Borrowed from the Vapor project, https://github.com/vapor/vapor/blob/main/Sources/Vapor/Utilities/Array%2BRandom.swift#L14
3+
// Borrowed from the Vapor project,
4+
// https://github.com/vapor/vapor/blob/main/Sources/Vapor/Utilities/Array%2BRandom.swift#L14
45
extension FixedWidthInteger {
5-
internal static func random() -> Self {
6-
return Self.random(in: .min ... .max)
7-
}
6+
static func random() -> Self {
7+
random(in: .min ... .max)
8+
}
89

9-
internal static func random<T>(using generator: inout T) -> Self
10-
where T : RandomNumberGenerator
11-
{
12-
return Self.random(in: .min ... .max, using: &generator)
13-
}
10+
static func random(using generator: inout some RandomNumberGenerator) -> Self {
11+
random(in: .min ... .max, using: &generator)
12+
}
1413
}
1514

1615
extension Array where Element: FixedWidthInteger {
17-
internal static func random(count: Int) -> [Element] {
18-
var array: [Element] = .init(repeating: 0, count: count)
19-
(0..<count).forEach { array[$0] = Element.random() }
20-
return array
21-
}
16+
static func random(count: Int) -> [Element] {
17+
var array: [Element] = .init(repeating: 0, count: count)
18+
(0 ..< count).forEach { array[$0] = Element.random() }
19+
return array
20+
}
2221

23-
internal static func random<T>(count: Int, using generator: inout T) -> [Element]
24-
where T: RandomNumberGenerator
25-
{
26-
var array: [Element] = .init(repeating: 0, count: count)
27-
(0..<count).forEach { array[$0] = Element.random(using: &generator) }
28-
return array
29-
}
22+
static func random(count: Int, using generator: inout some RandomNumberGenerator) -> [Element] {
23+
var array: [Element] = .init(repeating: 0, count: count)
24+
(0 ..< count).forEach { array[$0] = Element.random(using: &generator) }
25+
return array
26+
}
3027
}
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
#if !os(Windows) && !os(Linux)
2-
import Foundation
3-
@preconcurrency import KeychainAccess
2+
import Foundation
3+
@preconcurrency import KeychainAccess
44

5-
public struct KeychainLocalStorage: AuthLocalStorage {
6-
private let keychain: Keychain
5+
public struct KeychainLocalStorage: AuthLocalStorage {
6+
private let keychain: Keychain
77

8-
public init(service: String, accessGroup: String?) {
9-
if let accessGroup {
10-
keychain = Keychain(service: service, accessGroup: accessGroup)
11-
} else {
12-
keychain = Keychain(service: service)
8+
public init(service: String, accessGroup: String?) {
9+
if let accessGroup {
10+
keychain = Keychain(service: service, accessGroup: accessGroup)
11+
} else {
12+
keychain = Keychain(service: service)
13+
}
1314
}
14-
}
1515

16-
public func store(key: String, value: Data) throws {
17-
try keychain.set(value, key: key)
18-
}
16+
public func store(key: String, value: Data) throws {
17+
try keychain.set(value, key: key)
18+
}
1919

20-
public func retrieve(key: String) throws -> Data? {
21-
try keychain.getData(key)
22-
}
20+
public func retrieve(key: String) throws -> Data? {
21+
try keychain.getData(key)
22+
}
2323

24-
public func remove(key: String) throws {
25-
try keychain.remove(key)
24+
public func remove(key: String) throws {
25+
try keychain.remove(key)
26+
}
2627
}
27-
}
2828
#endif
Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,84 @@
11
#if os(Windows)
2-
import Foundation
3-
import WinSDK
2+
import Foundation
3+
import WinSDK
44

5-
enum WinCredLocalStorageError: Error {
6-
case windows(UInt32)
7-
case other(Int)
8-
}
5+
enum WinCredLocalStorageError: Error {
6+
case windows(UInt32)
7+
case other(Int)
8+
}
99

10-
public struct WinCredLocalStorage: AuthLocalStorage {
11-
private let service: String
10+
public struct WinCredLocalStorage: AuthLocalStorage {
11+
private let service: String
1212

13-
private let credentialType: DWORD
14-
private let credentialPersistence: DWORD
13+
private let credentialType: DWORD
14+
private let credentialPersistence: DWORD
1515

16-
public init(service: String) {
17-
self.service = service
18-
credentialType = DWORD(CRED_TYPE_GENERIC)
19-
credentialPersistence = DWORD(CRED_PERSIST_LOCAL_MACHINE)
20-
}
16+
public init(service: String) {
17+
self.service = service
18+
credentialType = DWORD(CRED_TYPE_GENERIC)
19+
credentialPersistence = DWORD(CRED_PERSIST_LOCAL_MACHINE)
20+
}
2121

22-
public func store(key: String, value: Data) throws {
23-
var valueData = value
22+
public func store(key: String, value: Data) throws {
23+
var valueData = value
2424

25-
var credential: CREDENTIALW = .init()
25+
var credential: CREDENTIALW = .init()
2626

27-
credential.Type = credentialType
28-
credential.Persist = credentialPersistence
29-
"\(service)\\\(key)".withCString(encodedAs: UTF16.self, { keyName in
30-
credential.TargetName = UnsafeMutablePointer(mutating: keyName)
31-
})
27+
credential.Type = credentialType
28+
credential.Persist = credentialPersistence
29+
"\(service)\\\(key)".withCString(encodedAs: UTF16.self) { keyName in
30+
credential.TargetName = UnsafeMutablePointer(mutating: keyName)
31+
}
3232

33-
withUnsafeMutableBytes(of: &valueData, { data in
34-
credential.CredentialBlobSize = DWORD(data.count)
35-
credential.CredentialBlob = data.baseAddress!.assumingMemoryBound(to: UInt8.self)
36-
})
33+
withUnsafeMutableBytes(of: &valueData) { data in
34+
credential.CredentialBlobSize = DWORD(data.count)
35+
credential.CredentialBlob = data.baseAddress!.assumingMemoryBound(to: UInt8.self)
36+
}
3737

38-
if !CredWriteW(&credential, 0) {
39-
let lastError = GetLastError()
40-
debugPrint("Unable to save password to credential vault, got error code \(lastError)")
38+
if !CredWriteW(&credential, 0) {
39+
let lastError = GetLastError()
40+
debugPrint("Unable to save password to credential vault, got error code \(lastError)")
4141

42-
throw WinCredLocalStorageError.windows(lastError)
42+
throw WinCredLocalStorageError.windows(lastError)
43+
}
4344
}
44-
}
4545

46-
public func retrieve(key: String) throws -> Data? {
47-
var credential: PCREDENTIALW?
46+
public func retrieve(key: String) throws -> Data? {
47+
var credential: PCREDENTIALW?
4848

49-
let targetName = "\(service)\\\(key))".withCString(encodedAs: UTF16.self, { $0 })
49+
let targetName = "\(service)\\\(key))".withCString(encodedAs: UTF16.self) { $0 }
5050

51-
if !CredReadW(targetName, credentialType, 0, &credential) {
52-
let lastError = GetLastError()
53-
debugPrint("Unable to find entry for key in credential vault, got error code \(lastError)")
51+
if !CredReadW(targetName, credentialType, 0, &credential) {
52+
let lastError = GetLastError()
53+
debugPrint("Unable to find entry for key in credential vault, got error code \(lastError)")
5454

55-
throw WinCredLocalStorageError.windows(lastError)
56-
}
55+
throw WinCredLocalStorageError.windows(lastError)
56+
}
5757

58-
guard let foundCredential = credential, let blob = foundCredential.pointee.CredentialBlob else {
59-
throw WinCredLocalStorageError.other(-1)
60-
}
58+
guard let foundCredential = credential,
59+
let blob = foundCredential.pointee.CredentialBlob
60+
else {
61+
throw WinCredLocalStorageError.other(-1)
62+
}
6163

62-
let blobSize = Int(foundCredential.pointee.CredentialBlobSize)
63-
let pointer = blob.withMemoryRebound(to: UInt8.self, capacity: blobSize, { $0 })
64-
let data = Data(bytes: pointer, count: blobSize)
64+
let blobSize = Int(foundCredential.pointee.CredentialBlobSize)
65+
let pointer = blob.withMemoryRebound(to: UInt8.self, capacity: blobSize) { $0 }
66+
let data = Data(bytes: pointer, count: blobSize)
6567

66-
CredFree(foundCredential)
68+
CredFree(foundCredential)
6769

68-
return data
69-
}
70+
return data
71+
}
7072

71-
public func remove(key: String) throws {
72-
let targetName = "\(service)\\\(key))".withCString(encodedAs: UTF16.self, { $0 })
73+
public func remove(key: String) throws {
74+
let targetName = "\(service)\\\(key))".withCString(encodedAs: UTF16.self) { $0 }
7375

74-
if !CredDeleteW(targetName, credentialType, 0) {
75-
let lastError = GetLastError()
76-
debugPrint("Unable to remove key from credential vault, got error code \(lastError)")
76+
if !CredDeleteW(targetName, credentialType, 0) {
77+
let lastError = GetLastError()
78+
debugPrint("Unable to remove key from credential vault, got error code \(lastError)")
7779

78-
throw WinCredLocalStorageError.windows(lastError)
80+
throw WinCredLocalStorageError.windows(lastError)
81+
}
7982
}
8083
}
81-
}
8284
#endif

Sources/Functions/FunctionsClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
@_spi(Internal) import _Helpers
33

44
#if canImport(FoundationNetworking)
5-
import FoundationNetworking
5+
import FoundationNetworking
66
#endif
77

88
let version = _Helpers.version

Sources/PostgREST/PostgrestClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
@_spi(Internal) import _Helpers
33

44
#if canImport(FoundationNetworking)
5-
import FoundationNetworking
5+
import FoundationNetworking
66
#endif
77

88
/// PostgREST client.

Sources/PostgREST/PostgrestFilterBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public class PostgrestFilterBuilder: PostgrestTransformBuilder {
239239

240240
public func match(_ query: [String: URLQueryRepresentable]) -> PostgrestFilterBuilder {
241241
mutableState.withValue { mutableState in
242-
query.forEach { key, value in
242+
for (key, value) in query {
243243
mutableState.request.query.append(URLQueryItem(
244244
name: key,
245245
value: "eq.\(value.queryValue)"

0 commit comments

Comments
 (0)