Skip to content

Commit b9a3fac

Browse files
Switch to Apple's swift-format tool
1 parent b1d3dea commit b9a3fac

24 files changed

+301
-161
lines changed

.swift-format

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"indentation": {
3+
"spaces": 4
4+
}
5+
}

Fyreplace.xcodeproj/project.pbxproj

+2
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
4DE785842C88EF8C000EC4E5 /* RequestIdMiddleware.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestIdMiddleware.swift; sourceTree = "<group>"; };
168168
4DE785872C88F392000EC4E5 /* HTTPField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPField.swift; sourceTree = "<group>"; };
169169
4DE785942C8B17AE000EC4E5 /* SubmitOrCancel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubmitOrCancel.swift; sourceTree = "<group>"; };
170+
4DF3737F2C99C23D0008AB04 /* .swift-format */ = {isa = PBXFileReference; explicitFileType = text.json; path = ".swift-format"; sourceTree = "<group>"; };
170171
4DFB906F2C5908DE00D4DABF /* LoginScreenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginScreenTests.swift; sourceTree = "<group>"; };
171172
4DFB90752C59173C00D4DABF /* RegisterScreenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterScreenTests.swift; sourceTree = "<group>"; };
172173
/* End PBXFileReference section */
@@ -273,6 +274,7 @@
273274
4D54C93C2BF26090001DE071 /* FyreplaceTests */,
274275
4D54C9462BF26090001DE071 /* FyreplaceUITests */,
275276
4D54C9632BF28695001DE071 /* .gitignore */,
277+
4DF3737F2C99C23D0008AB04 /* .swift-format */,
276278
4D0DDC292C18A467006CD503 /* .xcode-version */,
277279
4D6641DB2C5B963500BE3D07 /* .ios-test-version */,
278280
4DCEF8652C452EBA00F53085 /* .env-example */,

Fyreplace/Config/Config.swift

+7-5
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ struct Config {
9393
return Client(
9494
serverURL: url(for: environment),
9595
configuration: .init(dateTranscoder: .iso8601WithFractionalSeconds),
96-
transport: URLSessionTransport(configuration: .init(session: .init(configuration: configuration))),
96+
transport: URLSessionTransport(
97+
configuration: .init(session: .init(configuration: configuration))
98+
),
9799
middlewares: [RequestIdMiddleware(), AuthenticationMiddleware()]
98100
)
99101
}
@@ -109,17 +111,17 @@ struct Config {
109111
}
110112
}
111113

112-
private extension [String: Any] {
113-
func string(_ key: String) -> String? {
114+
extension [String: Any] {
115+
fileprivate func string(_ key: String) -> String? {
114116
return self[key] as? String
115117
}
116118

117-
func url(_ key: String) -> URL? {
119+
fileprivate func url(_ key: String) -> URL? {
118120
guard let s = string(key) else { return nil }
119121
return .init(string: s)
120122
}
121123

122-
func dictionary(_ key: String) -> [String: Any]? {
124+
fileprivate func dictionary(_ key: String) -> [String: Any]? {
123125
return self[key] as? [String: Any]
124126
}
125127
}

Fyreplace/Data/Keychain.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ struct Keychain {
2323
info[kSecReturnData] = true
2424
var itemReference: CFTypeRef?
2525
guard SecItemCopyMatching(info as CFDictionary, &itemReference) == errSecSuccess,
26-
let data = itemReference as? Data,
27-
let value = String(data: data, encoding: .utf8)
26+
let data = itemReference as? Data,
27+
let value = String(data: data, encoding: .utf8)
2828
else { return "" }
2929
return value
3030
}
@@ -33,8 +33,9 @@ struct Keychain {
3333
func set(_ value: String) -> Bool {
3434
guard !value.isEmpty else { return delete() }
3535
let data = value.data(using: .utf8)
36+
let attributes = [kSecValueData: data] as CFDictionary
3637

37-
if SecItemUpdate(query as CFDictionary, [kSecValueData: data] as CFDictionary) == errSecSuccess {
38+
if SecItemUpdate(query as CFDictionary, attributes) == errSecSuccess {
3839
return true
3940
} else {
4041
var info = query

Fyreplace/Data/Tokens.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func scheduleTokenRefresh() {
3131

3232
func refreshToken(using api: APIProtocol) async -> String? {
3333
guard let response = try? await api.getNewToken().ok,
34-
let newToken = try? await String(collecting: response.body.plainText, upTo: 1024)
34+
let newToken = try? await String(collecting: response.body.plainText, upTo: 1024)
3535
else { return nil }
3636
return newToken
3737
}

Fyreplace/Extensions/Array+RawRepresentable.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ extension Array: RawRepresentable where Element: Codable {
44
public init?(rawValue: String) {
55
self.init()
66
guard let data = rawValue.data(using: .utf8),
7-
let result = try? JSONDecoder().decode([Element].self, from: data)
7+
let result = try? JSONDecoder().decode([Element].self, from: data)
88
else { return nil }
99
result.forEach { append($0) }
1010
}
1111

1212
public var rawValue: String {
1313
guard let data = try? JSONEncoder().encode(self),
14-
let value = String(data: data, encoding: .utf8)
14+
let value = String(data: data, encoding: .utf8)
1515
else { return "[]" }
1616
return value
1717
}

0 commit comments

Comments
 (0)