Skip to content

Commit 4e0fb7c

Browse files
authored
chore: resolve SwiftFormat errors and warnings at the categories module (#3843)
* resolve swiftformat errors and warnings * resolve review comments * move braces back to same-line * fix argument spacing
1 parent ca6c65a commit 4e0fb7c

File tree

260 files changed

+1802
-1369
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+1802
-1369
lines changed

Amplify/Amplify.swift

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,37 @@ public class Amplify {
3333
// ease of testing.
3434

3535
/// - Tag: Amplify.Analytics
36-
public static internal(set) var Analytics = AnalyticsCategory()
36+
public internal(set) static var Analytics = AnalyticsCategory()
3737

3838
/// - Tag: Amplify.API
39-
public static internal(set) var API: APICategory = APICategory()
39+
public internal(set) static var API = APICategory()
4040

4141
/// - Tag: Amplify.Auth
42-
public static internal(set) var Auth = AuthCategory()
42+
public internal(set) static var Auth = AuthCategory()
4343

4444
/// - Tag: Amplify.DataStore
45-
public static internal(set) var DataStore = DataStoreCategory()
45+
public internal(set) static var DataStore = DataStoreCategory()
4646

4747
/// - Tag: Amplify.Geo
48-
public static internal(set) var Geo = GeoCategory()
48+
public internal(set) static var Geo = GeoCategory()
4949

5050
/// - Tag: Amplify.Hub
51-
public static internal(set) var Hub = HubCategory()
51+
public internal(set) static var Hub = HubCategory()
5252

5353
/// - Tag: Amplify.Notifications
54-
public static internal(set) var Notifications = NotificationsCategory()
54+
public internal(set) static var Notifications = NotificationsCategory()
5555

5656
/// - Tag: Amplify.Predictions
57-
public static internal(set) var Predictions = PredictionsCategory()
57+
public internal(set) static var Predictions = PredictionsCategory()
5858

5959
/// - Tag: Amplify.Storage
60-
public static internal(set) var Storage = StorageCategory()
60+
public internal(set) static var Storage = StorageCategory()
6161

6262
/// Special case category. We protect this with an AtomicValue because it is used by reset()
6363
/// methods during setup & teardown of tests
6464
///
6565
/// - Tag: Amplify.Logging
66-
public static internal(set) var Logging: LoggingCategory {
66+
public internal(set) static var Logging: LoggingCategory {
6767
get {
6868
loggingAtomic.get()
6969
}
@@ -73,13 +73,15 @@ public class Amplify {
7373
}
7474
private static let loggingAtomic = AtomicValue<LoggingCategory>(initialValue: LoggingCategory())
7575

76+
// swiftlint:disable cyclomatic_complexity
77+
7678
/// Adds `plugin` to the category
7779
///
7880
/// See: [Category.removePlugin(for:)](x-source-tag://Category.removePlugin)
7981
///
8082
/// - Parameter plugin: The plugin to add
8183
/// - Tag: Amplify.add_plugin
82-
public static func add<P: Plugin>(plugin: P) throws {
84+
public static func add(plugin: some Plugin) throws {
8385
log.debug("Adding plugin: \(plugin))")
8486
switch plugin {
8587
case let plugin as AnalyticsCategoryPlugin:
@@ -105,8 +107,11 @@ public class Amplify {
105107
default:
106108
throw PluginError.pluginConfigurationError(
107109
"Plugin category does not exist.",
108-
"Verify that the library version is correct and supports the plugin's category.")
110+
"Verify that the library version is correct and supports the plugin's category."
111+
)
109112
}
113+
114+
// swiftlint:enable cyclomatic_complexity
110115
}
111116
}
112117

Amplify/Categories/API/APICategory.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77

88
/// The API category provides a solution for making HTTP requests to REST and GraphQL endpoints.
9-
final public class APICategory: Category {
9+
public final class APICategory: Category {
1010
/// The category type for API
1111
public var categoryType: CategoryType {
1212
.api
@@ -57,8 +57,10 @@ final public class APICategory: Category {
5757
let key = plugin.key
5858
guard !key.isEmpty else {
5959
let pluginDescription = String(describing: plugin)
60-
let error = APIError.invalidConfiguration("Plugin \(pluginDescription) has an empty `key`.",
61-
"Set the `key` property for \(String(describing: plugin))")
60+
let error = APIError.invalidConfiguration(
61+
"Plugin \(pluginDescription) has an empty `key`.",
62+
"Set the `key` property for \(String(describing: plugin))"
63+
)
6264
throw error
6365
}
6466

@@ -81,8 +83,10 @@ final public class APICategory: Category {
8183
public func getPlugin(for key: PluginKey) throws -> APICategoryPlugin {
8284
guard let plugin = plugins[key] else {
8385
let keys = plugins.keys.joined(separator: ", ")
84-
let error = APIError.invalidConfiguration("No plugin has been added for '\(key)'.",
85-
"Either add a plugin for '\(key)', or use one of the known keys: \(keys)")
86+
let error = APIError.invalidConfiguration(
87+
"No plugin has been added for '\(key)'.",
88+
"Either add a plugin for '\(key)', or use one of the known keys: \(keys)"
89+
)
8690
throw error
8791
}
8892
return plugin

Amplify/Categories/API/ClientBehavior/APICategory+ReachabilityBehavior.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77

88
#if canImport(Combine)
9-
import Foundation
109
import Combine
10+
import Foundation
1111

1212
extension APICategory: APICategoryReachabilityBehavior {
1313
#if !os(watchOS)

Amplify/Categories/API/ClientBehavior/APICategoryBehavior.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
/// Behavior of the API category that clients will use
99
public typealias APICategoryBehavior =
10-
APICategoryRESTBehavior &
10+
APICategoryAuthProviderFactoryBehavior &
1111
APICategoryGraphQLBehavior &
1212
APICategoryInterceptorBehavior &
13-
APICategoryReachabilityBehavior &
14-
APICategoryAuthProviderFactoryBehavior
13+
APICategoryRESTBehavior &
14+
APICategoryReachabilityBehavior

Amplify/Categories/API/ClientBehavior/APICategoryGraphQLBehavior.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public protocol APICategoryGraphQLBehavior: AnyObject {
3535
/// - request: The GraphQL request containing apiName, document, variables, and responseType
3636
/// - valueListener: Invoked when the GraphQL subscription receives a new value from the service
3737
/// - completionListener: Invoked when the subscription has terminated
38-
/// - Returns: The AmplifyInProcessReportingOperation being enqueued
38+
/// - Returns: The AmplifyInProcessReportingOperation being enqueued
3939
func subscribe<R: Decodable>(
4040
request: GraphQLRequest<R>
4141
) -> AmplifyAsyncThrowingSequence<GraphQLSubscriptionEvent<R>>

Amplify/Categories/API/ClientBehavior/APICategoryReachabilityBehavior.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77

88
#if canImport(Combine)
9-
import Foundation
109
import Combine
10+
import Foundation
1111

1212
/// API Reachability Behavior
1313
public protocol APICategoryReachabilityBehavior {

Amplify/Categories/API/Operation/AmplifyOperation+APIPublishers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77

88
#if canImport(Combine)
9-
import Foundation
109
import Combine
10+
import Foundation
1111

1212
// MARK: - GraphQLSubscriptionOperation
1313

Amplify/Categories/API/Operation/NondeterminsticOperation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
98
import Combine
9+
1010
/**
1111
A non-deterministic operation offers multiple paths to accomplish its task.
1212
It attempts the next path if all preceding paths have failed with an error that allows for continuation.
@@ -62,7 +62,7 @@ final class NondeterminsticOperation<T> {
6262
self?.task = Task { [weak self] in
6363
do {
6464
if let self {
65-
promise(.success(try await self.run()))
65+
try await promise(.success(run()))
6666
} else {
6767
promise(.failure(NondeterminsticOperationError.cancelled))
6868
}

Amplify/Categories/API/Operation/RetryableGraphQLOperation.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
import Foundation
98
import Combine
9+
import Foundation
1010

1111

1212
// MARK: - RetryableGraphQLOperation
@@ -16,7 +16,7 @@ public final class RetryableGraphQLOperation<Payload: Decodable> {
1616
private let nondeterminsticOperation: NondeterminsticOperation<GraphQLTask<Payload>.Success>
1717

1818
public init(
19-
requestStream: AsyncStream<() async throws -> GraphQLTask<Payload>.Success>
19+
requestStream: AsyncStream < () async throws -> GraphQLTask<Payload>.Success>
2020
) {
2121
self.nondeterminsticOperation = NondeterminsticOperation(
2222
operations: requestStream,
@@ -80,7 +80,7 @@ public final class RetryableGraphQLSubscriptionOperation<Payload: Decodable> {
8080
private let nondeterminsticOperation: NondeterminsticOperation<AmplifyAsyncThrowingSequence<SubscriptionEvents>>
8181

8282
public init(
83-
requestStream: AsyncStream<() async throws -> AmplifyAsyncThrowingSequence<SubscriptionEvents>>
83+
requestStream: AsyncStream < () async throws -> AmplifyAsyncThrowingSequence < SubscriptionEvents>>
8484
) {
8585
self.nondeterminsticOperation = NondeterminsticOperation(operations: requestStream)
8686
}
@@ -91,15 +91,15 @@ public final class RetryableGraphQLSubscriptionOperation<Payload: Decodable> {
9191

9292
public func subscribe() -> AnyPublisher<SubscriptionEvents, APIError> {
9393
let subject = PassthroughSubject<SubscriptionEvents, APIError>()
94-
self.task = Task { await self.trySubscribe(subject) }
94+
task = Task { await self.trySubscribe(subject) }
9595
return subject.eraseToAnyPublisher()
9696
}
9797

9898
private func trySubscribe(_ subject: PassthroughSubject<SubscriptionEvents, APIError>) async {
9999
var apiError: APIError?
100100
do {
101101
try Task.checkCancellation()
102-
let sequence = try await self.nondeterminsticOperation.run()
102+
let sequence = try await nondeterminsticOperation.run()
103103
defer { sequence.cancel() }
104104
for try await event in sequence {
105105
try Task.checkCancellation()
@@ -122,13 +122,13 @@ public final class RetryableGraphQLSubscriptionOperation<Payload: Decodable> {
122122
}
123123

124124
public func cancel() {
125-
self.task?.cancel()
126-
self.nondeterminsticOperation.cancel()
125+
task?.cancel()
126+
nondeterminsticOperation.cancel()
127127
}
128128
}
129129

130-
extension AsyncSequence {
131-
fileprivate var asyncStream: AsyncStream<Self.Element> {
130+
private extension AsyncSequence {
131+
var asyncStream: AsyncStream<Self.Element> {
132132
AsyncStream { continuation in
133133
Task {
134134
var it = self.makeAsyncIterator()
@@ -145,11 +145,11 @@ extension AsyncSequence {
145145
}
146146
}
147147

148-
extension RetryableGraphQLSubscriptionOperation {
149-
public static var log: Logger {
148+
public extension RetryableGraphQLSubscriptionOperation {
149+
static var log: Logger {
150150
Amplify.Logging.logger(forCategory: CategoryType.api.displayName, forNamespace: String(describing: self))
151151
}
152-
public var log: Logger {
152+
var log: Logger {
153153
Self.log
154154
}
155155
}

Amplify/Categories/API/Request/GraphQLOperationRequest.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ public struct GraphQLOperationRequest<R: Decodable>: AmplifyOperationRequest {
3232
public let options: Options
3333

3434
/// Initializer for GraphQLOperationRequest
35-
public init(apiName: String?,
36-
operationType: GraphQLOperationType,
37-
document: String,
38-
variables: [String: Any]? = nil,
39-
responseType: R.Type,
40-
decodePath: String? = nil,
41-
authMode: AuthorizationMode? = nil,
42-
options: Options) {
35+
public init(
36+
apiName: String?,
37+
operationType: GraphQLOperationType,
38+
document: String,
39+
variables: [String: Any]? = nil,
40+
responseType: R.Type,
41+
decodePath: String? = nil,
42+
authMode: AuthorizationMode? = nil,
43+
options: Options
44+
) {
4345
self.apiName = apiName
4446
self.operationType = operationType
4547
self.document = document

0 commit comments

Comments
 (0)