Skip to content

Commit f215eb6

Browse files
committed
chore: swift lint
1 parent 5aac718 commit f215eb6

35 files changed

+468
-515
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: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,39 @@ import Foundation
2121
/// Errors originating from `MLSAPI`.
2222

2323
public enum MLSAPIError: Error, Codable, Equatable {
24-
24+
2525
public init?(from string: String) throws {
2626
self = try JSONDecoder().decode(MLSAPIError.self, from: Data(string.utf8))
2727
}
28-
28+
2929
public var encodedAsString: String {
3030
let encoder = JSONEncoder()
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
3838

3939
/// MLS is not configured on this backend
4040

4141
case mlsNotEnabled
42-
42+
4343
/// Message is was sent in an too old epoch
44-
44+
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: 18 additions & 14 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
}
@@ -84,12 +88,12 @@ private struct BackendMLSPublicKeysResponseV5: Decodable, ToAPIModelConvertible
8488
}
8589

8690
private struct CommitBundleResponseV5: Decodable, ToAPIModelConvertible {
87-
91+
8892
let time: UTCTimeMillis?
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 {
@@ -143,10 +143,10 @@ final class MLSAPITests: XCTestCase {
143143
}
144144
}
145145
}
146-
146+
147147
func testPostCommitBundle_SuccessResponseWithEvents_201_V5_And_Next_Versions() async throws {
148148
// Given
149-
try await withThrowingTaskGroup(of: Array<UpdateEvent>.self) { taskGroup in
149+
try await withThrowingTaskGroup(of: [UpdateEvent].self) { taskGroup in
150150
let testedVersions = APIVersion.v5.andNextVersions
151151

152152
for version in testedVersions {
@@ -157,7 +157,7 @@ final class MLSAPITests: XCTestCase {
157157

158158
taskGroup.addTask {
159159
// When
160-
return try await sut.postCommitBundle(Scaffolding.commitBundle)
160+
try await sut.postCommitBundle(Scaffolding.commitBundle)
161161
}
162162

163163
for try await value in taskGroup {
@@ -167,7 +167,7 @@ final class MLSAPITests: XCTestCase {
167167
}
168168
}
169169
}
170-
170+
171171
func testPostCommitBundle_givenV5AndErrorResponse() async throws {
172172
// Given
173173
let apiService = MockAPIServiceProtocol.withError(
@@ -197,15 +197,15 @@ private extension APIVersion {
197197
// MARK: Helpers
198198

199199
private enum Scaffolding {
200-
200+
201201
static let commitBundle = CommitBundle(
202202
welcome: nil,
203-
commit: "commit".data(using: .utf8)!,
204-
groupInfo: "groupinfo".data(using: .utf8)!
203+
commit: Data("commit".utf8),
204+
groupInfo: Data("groupinfo".utf8)
205205
)
206-
206+
207207
static let updateEvents = [
208-
UpdateEvent.unknown(eventType: "some event"),
208+
UpdateEvent.unknown(eventType: "some event")
209209
]
210-
210+
211211
}

WireDomain/Sources/WireDomain/Components/ClientSessionComponent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,8 @@ public final class ClientSessionComponent {
639639
service: mlsService,
640640
isMLSEnabled: isMLSEnabled
641641
)
642-
643-
internal lazy var mlsTransport = MLSTransport(
642+
643+
lazy var mlsTransport = MLSTransport(
644644
mlsAPI: mlsAPI,
645645
conversationEventProcessor: updateEventProcessor.conversationEventProcessor
646646
)

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/Providers/MLSTransportProvider.swift

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

1919
import WireCoreCrypto
2020

21-
/// An object that provides an instance of `MlsTransport`.
22-
2321
// sourcery: AutoMockable
22+
/// An object that provides an instance of `MlsTransport`.
2423
public protocol MLSTransportProvider {
2524
func provideMLSTransport() throws -> MlsTransport
2625
}

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/MLSTransport.swift

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,23 @@
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
class MLSTransport: MlsTransport {
23-
23+
2424
let mlsAPI: MLSAPI
2525
let conversationEventProcessor: ConversationEventProcessorProtocol
26-
26+
2727
init(mlsAPI: MLSAPI, conversationEventProcessor: ConversationEventProcessorProtocol) {
2828
self.mlsAPI = mlsAPI
2929
self.conversationEventProcessor = conversationEventProcessor
3030
}
31-
32-
func sendCommitBundle(commitBundle: WireCoreCryptoUniffi.CommitBundle) async -> WireCoreCryptoUniffi.MlsTransportResponse {
31+
32+
func sendCommitBundle(commitBundle: WireCoreCryptoUniffi.CommitBundle) async -> WireCoreCryptoUniffi
33+
.MlsTransportResponse {
3334
let events: [UpdateEvent]
34-
35+
3536
do {
3637
events = try await mlsAPI.postCommitBundle(commitBundle.toAPIModel())
3738
} catch let error as MLSAPIError {
@@ -43,22 +44,22 @@ class MLSTransport: MlsTransport {
4344
} catch {
4445
return .abort(reason: error.localizedDescription)
4546
}
46-
47+
4748
for event in events {
4849
do {
49-
if case .conversation(let conversationEvent) = event {
50+
if case let .conversation(conversationEvent) = event {
5051
try await conversationEventProcessor.processEvent(conversationEvent)
5152
}
5253
} catch {
5354
// We can't roll back now since the commit bundle has been accepted by the backend.
5455
}
5556
}
56-
57+
5758
return .success
5859
}
59-
60+
6061
func sendMessage(mlsMessage: Data) async -> WireCoreCryptoUniffi.MlsTransportResponse {
61-
return .abort(reason: "not implemented")
62+
.abort(reason: "not implemented")
6263
}
63-
64+
6465
}

0 commit comments

Comments
 (0)