From ddceaa7d52202fd59f84645da145b1693e7698a8 Mon Sep 17 00:00:00 2001 From: Hui Zhao Date: Wed, 17 Nov 2021 18:48:03 -0800 Subject: [PATCH] Fix swift linter complained errors - Function name cannot start with upper case - Class name cannot start with lower case --- .../SwiftAmplifyAnalyticsPinpointPlugin.swift | 2 +- .../ios/Classes/SwiftAmplifyApiPlugin.swift | 2 +- .../ios/Classes/SwiftAuthCognito.swift | 2 +- .../ios/Classes/Support/AtomicResult.swift | 14 +++++++------- .../Classes/SwiftAmplifyDataStorePlugin.swift | 2 +- .../ios/unit_tests/AtomicResultTests.swift | 18 +++++++++--------- .../ios/Classes/SwiftAmplify.swift | 2 +- .../Classes/SwiftAmplifyStorageS3Plugin.swift | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/amplify_analytics_pinpoint/ios/Classes/SwiftAmplifyAnalyticsPinpointPlugin.swift b/packages/amplify_analytics_pinpoint/ios/Classes/SwiftAmplifyAnalyticsPinpointPlugin.swift index 64ba6ed50d..debff1ea50 100644 --- a/packages/amplify_analytics_pinpoint/ios/Classes/SwiftAmplifyAnalyticsPinpointPlugin.swift +++ b/packages/amplify_analytics_pinpoint/ios/Classes/SwiftAmplifyAnalyticsPinpointPlugin.swift @@ -37,7 +37,7 @@ public class SwiftAmplifyAnalyticsPinpointPlugin: NSObject, FlutterPlugin { } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - let result = AtomicResult(result, call.method) + let result = atomicResult(result, call.method) innerHandle(method: call.method, callArgs: call.arguments as Any?, result: result) } diff --git a/packages/amplify_api/ios/Classes/SwiftAmplifyApiPlugin.swift b/packages/amplify_api/ios/Classes/SwiftAmplifyApiPlugin.swift index 53a8e2e66a..b1c80471a8 100644 --- a/packages/amplify_api/ios/Classes/SwiftAmplifyApiPlugin.swift +++ b/packages/amplify_api/ios/Classes/SwiftAmplifyApiPlugin.swift @@ -46,7 +46,7 @@ public class SwiftAmplifyApiPlugin: NSObject, FlutterPlugin { } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - let result = AtomicResult(result, call.method) + let result = atomicResult(result, call.method) innerHandle(method: call.method, callArgs: call.arguments as Any, result: result) } diff --git a/packages/amplify_auth_cognito/ios/Classes/SwiftAuthCognito.swift b/packages/amplify_auth_cognito/ios/Classes/SwiftAuthCognito.swift index 2c7533c76b..d975d75d50 100644 --- a/packages/amplify_auth_cognito/ios/Classes/SwiftAuthCognito.swift +++ b/packages/amplify_auth_cognito/ios/Classes/SwiftAuthCognito.swift @@ -65,7 +65,7 @@ public class SwiftAuthCognito: NSObject, FlutterPlugin { } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - let result = AtomicResult(result, call.method) + let result = atomicResult(result, call.method) if(call.method == "addPlugin"){ do { diff --git a/packages/amplify_core/ios/Classes/Support/AtomicResult.swift b/packages/amplify_core/ios/Classes/Support/AtomicResult.swift index c9ae6c8485..618d7b0be2 100644 --- a/packages/amplify_core/ios/Classes/Support/AtomicResult.swift +++ b/packages/amplify_core/ios/Classes/Support/AtomicResult.swift @@ -16,24 +16,24 @@ import Foundation /// Thread-safe wrapper for [FlutterResult]. Prevents multiple replies and automically posts results to the main thread. -public func AtomicResult(_ result: @escaping FlutterResult, _ methodName: String) -> FlutterResult { - return atomicResult(result, methodName).send +public func atomicResult(_ result: @escaping FlutterResult, _ methodName: String) -> FlutterResult { + return AtomicResult(result, methodName).send } -private class atomicResult { +private class AtomicResult { let result: FlutterResult - + /// The method call which initiated this result. let methodName: String - + /// Whether a reply has already been sent. var isSent = false - + init(_ result: @escaping FlutterResult, _ methodName: String) { self.result = result self.methodName = methodName } - + func send(_ value: Any?) { DispatchQueue.main.async { [self] in guard !isSent else { diff --git a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift index 470087e3e1..207d627de5 100644 --- a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift +++ b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift @@ -54,7 +54,7 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin { } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - let result = AtomicResult(result, call.method) + let result = atomicResult(result, call.method) var arguments: [String: Any] = [:] do { if(call.arguments != nil) { diff --git a/packages/amplify_flutter/example/ios/unit_tests/AtomicResultTests.swift b/packages/amplify_flutter/example/ios/unit_tests/AtomicResultTests.swift index 19d6475981..f1cd609d6f 100644 --- a/packages/amplify_flutter/example/ios/unit_tests/AtomicResultTests.swift +++ b/packages/amplify_flutter/example/ios/unit_tests/AtomicResultTests.swift @@ -36,8 +36,8 @@ class AtomicResultTests: XCTestCase { } XCTAssertEqual(strValue, expected) } - let atomicResult = AtomicResult(result, #function) - atomicResult(expected) + let aResult = atomicResult(result, #function) + aResult(expected) waitForExpectations(timeout: 1) } @@ -52,8 +52,8 @@ class AtomicResultTests: XCTestCase { } XCTAssertEqual(errValue, expected) } - let atomicResult = AtomicResult(result, #function) - atomicResult(expected) + let aResult = atomicResult(result, #function) + aResult(expected) waitForExpectations(timeout: 0.1) } @@ -61,9 +61,9 @@ class AtomicResultTests: XCTestCase { let result: FlutterResult = { _ in OSAtomicIncrement32(&self.counter) } - let atomicResult = AtomicResult(result, #function) - atomicResult(nil) - atomicResult(nil) + let aResult = atomicResult(result, #function) + aResult(nil) + aResult(nil) let exp = expectation(description: #function) DispatchQueue.main.async { [self] in XCTAssertEqual(counter, 1) @@ -76,11 +76,11 @@ class AtomicResultTests: XCTestCase { let result: FlutterResult = { _ in OSAtomicIncrement32(&self.counter) } - let atomicResult = AtomicResult(result, #function) + let aResult = atomicResult(result, #function) DispatchQueue.global().sync { DispatchQueue.concurrentPerform(iterations: 1000) { i in - atomicResult(nil) + aResult(nil) } } diff --git a/packages/amplify_flutter/ios/Classes/SwiftAmplify.swift b/packages/amplify_flutter/ios/Classes/SwiftAmplify.swift index 761a1fa327..a065a536a3 100644 --- a/packages/amplify_flutter/ios/Classes/SwiftAmplify.swift +++ b/packages/amplify_flutter/ios/Classes/SwiftAmplify.swift @@ -29,7 +29,7 @@ public class SwiftAmplify: NSObject, FlutterPlugin { } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - let result = AtomicResult(result, call.method) + let result = atomicResult(result, call.method) switch call.method { case "configure": diff --git a/packages/amplify_storage_s3/ios/Classes/SwiftAmplifyStorageS3Plugin.swift b/packages/amplify_storage_s3/ios/Classes/SwiftAmplifyStorageS3Plugin.swift index f4ca5319a0..43f99b9a36 100644 --- a/packages/amplify_storage_s3/ios/Classes/SwiftAmplifyStorageS3Plugin.swift +++ b/packages/amplify_storage_s3/ios/Classes/SwiftAmplifyStorageS3Plugin.swift @@ -33,7 +33,7 @@ public class SwiftAmplifyStorageS3Plugin: NSObject, FlutterPlugin { } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - let result = AtomicResult(result, call.method) + let result = atomicResult(result, call.method) if(call.method == "addPlugin"){ do {