Эх сурвалжийг харах

Second run with swiftlint

Andrea Bizzotto 8 жил өмнө
parent
commit
2996240599

+ 0 - 2
SwiftyStoreKit-iOS-Demo/ViewController.swift

@@ -36,7 +36,6 @@ enum RegisteredPurchase: String {
     case nonRenewingPurchase = "nonRenewingPurchase"
 }
 
-
 class ViewController: UIViewController {
 
     let appBundleId = "com.musevisions.iOS.SwiftyStoreKit"
@@ -246,7 +245,6 @@ extension ViewController {
         }
     }
 
-
     func alertForVerifyReceipt(_ result: VerifyReceiptResult) -> UIAlertController {
 
         switch result {

+ 2 - 3
SwiftyStoreKit-macOS-Demo/ViewController.swift

@@ -110,7 +110,7 @@ class ViewController: NSViewController {
         let appleValidator = AppleReceiptValidator(service: .production)
         SwiftyStoreKit.verifyReceipt(using: appleValidator, password: "your-shared-secret") { result in
 
-            self.showAlert(self.alertForVerifyReceipt(result)) { response in
+            self.showAlert(self.alertForVerifyReceipt(result)) { _ in
 
                 if case .error(let error) = result {
                     if case .noReceiptData = error {
@@ -155,7 +155,7 @@ class ViewController: NSViewController {
 
     func refreshReceipt() {
 
-        SwiftyStoreKit.refreshReceipt() { result in
+        SwiftyStoreKit.refreshReceipt { result in
 
             self.showAlert(self.alertForRefreshReceipt(result))
         }
@@ -261,7 +261,6 @@ extension ViewController {
         }
     }
 
-
     func alertForVerifyPurchase(_ result: VerifyPurchaseResult) -> NSAlert {
 
         switch result {

+ 2 - 2
SwiftyStoreKit/AppleReceiptValidator.swift

@@ -47,7 +47,7 @@ public struct AppleReceiptValidator: ReceiptValidator {
 		let storeRequest = NSMutableURLRequest(url: storeURL)
 		storeRequest.httpMethod = "POST"
 
-		let requestContents: NSMutableDictionary = [ "receipt-data" : receipt ]
+		let requestContents: NSMutableDictionary = [ "receipt-data": receipt ]
 		// password if defined
 		if let password = autoRenewPassword {
 			requestContents.setValue(password, forKey: "password")
@@ -62,7 +62,7 @@ public struct AppleReceiptValidator: ReceiptValidator {
 		}
 
 		// Remote task
-		let task = URLSession.shared.dataTask(with: storeRequest as URLRequest) { data, response, error -> Void in
+		let task = URLSession.shared.dataTask(with: storeRequest as URLRequest) { data, _, error -> Void in
 
 			// there is an error
 			if let networkError = error {

+ 2 - 3
SwiftyStoreKit/CompleteTransactionsController.swift

@@ -27,9 +27,9 @@ import StoreKit
 
 struct CompleteTransactions {
     let atomically: Bool
-    let callback: ([Product]) -> ()
+    let callback: ([Product]) -> Void
 
-    init(atomically: Bool, callback: @escaping ([Product]) -> ()) {
+    init(atomically: Bool, callback: @escaping ([Product]) -> Void) {
         self.atomically = atomically
         self.callback = callback
     }
@@ -48,7 +48,6 @@ extension SKPaymentTransactionState {
     }
 }
 
-
 class CompleteTransactionsController: TransactionController {
 
     var completeTransactions: CompleteTransactions?

+ 1 - 1
SwiftyStoreKit/InAppProductQueryRequest.swift

@@ -26,7 +26,7 @@ import StoreKit
 
 class InAppProductQueryRequest: NSObject, SKProductsRequestDelegate {
 
-    typealias RequestCallback = (RetrieveResults) -> ()
+    typealias RequestCallback = (RetrieveResults) -> Void
     private let callback: RequestCallback
     private let request: SKProductsRequest
     // http://stackoverflow.com/questions/24011575/what-is-the-difference-between-a-weak-reference-and-an-unowned-reference

+ 1 - 1
SwiftyStoreKit/InAppReceipt.swift

@@ -55,7 +55,7 @@ internal class InAppReceipt {
     class func verify(
 		using validator: ReceiptValidator,
         password autoRenewPassword: String? = nil,
-        completion: @escaping (VerifyReceiptResult) -> ()) {
+        completion: @escaping (VerifyReceiptResult) -> Void) {
 
             // If no receipt is present, validation fails.
             guard let base64EncodedString = appStoreReceiptBase64Encoded else {

+ 1 - 1
SwiftyStoreKit/InAppReceiptRefreshRequest.swift

@@ -33,7 +33,7 @@ class InAppReceiptRefreshRequest: NSObject, SKRequestDelegate {
         case error(e: Error)
     }
 
-    typealias RequestCallback = (ResultType) -> ()
+    typealias RequestCallback = (ResultType) -> Void
 
     class func refresh(_ receiptProperties: [String : Any]? = nil, callback: @escaping RequestCallback) -> InAppReceiptRefreshRequest {
         let request = InAppReceiptRefreshRequest(receiptProperties: receiptProperties, callback: callback)

+ 0 - 1
SwiftyStoreKit/PaymentQueueController.swift

@@ -116,7 +116,6 @@ class PaymentQueueController: NSObject, SKPaymentTransactionObserver {
         paymentQueue.finishTransaction(skTransaction)
     }
 
-
     // MARK: SKPaymentTransactionObserver
     func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
 

+ 1 - 2
SwiftyStoreKit/PaymentsController.swift

@@ -22,7 +22,6 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import Foundation
 import StoreKit
 
@@ -30,7 +29,7 @@ struct Payment: Hashable {
     let product: SKProduct
     let atomically: Bool
     let applicationUsername: String
-    let callback: (TransactionResult) -> ()
+    let callback: (TransactionResult) -> Void
 
     var hashValue: Int {
         return product.productIdentifier.hashValue

+ 2 - 2
SwiftyStoreKit/ProductsInfoController.swift

@@ -43,7 +43,7 @@ class ProductsInfoController: NSObject {
         return Set(productIds.flatMap { self.products[$0] })
     }
 
-    private func requestProducts(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> ()) {
+    private func requestProducts(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> Void) {
 
         inflightQueries[productIds] = InAppProductQueryRequest.startQuery(productIds) { result in
 
@@ -55,7 +55,7 @@ class ProductsInfoController: NSObject {
         }
     }
 
-    func retrieveProductsInfo(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> ()) {
+    func retrieveProductsInfo(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> Void) {
 
         let products = allProductsMatching(productIds)
         guard products.count == productIds.count else {

+ 2 - 2
SwiftyStoreKit/RestorePurchasesController.swift

@@ -28,9 +28,9 @@ import StoreKit
 struct RestorePurchases {
     let atomically: Bool
     let applicationUsername: String?
-    let callback: ([TransactionResult]) -> ()
+    let callback: ([TransactionResult]) -> Void
 
-    init(atomically: Bool, applicationUsername: String? = nil, callback: @escaping ([TransactionResult]) -> ()) {
+    init(atomically: Bool, applicationUsername: String? = nil, callback: @escaping ([TransactionResult]) -> Void) {
         self.atomically = atomically
         self.applicationUsername = applicationUsername
         self.callback = callback

+ 13 - 14
SwiftyStoreKit/SwiftyStoreKit.swift

@@ -41,16 +41,16 @@ public class SwiftyStoreKit {
 
     // MARK: Internal methods
 
-    func retrieveProductsInfo(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> ()) {
+    func retrieveProductsInfo(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> Void) {
         return productsInfoController.retrieveProductsInfo(productIds, completion: completion)
     }
 
-    func purchaseProduct(_ productId: String, atomically: Bool = true, applicationUsername: String = "", completion: @escaping ( PurchaseResult) -> ()) {
+    func purchaseProduct(_ productId: String, atomically: Bool = true, applicationUsername: String = "", completion: @escaping ( PurchaseResult) -> Void) {
 
         if let product = productsInfoController.products[productId] {
             purchase(product: product, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
         } else {
-            retrieveProductsInfo(Set([productId])) { result -> () in
+            retrieveProductsInfo(Set([productId])) { result -> Void in
                 if let product = result.retrievedProducts.first {
                     self.purchase(product: product, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
                 } else if let error = result.error {
@@ -64,7 +64,7 @@ public class SwiftyStoreKit {
         }
     }
 
-    func restorePurchases(atomically: Bool = true, applicationUsername: String = "", completion: @escaping (RestoreResults) -> ()) {
+    func restorePurchases(atomically: Bool = true, applicationUsername: String = "", completion: @escaping (RestoreResults) -> Void) {
 
         paymentQueueController.restorePurchases(RestorePurchases(atomically: atomically, applicationUsername: applicationUsername) { results in
 
@@ -73,7 +73,7 @@ public class SwiftyStoreKit {
         })
     }
 
-    func completeTransactions(atomically: Bool = true, completion: @escaping ([Product]) -> ()) {
+    func completeTransactions(atomically: Bool = true, completion: @escaping ([Product]) -> Void) {
 
         paymentQueueController.completeTransactions(CompleteTransactions(atomically: atomically, callback: completion))
     }
@@ -83,7 +83,7 @@ public class SwiftyStoreKit {
         paymentQueueController.finishTransaction(transaction)
     }
 
-    func refreshReceipt(_ receiptProperties: [String : Any]? = nil, completion: @escaping (RefreshReceiptResult) -> ()) {
+    func refreshReceipt(_ receiptProperties: [String : Any]? = nil, completion: @escaping (RefreshReceiptResult) -> Void) {
         receiptRefreshRequest = InAppReceiptRefreshRequest.refresh(receiptProperties) { result in
 
             self.receiptRefreshRequest = nil
@@ -102,7 +102,7 @@ public class SwiftyStoreKit {
     }
 
     // MARK: private methods
-    private func purchase(product: SKProduct, atomically: Bool, applicationUsername: String = "", completion: @escaping (PurchaseResult) -> ()) {
+    private func purchase(product: SKProduct, atomically: Bool, applicationUsername: String = "", completion: @escaping (PurchaseResult) -> Void) {
         guard SwiftyStoreKit.canMakePayments else {
             let error = NSError(domain: SKErrorDomain, code: SKError.paymentNotAllowed.rawValue, userInfo: nil)
             completion(.error(error: SKError(_nsError: error)))
@@ -159,7 +159,7 @@ extension SwiftyStoreKit {
         return SKPaymentQueue.canMakePayments()
     }
 
-    public class func retrieveProductsInfo(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> ()) {
+    public class func retrieveProductsInfo(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> Void) {
 
         return sharedInstance.retrieveProductsInfo(productIds, completion: completion)
     }
@@ -171,29 +171,28 @@ extension SwiftyStoreKit {
      *  - Parameter applicationUsername: an opaque identifier for the user’s account on your system
      *  - Parameter completion: handler for result
      */
-    public class func purchaseProduct(_ productId: String, atomically: Bool = true, applicationUsername: String = "", completion: @escaping ( PurchaseResult) -> ()) {
+    public class func purchaseProduct(_ productId: String, atomically: Bool = true, applicationUsername: String = "", completion: @escaping ( PurchaseResult) -> Void) {
 
         sharedInstance.purchaseProduct(productId, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
     }
 
-    public class func restorePurchases(atomically: Bool = true, applicationUsername: String = "", completion: @escaping (RestoreResults) -> ()) {
+    public class func restorePurchases(atomically: Bool = true, applicationUsername: String = "", completion: @escaping (RestoreResults) -> Void) {
 
         sharedInstance.restorePurchases(atomically: atomically, applicationUsername: applicationUsername, completion: completion)
     }
 
-    public class func completeTransactions(atomically: Bool = true, completion: @escaping ([Product]) -> ()) {
+    public class func completeTransactions(atomically: Bool = true, completion: @escaping ([Product]) -> Void) {
 
         sharedInstance.completeTransactions(atomically: atomically, completion: completion)
     }
 
-
     public class func finishTransaction(_ transaction: PaymentTransaction) {
 
         sharedInstance.finishTransaction(transaction)
     }
 
     // After verifying receive and have `ReceiptError.NoReceiptData`, refresh receipt using this method
-    public class func refreshReceipt(_ receiptProperties: [String : Any]? = nil, completion: @escaping (RefreshReceiptResult) -> ()) {
+    public class func refreshReceipt(_ receiptProperties: [String : Any]? = nil, completion: @escaping (RefreshReceiptResult) -> Void) {
 
         sharedInstance.refreshReceipt(receiptProperties, completion: completion)
     }
@@ -219,7 +218,7 @@ extension SwiftyStoreKit {
     public class func verifyReceipt(
         using validator: ReceiptValidator,
         password: String? = nil,
-        completion:@escaping (VerifyReceiptResult) -> ()) {
+        completion:@escaping (VerifyReceiptResult) -> Void) {
 
         InAppReceipt.verify(using: validator, password: password) { result in
 

+ 3 - 5
SwiftyStoreKitTests/PaymentQueueControllerTests.swift

@@ -27,7 +27,7 @@ import StoreKit
 @testable import SwiftyStoreKit
 
 extension Payment {
-    init(product: SKProduct, atomically: Bool, applicationUsername: String, callback: @escaping (TransactionResult) -> ()) {
+    init(product: SKProduct, atomically: Bool, applicationUsername: String, callback: @escaping (TransactionResult) -> Void) {
         self.product = product
         self.atomically = atomically
         self.applicationUsername = applicationUsername
@@ -64,7 +64,7 @@ class PaymentQueueControllerTests: XCTestCase {
 
         let paymentQueueController = PaymentQueueController(paymentQueue: spy)
 
-        let payment = makeTestPayment(productIdentifier: "com.SwiftyStoreKit.product1") { result in }
+        let payment = makeTestPayment(productIdentifier: "com.SwiftyStoreKit.product1") { _ in }
 
         paymentQueueController.startPayment(payment)
 
@@ -93,7 +93,6 @@ class PaymentQueueControllerTests: XCTestCase {
             makeTestPaymentTransaction(productIdentifier: purchasingProductIdentifier, transactionState: .purchasing),
             ]
 
-
         var paymentCallbackCalled = false
         let testPayment = makeTestPayment(productIdentifier: purchasedProductIdentifier) { result in
             paymentCallbackCalled = true
@@ -161,7 +160,6 @@ class PaymentQueueControllerTests: XCTestCase {
             makeTestPaymentTransaction(productIdentifier: purchasingProductIdentifier, transactionState: .purchasing),
             ]
 
-
         var paymentCallbackCalled = false
         let testPayment = makeTestPayment(productIdentifier: purchasedProductIdentifier) { result in
             paymentCallbackCalled = true
@@ -256,7 +254,7 @@ class PaymentQueueControllerTests: XCTestCase {
         return TestPaymentTransaction(payment: SKPayment(product: testProduct), transactionState: transactionState)
     }
 
-    func makeTestPayment(productIdentifier: String, atomically: Bool = true, callback: @escaping (TransactionResult) -> ()) -> Payment {
+    func makeTestPayment(productIdentifier: String, atomically: Bool = true, callback: @escaping (TransactionResult) -> Void) -> Payment {
 
         let testProduct = TestProduct(productIdentifier: productIdentifier)
         return Payment(product: testProduct, atomically: atomically, applicationUsername: "", callback: callback)

+ 4 - 5
SwiftyStoreKitTests/PaymentsControllerTests.swift

@@ -30,7 +30,7 @@ class PaymentsControllerTests: XCTestCase {
 
     func testInsertPayment_hasPayment() {
 
-        let payment = makeTestPayment(productIdentifier: "com.SwiftyStoreKit.product1") { result in }
+        let payment = makeTestPayment(productIdentifier: "com.SwiftyStoreKit.product1") { _ in }
 
         let paymentsController = makePaymentsController(appendPayments: [payment])
 
@@ -168,7 +168,7 @@ class PaymentsControllerTests: XCTestCase {
         }
 
         let testProduct2 = TestProduct(productIdentifier: productIdentifier)
-        let payment2 = makeTestPayment(product: testProduct2) { result in
+        let payment2 = makeTestPayment(product: testProduct2) { _ in
 
             XCTFail("unexpected callback for second payment")
         }
@@ -191,7 +191,6 @@ class PaymentsControllerTests: XCTestCase {
         XCTAssertEqual(spy.finishTransactionCalledCount, 1)
     }
 
-
     func makePaymentsController(appendPayments payments: [Payment]) -> PaymentsController {
 
         let paymentsController = PaymentsController()
@@ -201,12 +200,12 @@ class PaymentsControllerTests: XCTestCase {
         return paymentsController
     }
 
-    func makeTestPayment(product: SKProduct, atomically: Bool = true, callback: @escaping (TransactionResult) -> ()) -> Payment {
+    func makeTestPayment(product: SKProduct, atomically: Bool = true, callback: @escaping (TransactionResult) -> Void) -> Payment {
 
         return Payment(product: product, atomically: atomically, applicationUsername: "", callback: callback)
     }
 
-    func makeTestPayment(productIdentifier: String, atomically: Bool = true, callback: @escaping (TransactionResult) -> ()) -> Payment {
+    func makeTestPayment(productIdentifier: String, atomically: Bool = true, callback: @escaping (TransactionResult) -> Void) -> Payment {
 
         let product = TestProduct(productIdentifier: productIdentifier)
         return makeTestPayment(product: product, atomically: atomically, callback: callback)

+ 0 - 1
SwiftyStoreKitTests/RestorePurchasesControllerTests.swift

@@ -22,7 +22,6 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import XCTest
 import StoreKit
 @testable import SwiftyStoreKit