Skip to content

Commit

Permalink
Swiftlint and Swiftformat cleanup
Browse files Browse the repository at this point in the history
Summary: $title

Reviewed By: samodom

Differential Revision: D38539379

fbshipit-source-id: 58a71be69891b9987629ae9cd90493a5a7f6e9b9
  • Loading branch information
joesus authored and facebook-github-bot committed Aug 9, 2022
1 parent b33da10 commit 64897b4
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 20 deletions.
6 changes: 2 additions & 4 deletions FBAEMKit/FBAEMKit/_AEMUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ public final class _AEMUtility: NSObject {

public func getMatchedInvocation(_ invocations: [_AEMInvocation], businessID: String?) -> _AEMInvocation? {
guard let businessID = businessID else {
for invocation in invocations.reversed() {
if invocation.businessID == nil {
return invocation
}
for invocation in invocations.reversed() where invocation.businessID == nil {
return invocation
}
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import FBSDKCoreKit_Basics

@objcMembers
// swiftlint:disable:next prefer_final_classes
public class FBSDKTransformerGraphRequestFactory: NSObject {
let contentType = "application/json"
let timeoutInterval = 60
Expand Down Expand Up @@ -64,7 +65,11 @@ public class FBSDKTransformerGraphRequestFactory: NSObject {
let requestDictionary = self.capiGatewayRequestDictionary(with: processedEvents)
let jsonData = try JSONSerialization.data(withJSONObject: requestDictionary, options: [])

var request = URLRequest(url: url, cachePolicy: NSURLRequest.CachePolicy.useProtocolCachePolicy, timeoutInterval: TimeInterval(self.timeoutInterval))
var request = URLRequest(
url: url,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: TimeInterval(self.timeoutInterval)
)
request.httpMethod = HTTPMethod.post.rawValue
request.setValue(self.contentType, forHTTPHeaderField: "Content-Type")
request.httpShouldHandleCookies = false
Expand All @@ -79,7 +84,8 @@ public class FBSDKTransformerGraphRequestFactory: NSObject {
return
}
}
}.resume()
}
.resume()
} catch {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
@testable import FBSDKCoreKit
import XCTest

class FBSDKAppEventsConversionsAPITransformerTests: XCTestCase {
// swiftlint:disable:next type_name
final class FBSDKAppEventsConversionsAPITransformerTests: XCTestCase {

// MARK: Helper variables

let customEvent1 = "[{\"_eventName\":\"fb_mobile_add_to_cart\",\"_logTime\":12345}]"
let customEvent2 =
// swiftlint:disable:next line_length
"[{\"_eventName\":\"fb_mobile_add_to_cart\",\"_logTime\":12345}, {\"_eventName\":\"new_event\",\"_logTime\":67890, \"fb_content_type\":\"product\", \"_valueToSum\":21.97, \"fb_currency\":\"GBP\"}]"

// swiftlint:disable:next identifier_name
let ud = "{\"fn\":\"1234567890\", \"em\":\"ABCDE\"}"

let restOfData1 = [
Expand Down Expand Up @@ -139,14 +142,18 @@ class FBSDKAppEventsConversionsAPITransformerTests: XCTestCase {
userData: &userData, appData: &appData, field: AppEventUserAndAppDataField.extinfo, value: ["i2"]
)
AppEventsConversionsAPITransformer.transformAndUpdateAppAndUserData(
userData: &userData, appData: &appData, field: AppEventUserAndAppDataField.userData,
userData: &userData,
appData: &appData,
field: AppEventUserAndAppDataField.userData,
value: "{\"fn\":\"1234567890\", \"em\":\"ABCDE\"}"
)

let ATE = try XCTUnwrap(appData[ConversionsAPIUserAndAppDataField.advTE.rawValue] as? Int)
let extinfo = try XCTUnwrap(appData[ConversionsAPIUserAndAppDataField.extinfo.rawValue] as? [Any])
let madid = try XCTUnwrap(userData[ConversionsAPIUserAndAppDataField.madid.rawValue] as? String)
// swiftlint:disable:next identifier_name
let fn = try XCTUnwrap(userData["fn"] as? String)
// swiftlint:disable:next identifier_name
let em = try XCTUnwrap(userData["em"] as? String)

XCTAssertEqual(ATE, 1)
Expand Down Expand Up @@ -175,12 +182,14 @@ class FBSDKAppEventsConversionsAPITransformerTests: XCTestCase {
}

func testTransformValueATE() throws {
let ateTransformedValue = AppEventsConversionsAPITransformer.transformValue(
field: AppEventUserAndAppDataField.advTE.rawValue,
value: "1"
) as? Bool
let ateTransformedValue = try XCTUnwrap(
AppEventsConversionsAPITransformer.transformValue(
field: AppEventUserAndAppDataField.advTE.rawValue,
value: "1"
) as? Bool
)

XCTAssertEqual(ateTransformedValue, true)
XCTAssertTrue(ateTransformedValue)
}

func testTransformValueExtinfo() throws {
Expand Down Expand Up @@ -265,16 +274,28 @@ class FBSDKAppEventsConversionsAPITransformerTests: XCTestCase {
let customEvents = [transformedCustomEvent1, transformedCustomEvent2]

XCTAssertNil(AppEventsConversionsAPITransformer.combineAllTransformedData(
eventType: AppEventType.other, userData: transformedUserData1, appData: transformedAppData1,
restOfData: restOfData1, customEvents: customEvents, eventTime: nil
eventType: AppEventType.other,
userData: transformedUserData1,
appData: transformedAppData1,
restOfData: restOfData1,
customEvents: customEvents,
eventTime: nil
))
XCTAssertNil(AppEventsConversionsAPITransformer.combineAllTransformedData(
eventType: AppEventType.custom, userData: transformedUserData1, appData: transformedAppData1,
restOfData: restOfData1, customEvents: [[String: Any]](), eventTime: nil
eventType: AppEventType.custom,
userData: transformedUserData1,
appData: transformedAppData1,
restOfData: restOfData1,
customEvents: [[String: Any]](),
eventTime: nil
))
XCTAssertNil(AppEventsConversionsAPITransformer.combineAllTransformedData(
eventType: AppEventType.mobileAppInstall, userData: transformedUserData1, appData: transformedAppData1,
restOfData: restOfData1, customEvents: [[String: Any]](), eventTime: nil
eventType: AppEventType.mobileAppInstall,
userData: transformedUserData1,
appData: transformedAppData1,
restOfData: restOfData1,
customEvents: [[String: Any]](),
eventTime: nil
))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import TestTools
import XCTest

class FBSDKTransformerGraphRequestFactoryTests: XCTestCase {
final class FBSDKTransformerGraphRequestFactoryTests: XCTestCase {

enum Keys {
static let eventName = "event_name"
Expand Down

0 comments on commit 64897b4

Please sign in to comment.