Skip to content

Commit

Permalink
resolve swiftformat errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
phantumcode committed Sep 3, 2024
1 parent ca6c65a commit a6a31f3
Show file tree
Hide file tree
Showing 241 changed files with 878 additions and 746 deletions.
22 changes: 11 additions & 11 deletions Amplify/Amplify.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,37 @@ public class Amplify {
// ease of testing.

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

/// - Tag: Amplify.API
public static internal(set) var API: APICategory = APICategory()
public internal(set) static var API: APICategory = .init()

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

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

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

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

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

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

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

/// Special case category. We protect this with an AtomicValue because it is used by reset()
/// methods during setup & teardown of tests
///
/// - Tag: Amplify.Logging
public static internal(set) var Logging: LoggingCategory {
public internal(set) static var Logging: LoggingCategory {
get {
loggingAtomic.get()
}
Expand All @@ -79,7 +79,7 @@ public class Amplify {
///
/// - Parameter plugin: The plugin to add
/// - Tag: Amplify.add_plugin
public static func add<P: Plugin>(plugin: P) throws {
public static func add(plugin: some Plugin) throws {

Check warning on line 82 in Amplify/Amplify.swift

View workflow job for this annotation

GitHub Actions / run-swiftlint

Function should have complexity 10 or less; currently complexity is 11 (cyclomatic_complexity)
log.debug("Adding plugin: \(plugin))")
switch plugin {
case let plugin as AnalyticsCategoryPlugin:
Expand Down
2 changes: 1 addition & 1 deletion Amplify/Categories/API/APICategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

/// The API category provides a solution for making HTTP requests to REST and GraphQL endpoints.
final public class APICategory: Category {
public final class APICategory: Category {
/// The category type for API
public var categoryType: CategoryType {
.api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//

#if canImport(Combine)
import Foundation
import Combine
import Foundation

extension APICategory: APICategoryReachabilityBehavior {
#if !os(watchOS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

/// Behavior of the API category that clients will use
public typealias APICategoryBehavior =
APICategoryRESTBehavior &
APICategoryAuthProviderFactoryBehavior &
APICategoryGraphQLBehavior &
APICategoryInterceptorBehavior &
APICategoryReachabilityBehavior &
APICategoryAuthProviderFactoryBehavior
APICategoryRESTBehavior &
APICategoryReachabilityBehavior
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public protocol APICategoryGraphQLBehavior: AnyObject {
/// - request: The GraphQL request containing apiName, document, variables, and responseType
/// - valueListener: Invoked when the GraphQL subscription receives a new value from the service
/// - completionListener: Invoked when the subscription has terminated
/// - Returns: The AmplifyInProcessReportingOperation being enqueued
/// - Returns: The AmplifyInProcessReportingOperation being enqueued
func subscribe<R: Decodable>(
request: GraphQLRequest<R>
) -> AmplifyAsyncThrowingSequence<GraphQLSubscriptionEvent<R>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//

#if canImport(Combine)
import Foundation
import Combine
import Foundation

/// API Reachability Behavior
public protocol APICategoryReachabilityBehavior {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//

#if canImport(Combine)
import Foundation
import Combine
import Foundation

// MARK: - GraphQLSubscriptionOperation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//


import Combine

/**
A non-deterministic operation offers multiple paths to accomplish its task.
It attempts the next path if all preceding paths have failed with an error that allows for continuation.
Expand Down Expand Up @@ -62,7 +62,7 @@ final class NondeterminsticOperation<T> {
self?.task = Task { [weak self] in
do {
if let self {
promise(.success(try await self.run()))
try await promise(.success(run()))
} else {
promise(.failure(NondeterminsticOperationError.cancelled))
}
Expand Down
24 changes: 12 additions & 12 deletions Amplify/Categories/API/Operation/RetryableGraphQLOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//

import Foundation
import Combine
import Foundation


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

public init(
requestStream: AsyncStream<() async throws -> GraphQLTask<Payload>.Success>
requestStream: AsyncStream < () async throws -> GraphQLTask<Payload>.Success>
) {
self.nondeterminsticOperation = NondeterminsticOperation(
operations: requestStream,
Expand Down Expand Up @@ -80,7 +80,7 @@ public final class RetryableGraphQLSubscriptionOperation<Payload: Decodable> {
private let nondeterminsticOperation: NondeterminsticOperation<AmplifyAsyncThrowingSequence<SubscriptionEvents>>

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

public func subscribe() -> AnyPublisher<SubscriptionEvents, APIError> {
let subject = PassthroughSubject<SubscriptionEvents, APIError>()
self.task = Task { await self.trySubscribe(subject) }
task = Task { await self.trySubscribe(subject) }
return subject.eraseToAnyPublisher()
}

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

public func cancel() {
self.task?.cancel()
self.nondeterminsticOperation.cancel()
task?.cancel()
nondeterminsticOperation.cancel()
}
}

extension AsyncSequence {
fileprivate var asyncStream: AsyncStream<Self.Element> {
private extension AsyncSequence {
var asyncStream: AsyncStream<Self.Element> {
AsyncStream { continuation in
Task {
var it = self.makeAsyncIterator()
Expand All @@ -145,11 +145,11 @@ extension AsyncSequence {
}
}

extension RetryableGraphQLSubscriptionOperation {
public static var log: Logger {
public extension RetryableGraphQLSubscriptionOperation {
static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.api.displayName, forNamespace: String(describing: self))
}
public var log: Logger {
var log: Logger {
Self.log
}
}
3 changes: 2 additions & 1 deletion Amplify/Categories/API/Request/GraphQLOperationRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public struct GraphQLOperationRequest<R: Decodable>: AmplifyOperationRequest {
responseType: R.Type,
decodePath: String? = nil,
authMode: AuthorizationMode? = nil,
options: Options) {
options: Options)
{
self.apiName = apiName
self.operationType = operationType
self.document = document
Expand Down
3 changes: 2 additions & 1 deletion Amplify/Categories/API/Request/GraphQLRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public struct GraphQLRequest<R: Decodable> {
responseType: R.Type,
decodePath: String? = nil,
authMode: AuthorizationMode? = nil,
options: GraphQLRequest<R>.Options? = nil) {
options: GraphQLRequest<R>.Options? = nil)
{
self.apiName = apiName
self.document = document
self.variables = variables
Expand Down
3 changes: 2 additions & 1 deletion Amplify/Categories/API/Request/RESTOperationRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public struct RESTOperationRequest: AmplifyOperationRequest {
headers: [String: String]? = nil,
queryParameters: [String: String]? = nil,
body: Data? = nil,
options: Options) {
options: Options)
{
self.apiName = apiName
self.operationType = operationType
self.path = path
Expand Down
3 changes: 2 additions & 1 deletion Amplify/Categories/API/Request/RESTRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class RESTRequest {
path: String? = nil,
headers: [String: String]? = nil,
queryParameters: [String: String]? = nil,
body: Data? = nil) {
body: Data? = nil)
{
let inputHeaders = headers ?? [:]
self.headers = inputHeaders.merging(
["Cache-Control": "no-store"],
Expand Down
7 changes: 4 additions & 3 deletions Amplify/Categories/API/Response/GraphQLError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ public struct GraphQLError: Decodable {
public init(message: String,
locations: [Location]? = nil,
path: [JSONValue]? = nil,
extensions: [String: JSONValue]? = nil) {
extensions: [String: JSONValue]? = nil)
{
self.message = message
self.locations = locations
self.path = path
self.extensions = extensions
}
}

extension GraphQLError {
public extension GraphQLError {

/// Both `line` and `column` are positive numbers describing the beginning of an associated syntax element
public struct Location: Decodable {
struct Location: Decodable {

/// The line describing the associated syntax element
public let line: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ extension AnalyticsCategory: AnalyticsCategoryBehavior {
}

/// Methods that wrap `AnalyticsCategoryBehavior` to provides additional useful calling patterns
extension AnalyticsCategory {
public extension AnalyticsCategory {

/// Registered global properties can be unregistered though this method. In case no keys are provided, *all*
/// registered global properties will be unregistered. Duplicate keys will be ignored. This method can be called
/// from `Amplify.Analytics` and is a wrapper for `unregisterGlobalProperties(_ keys: Set<String>? = nil)`
///
/// - Parameter keys: one or more of property names to unregister
public func unregisterGlobalProperties(_ keys: String...) {
func unregisterGlobalProperties(_ keys: String...) {
plugin.unregisterGlobalProperties(keys.isEmpty ? nil : Set<String>(keys))
}

Expand All @@ -56,7 +56,7 @@ extension AnalyticsCategory {
/// from `Amplify.Analytics` and is a wrapper for `unregisterGlobalProperties(_ keys: Set<String>? = nil)`
///
/// - Parameter keys: an array of property names to unregister
public func unregisterGlobalProperties(_ keys: [String]) {
func unregisterGlobalProperties(_ keys: [String]) {
plugin.unregisterGlobalProperties(keys.isEmpty ? nil : Set(keys))
}
}
2 changes: 1 addition & 1 deletion Amplify/Categories/Analytics/AnalyticsCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

/// The Analytics category enables you to collect analytics data for your app.
final public class AnalyticsCategory: Category {
public final class AnalyticsCategory: Category {
/// Analytics category type
public let categoryType = CategoryType.analytics

Expand Down
7 changes: 4 additions & 3 deletions Amplify/Categories/Analytics/AnalyticsProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public struct AnalyticsUserProfile {
email: String? = nil,
plan: String? = nil,
location: Location? = nil,
properties: AnalyticsProperties? = nil) {
properties: AnalyticsProperties? = nil)
{
self.name = name
self.email = email
self.plan = plan
Expand All @@ -45,10 +46,10 @@ public struct AnalyticsUserProfile {
}
}

extension AnalyticsUserProfile {
public extension AnalyticsUserProfile {

/// Location specific data
public typealias Location = UserProfileLocation
typealias Location = UserProfileLocation
}

extension AnalyticsUserProfile: UserProfile {
Expand Down
3 changes: 2 additions & 1 deletion Amplify/Categories/Analytics/Event/BasicAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public struct BasicAnalyticsEvent: AnalyticsEvent {
/// - name: The name of the event
/// - properties: Properties of the event
public init(name: String,
properties: AnalyticsProperties? = nil) {
properties: AnalyticsProperties? = nil)
{
self.name = name
self.properties = properties
}
Expand Down
9 changes: 6 additions & 3 deletions Amplify/Categories/Auth/AuthCategory+ClientBehavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ extension AuthCategory: AuthCategoryBehavior {

public func confirmSignUp(for username: String,
confirmationCode: String,
options: AuthConfirmSignUpRequest.Options? = nil) async throws -> AuthSignUpResult {
options: AuthConfirmSignUpRequest.Options? = nil) async throws -> AuthSignUpResult
{
return try await plugin.confirmSignUp(for: username, confirmationCode: confirmationCode, options: options)
}

Expand All @@ -32,7 +33,8 @@ extension AuthCategory: AuthCategoryBehavior {

public func signIn(username: String? = nil,
password: String? = nil,
options: AuthSignInRequest.Options? = nil) async throws -> AuthSignInResult {
options: AuthSignInRequest.Options? = nil) async throws -> AuthSignInResult
{
return try await plugin.signIn(username: username, password: password, options: options)
}

Expand All @@ -46,7 +48,8 @@ extension AuthCategory: AuthCategoryBehavior {
public func signInWithWebUI(
for authProvider: AuthProvider,
presentationAnchor: AuthUIPresentationAnchor? = nil,
options: AuthWebUISignInRequest.Options? = nil) async throws -> AuthSignInResult {
options: AuthWebUISignInRequest.Options? = nil) async throws -> AuthSignInResult
{
return try await plugin.signInWithWebUI(for: authProvider,
presentationAnchor: presentationAnchor,
options: options)
Expand Down
6 changes: 4 additions & 2 deletions Amplify/Categories/Auth/AuthCategory+UserBehavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ extension AuthCategory: AuthCategoryUserBehavior {

public func update(userAttributes: [AuthUserAttribute],
options: AuthUpdateUserAttributesRequest.Options? = nil)
async throws -> [AuthUserAttributeKey: AuthUpdateAttributeResult] {
async throws -> [AuthUserAttributeKey: AuthUpdateAttributeResult]
{
try await plugin.update(userAttributes: userAttributes, options: options)
}

Expand All @@ -49,7 +50,8 @@ extension AuthCategory: AuthCategoryUserBehavior {

public func confirm(userAttribute: AuthUserAttributeKey,
confirmationCode: String,
options: AuthConfirmUserAttributeRequest.Options? = nil) async throws {
options: AuthConfirmUserAttributeRequest.Options? = nil) async throws
{
try await plugin.confirm(
userAttribute: userAttribute,
confirmationCode: confirmationCode,
Expand Down
Loading

0 comments on commit a6a31f3

Please sign in to comment.