Skip to content

Commit f5b2ef0

Browse files
committed
chore: swift lint
1 parent f10a1ce commit f5b2ef0

File tree

33 files changed

+511
-527
lines changed

33 files changed

+511
-527
lines changed

WireAPI/Sources/WireAPI/APIs/MLSAPI/MLSAPI.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ public protocol MLSAPI {
2424
/// Fetch the info of MLS support on the backend available from ``APIVersion`` v5.
2525

2626
func getBackendMLSPublicKeys() async throws -> BackendMLSPublicKeys
27-
27+
2828
/// Post a commit bundle.
2929
///
3030
/// - Parameter bundle: commit bundle to post
3131
/// - Returns: updates events generated by the commit
3232
///
3333
/// Available from ``APIVersion`` v5.
3434
///
35-
35+
3636
func postCommitBundle(_ bundle: CommitBundle) async throws -> [UpdateEvent]
3737

3838
}

WireAPI/Sources/WireAPI/APIs/MLSAPI/MLSAPIError.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public enum MLSAPIError: Error, Codable, Equatable {
3131
encoder.outputFormatting = .sortedKeys
3232
return String(decoding: try encoder.encode(self), as: UTF8.self)
3333
}
34-
34+
3535
/// Unsupported endpoint for API version
3636

3737
case unsupportedEndpointForAPIVersion
@@ -43,17 +43,17 @@ public enum MLSAPIError: Error, Codable, Equatable {
4343
/// Message was sent in an too old epoch
4444

4545
case mlsStaleMessage
46-
46+
4747
/// A proposal of type Add or Remove does not apply to the full list of clients for a user
48-
48+
4949
case mlsClientMismatch
50-
50+
5151
/// The commit is not referencing all pending proposals
52-
52+
5353
case mlsCommitMissingReferences
54-
54+
5555
/// Generic error for all non recoverable MLS error
56-
56+
5757
case mlsError(_ label: String, _ message: String)
5858

5959
}

WireAPI/Sources/WireAPI/APIs/MLSAPI/MLSAPIV0.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import Foundation
2020

21-
class MLSAPIV0: MLSAPI, VersionedAPI {
21+
class MLSAPIV0: MLSAPI, VersionedAPI {
2222

2323
// MARK: - Properties
2424

@@ -37,7 +37,7 @@ class MLSAPIV0: MLSAPI, VersionedAPI {
3737
func getBackendMLSPublicKeys() async throws -> BackendMLSPublicKeys {
3838
throw MLSAPIError.unsupportedEndpointForAPIVersion
3939
}
40-
40+
4141
func postCommitBundle(_ bundle: CommitBundle) async throws -> [UpdateEvent] {
4242
throw MLSAPIError.unsupportedEndpointForAPIVersion
4343
}

WireAPI/Sources/WireAPI/APIs/MLSAPI/MLSAPIV5.swift

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,39 @@ class MLSAPIV5: MLSAPIV4 {
4040
.failure(code: .badRequest, label: "mls-not-enabled", error: MLSAPIError.mlsNotEnabled)
4141
.parse(code: response.statusCode, data: data)
4242
}
43-
43+
4444
override func postCommitBundle(_ bundle: CommitBundle) async throws -> [UpdateEvent] {
4545
let request = try URLRequestBuilder(path: "\(pathPrefix)/mls/commit-bundles")
4646
.withMethod(.post)
4747
.withAcceptType(.json)
4848
.withBody(bundle.transportData(), contentType: .mls)
4949
.build()
50-
50+
5151
let (data, response) = try await apiService.executeRequest(
5252
request,
5353
requiringAccessToken: true
5454
)
55-
55+
5656
do {
5757
return try ResponseParser()
58-
.success(code: .created, type: CommitBundleResponseV5.self)
59-
.failure(code: .conflict, label: "mls-stale-message", error: MLSAPIError.mlsStaleMessage)
60-
.failure(code: .conflict, label: "mls-client-mismatch", error: MLSAPIError.mlsClientMismatch)
61-
.failure(code: .badRequest, label: "mls-commit-missing-references", error: MLSAPIError.mlsCommitMissingReferences)
62-
.failure(code: .conflict, decodableError: FailureResponse.self)
63-
.parse(code: response.statusCode, data: data)
58+
.success(code: .created, type: CommitBundleResponseV5.self)
59+
.failure(code: .conflict, label: "mls-stale-message", error: MLSAPIError.mlsStaleMessage)
60+
.failure(code: .conflict, label: "mls-client-mismatch", error: MLSAPIError.mlsClientMismatch)
61+
.failure(
62+
code: .badRequest,
63+
label: "mls-commit-missing-references",
64+
error: MLSAPIError.mlsCommitMissingReferences
65+
)
66+
.failure(code: .conflict, decodableError: FailureResponse.self)
67+
.parse(code: response.statusCode, data: data)
6468
} catch {
6569
if let failureResponse = error as? FailureResponse {
6670
throw MLSAPIError.mlsError(failureResponse.label, failureResponse.message)
6771
} else {
6872
throw error
6973
}
7074
}
71-
75+
7276
}
7377

7478
}
@@ -87,9 +91,9 @@ private struct CommitBundleResponseV5: Decodable, ToAPIModelConvertible {
8791

8892
let time: UTCTime?
8993
let events: [UpdateEventDecodingProxy]
90-
94+
9195
func toAPIModel() -> [UpdateEvent] {
92-
events.map({ $0.updateEvent })
96+
events.map(\.updateEvent)
9397
}
94-
98+
9599
}

WireAPI/Sources/WireAPI/Models/MLS/CommitBundle.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ public struct CommitBundle: Sendable, Equatable {
3131
self.commit = commit
3232
self.groupInfo = groupInfo
3333
}
34-
34+
3535
func transportData() -> Data {
3636
var data = Data()
3737
data.append(commit)
38-
38+
3939
if let welcome {
4040
data.append(welcome)
4141
}
42-
42+
4343
data.append(groupInfo)
44-
44+
4545
return data
4646
}
4747
}

WireAPI/Sources/WireAPI/Network/URLRequestBuilder/HTTPContentType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
enum HTTPContentType: String {
2020

2121
case json = "application/json"
22-
22+
2323
case mls = "message/mls"
2424

2525
}

WireAPI/Tests/WireAPITests/APIs/MLSAPI/MLSAPITests.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ final class MLSAPITests: XCTestCase {
103103
try await api.getBackendMLSPublicKeys()
104104
}
105105
}
106-
106+
107107
// MARK: - Send commit bundle
108-
108+
109109
func testPostCommitBundleRequest() async throws {
110110
// Given
111111
let apiVersions = APIVersion.v5.andNextVersions
@@ -116,10 +116,10 @@ final class MLSAPITests: XCTestCase {
116116
_ = try await sut.postCommitBundle(Scaffolding.commitBundle)
117117
}
118118
}
119-
119+
120120
func testPostCommitBundle_SuccessResponse_201_V5_And_Next_Versions() async throws {
121121
// Given
122-
try await withThrowingTaskGroup(of: Array<UpdateEvent>.self) { taskGroup in
122+
try await withThrowingTaskGroup(of: [UpdateEvent].self) { taskGroup in
123123
let testedVersions = APIVersion.v5.andNextVersions
124124

125125
for version in testedVersions {
@@ -130,7 +130,7 @@ final class MLSAPITests: XCTestCase {
130130

131131
taskGroup.addTask {
132132
// When
133-
return try await sut.postCommitBundle(Scaffolding.commitBundle)
133+
try await sut.postCommitBundle(Scaffolding.commitBundle)
134134
}
135135

136136
for try await value in taskGroup {
@@ -140,10 +140,10 @@ final class MLSAPITests: XCTestCase {
140140
}
141141
}
142142
}
143-
143+
144144
func testPostCommitBundle_SuccessResponseWithEvents_201_V5_And_Next_Versions() async throws {
145145
// Given
146-
try await withThrowingTaskGroup(of: Array<UpdateEvent>.self) { taskGroup in
146+
try await withThrowingTaskGroup(of: [UpdateEvent].self) { taskGroup in
147147
let testedVersions = APIVersion.v5.andNextVersions
148148

149149
for version in testedVersions {
@@ -154,7 +154,7 @@ final class MLSAPITests: XCTestCase {
154154

155155
taskGroup.addTask {
156156
// When
157-
return try await sut.postCommitBundle(Scaffolding.commitBundle)
157+
try await sut.postCommitBundle(Scaffolding.commitBundle)
158158
}
159159

160160
for try await value in taskGroup {
@@ -164,7 +164,7 @@ final class MLSAPITests: XCTestCase {
164164
}
165165
}
166166
}
167-
167+
168168
func testPostCommitBundle_givenV5AndErrorResponse() async throws {
169169
// Given
170170
let apiService = MockAPIServiceProtocol.withError(
@@ -194,15 +194,15 @@ private extension APIVersion {
194194
// MARK: Helpers
195195

196196
private enum Scaffolding {
197-
197+
198198
static let commitBundle = CommitBundle(
199199
welcome: nil,
200-
commit: "commit".data(using: .utf8)!,
201-
groupInfo: "groupinfo".data(using: .utf8)!
200+
commit: Data("commit".utf8),
201+
groupInfo: Data("groupinfo".utf8)
202202
)
203-
203+
204204
static let updateEvents = [
205-
UpdateEvent.unknown(eventType: "some event"),
205+
UpdateEvent.unknown(eventType: "some event")
206206
]
207-
207+
208208
}

WireDomain/Sources/WireDomain/Components/ClientSessionComponent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ public final class ClientSessionComponent {
584584
private lazy var addPermissionEventProcessor = ConversationAddPermissionEventProcessor(
585585
localStore: conversationLocalStore
586586
)
587-
587+
588588
private lazy var conversationEventProcessor = ConversationEventProcessor(
589589
accessUpdateEventProcessor: conversationAccessUpdateEventProcessor,
590590
createEventProcessor: conversationCreateEventProcessor,
@@ -604,7 +604,7 @@ public final class ClientSessionComponent {
604604
)
605605

606606
private lazy var updateEventProcessor: UpdateEventProcessor = {
607-
607+
608608
let featureConfigEventProcessor = FeatureConfigEventProcessor(
609609
updateEventProcessor: featureConfigUpdateEventProcessor
610610
)

WireDomain/Sources/WireDomain/Event Processing/ConversationEventProcessor/Protocols/ConversationEventProcessorProtocol.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818

1919
import WireAPI
2020

21-
/// Process conversation update events.
22-
2321
// sourcery: AutoMockable
22+
/// Process conversation update events.
2423
protocol ConversationEventProcessorProtocol {
2524

2625
/// Process a conversation update event.

WireDomain/Sources/WireDomain/Synchronization/MLSModelMappings.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
// along with this program. If not, see http://www.gnu.org/licenses/.
1717
//
1818

19-
import WireCoreCrypto
2019
import WireAPI
20+
import WireCoreCrypto
2121

2222
extension WireCoreCryptoUniffi.CommitBundle {
23-
23+
2424
func toAPIModel() -> WireAPI.CommitBundle {
2525
WireAPI.CommitBundle(
26-
welcome: self.welcome,
27-
commit: self.commit,
28-
groupInfo: self.groupInfo.payload
26+
welcome: welcome,
27+
commit: commit,
28+
groupInfo: groupInfo.payload
2929
)
3030
}
3131
}

WireDomain/Sources/WireDomain/Synchronization/MLSTransportImpl.swift

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,24 @@
1616
// along with this program. If not, see http://www.gnu.org/licenses/.
1717
//
1818

19-
import WireCoreCrypto
2019
import WireAPI
20+
import WireCoreCrypto
2121
import WireLogging
2222

2323
final class MLSTransportImpl: MlsTransport {
2424

2525
let mlsAPI: MLSAPI
2626
let conversationEventProcessor: ConversationEventProcessorProtocol
27-
27+
2828
init(mlsAPI: MLSAPI, conversationEventProcessor: ConversationEventProcessorProtocol) {
2929
self.mlsAPI = mlsAPI
3030
self.conversationEventProcessor = conversationEventProcessor
3131
}
32-
33-
func sendCommitBundle(commitBundle: WireCoreCryptoUniffi.CommitBundle) async -> WireCoreCryptoUniffi.MlsTransportResponse {
32+
33+
func sendCommitBundle(commitBundle: WireCoreCryptoUniffi.CommitBundle) async -> WireCoreCryptoUniffi
34+
.MlsTransportResponse {
3435
let events: [UpdateEvent]
35-
36+
3637
do {
3738
events = try await mlsAPI.postCommitBundle(commitBundle.toAPIModel())
3839
} catch let error as MLSAPIError {
@@ -44,22 +45,25 @@ final class MLSTransportImpl: MlsTransport {
4445
} catch {
4546
return .abort(reason: error.localizedDescription)
4647
}
47-
48+
4849
for event in events {
4950
do {
50-
if case .conversation(let conversationEvent) = event {
51+
if case let .conversation(conversationEvent) = event {
5152
try await conversationEventProcessor.processEvent(conversationEvent)
5253
}
5354
} catch {
54-
WireLogger.mls.error("Commit bundle was accepted by the backend so can't roll back after failing to process conversation event)")
55+
WireLogger.mls
56+
.error(
57+
"Commit bundle was accepted by the backend so can't roll back after failing to process conversation event)"
58+
)
5559
}
5660
}
57-
61+
5862
return .success
5963
}
60-
64+
6165
func sendMessage(mlsMessage: Data) async -> WireCoreCryptoUniffi.MlsTransportResponse {
62-
return .abort(reason: "not implemented")
66+
.abort(reason: "not implemented")
6367
}
64-
68+
6569
}

0 commit comments

Comments
 (0)