From 6601a023bc195e6f2dda90340ff5db2959af010a Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 13:54:56 +0100 Subject: [PATCH 01/26] Remove all 'value == true' instances --- Dangerfile.swift | 2 +- .../project.pbxproj | 104 +++++++++--------- Debug App/Sources/AppDelegate.swift | 2 +- .../Sources/Model/CreateClientToken.swift | 2 +- .../Utilities/AppetizeConfigProvider.swift | 2 +- ...hantSessionAndSettingsViewController.swift | 2 +- .../Core/Connectivity/Connectivity.swift | 2 +- .../Models/BanksTokenizationComponent.swift | 2 +- ...KlarnaComponent+SessionAuthorization.swift | 6 +- ...sKlarnaComponent+SessionFinalization.swift | 2 +- .../CardComponentsManager.swift | 2 +- .../RawDataManager.swift | 2 +- .../Managers/VaultManager.swift | 2 +- .../Classes/Data Models/ClientToken.swift | 2 +- .../Classes/Data Models/OrderItem.swift | 2 +- .../Data Models/PrimerConfiguration.swift | 2 +- .../ImageFileProcessor.swift | 4 +- .../Classes/Modules/ImageManager.swift | 6 +- .../Classes/Modules/UserInterfaceModule.swift | 2 +- ...rmPaymentMethodTokenizationViewModel.swift | 23 ++-- ...rmPaymentMethodTokenizationViewModel.swift | 8 +- .../PrimerCardholderNameFieldView.swift | 2 +- .../CVVRecaptureViewController.swift | 9 +- .../Root/PrimerFormViewController.swift | 2 +- ...rimerUniversalCheckoutViewController.swift | 2 +- .../PrimerFirstNameFieldView.swift | 2 +- .../Text Fields/PrimerLastNameFieldView.swift | 2 +- .../Text Fields/PrimerStateFieldView.swift | 2 +- .../QRCodeViewController.swift | 2 +- .../ApplePayTokenizationViewModel.swift | 6 +- .../NolPayTokenizationViewModel.swift | 2 +- ...ctPaymentMethodTokenizationViewModel.swift | 2 +- .../HUC_TokenizationViewModelTests.swift | 4 +- .../Network/Legacy/URLSessionStackTests.swift | 8 +- .../NolPayUnlinkCardComponentTest.swift | 2 +- Tests/Unit Tests/Utils/WebViewUtilTests.swift | 2 +- 36 files changed, 115 insertions(+), 115 deletions(-) diff --git a/Dangerfile.swift b/Dangerfile.swift index 3e315247a4..b584b1c00a 100644 --- a/Dangerfile.swift +++ b/Dangerfile.swift @@ -54,7 +54,7 @@ if additions + deletions > bigPRThreshold { // MARK: - PR WIP -if pr.title.contains("WIP") || pr.draft == true { +if pr.title.contains("WIP") || pr.draft { warn("PR is classed as Work in Progress") } diff --git a/Debug App/Primer.io Debug App.xcodeproj/project.pbxproj b/Debug App/Primer.io Debug App.xcodeproj/project.pbxproj index c0c496cca9..65efdbd1e3 100644 --- a/Debug App/Primer.io Debug App.xcodeproj/project.pbxproj +++ b/Debug App/Primer.io Debug App.xcodeproj/project.pbxproj @@ -35,14 +35,14 @@ 876141082B8346650058CA8C /* MerchantHeadlessKlarnaInitializationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 876141072B8346650058CA8C /* MerchantHeadlessKlarnaInitializationView.swift */; }; 8761410A2B8355920058CA8C /* MerchantHeadlessKlarnaInitializationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 876141092B8355920058CA8C /* MerchantHeadlessKlarnaInitializationViewModel.swift */; }; 8761410C2B849A250058CA8C /* MerchantHeadlessKlarnaInitializationView+Elements.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8761410B2B849A250058CA8C /* MerchantHeadlessKlarnaInitializationView+Elements.swift */; }; + 8A9CDDA3DBB1BAE5FC83B41D /* Pods_Debug_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C03F162817FA88FE027BAD75 /* Pods_Debug_App.framework */; }; 949864026D1CDE6F5C62C66E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE259612A00F85709107B872 /* Main.storyboard */; }; A19EF5632B20E22E00A72F60 /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = A19EF5622B20E22E00A72F60 /* .swiftlint.yml */; }; AAE3B30B64B6822A20987FCA /* CreateClientToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = 229849A3DBE0858EE90673B9 /* CreateClientToken.swift */; }; AD9CF1073EE0676E6640481A /* MerchantHeadlessCheckoutRawDataViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B866FF13033A5CB8B4C3388E /* MerchantHeadlessCheckoutRawDataViewController.swift */; }; - B15DB155FF963676B88B96BF /* Pods_Debug_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E07ED300DA4DBEB8D2BF520D /* Pods_Debug_App.framework */; }; - BAEBC22D052C55BD8EC53C6B /* Pods_Debug_App_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F0FD41735810826EB829619C /* Pods_Debug_App_Tests.framework */; }; C0115AC7BC96FDF49EF8E530 /* PaymentMethodCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E79C93EA805E87E1137A513 /* PaymentMethodCell.swift */; }; C75A11E6AEEFC2B7A29BBC04 /* TestScenario.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6AEF11B151368BF993C3EA9 /* TestScenario.swift */; }; + C91883558AE2139022890E15 /* Pods_Debug_App_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D5E662A6F6F5D1F02A41932 /* Pods_Debug_App_Tests.framework */; }; CE5E673A96BB5B96AE5EFC56 /* Range+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9128566126AA7F571FFECA3A /* Range+Extensions.swift */; }; D886D8E47D883304B505CE11 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC5687FF32E8661F1A00CE5 /* AppDelegate.swift */; }; DE53DA2D0AD108306C92E198 /* UIViewController+API.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1FD8065D40A2D691F643F3B /* UIViewController+API.swift */; }; @@ -108,17 +108,17 @@ 13FA89917603E4BA5BB66AFC /* da */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = da; path = da.lproj/LaunchScreen.strings; sourceTree = ""; }; 1594BC5C96ECC3F46C811B2F /* Data+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Extensions.swift"; sourceTree = ""; }; 1D05E65C196E6715D7D8B0C6 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Main.strings; sourceTree = ""; }; - 1F278229D66AFE30C9C39085 /* Pods-Debug App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Debug App.release.xcconfig"; path = "Target Support Files/Pods-Debug App/Pods-Debug App.release.xcconfig"; sourceTree = ""; }; 229849A3DBE0858EE90673B9 /* CreateClientToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateClientToken.swift; sourceTree = ""; }; - 27B211EA3949D1672A82B5F6 /* Pods-Debug App Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Debug App Tests.debug.xcconfig"; path = "Target Support Files/Pods-Debug App Tests/Pods-Debug App Tests.debug.xcconfig"; sourceTree = ""; }; 2A328E38DA586FFE0ED2894B /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Main.strings; sourceTree = ""; }; 2E64F057A39A91CA01CCB57F /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Main.strings; sourceTree = ""; }; + 31523817971E2C6BC9635F49 /* Pods-Debug App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Debug App.release.xcconfig"; path = "Target Support Files/Pods-Debug App/Pods-Debug App.release.xcconfig"; sourceTree = ""; }; 33E18D5B5190C64631309D1B /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/LaunchScreen.strings; sourceTree = ""; }; 39CCCB917D1881082ED75975 /* ViewController+Primer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewController+Primer.swift"; sourceTree = ""; }; 404E173A513B986A36F835F7 /* MerchantHeadlessCheckoutRawPhoneNumberDataViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantHeadlessCheckoutRawPhoneNumberDataViewController.swift; sourceTree = ""; }; 483D2036DE3F89CA2C244C4F /* Debug App Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Debug App Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 4ACFB17A73AB7240BED98585 /* ExampleApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ExampleApp.entitlements; sourceTree = ""; }; 4C353D84EABA4990DAB4DD28 /* MerchantHeadlessCheckoutRawRetailDataViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantHeadlessCheckoutRawRetailDataViewController.swift; sourceTree = ""; }; + 4D5E662A6F6F5D1F02A41932 /* Pods_Debug_App_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Debug_App_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4E79C93EA805E87E1137A513 /* PaymentMethodCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentMethodCell.swift; sourceTree = ""; }; 52F54EC3C1ACE19DF48BD6E2 /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/LaunchScreen.strings; sourceTree = ""; }; 6493EA8D95DDA066DE982B24 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Main.strings; sourceTree = ""; }; @@ -131,7 +131,6 @@ 72E691B9A6A8EBB9F6A6B266 /* MerchantHeadlessCheckoutAvailablePaymentMethodsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantHeadlessCheckoutAvailablePaymentMethodsViewController.swift; sourceTree = ""; }; 743E00065B4A8D6C95092A23 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/LaunchScreen.strings; sourceTree = ""; }; 7480FE5F665CC66C092BC95A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 85AFC960D1A9EB56C4561471 /* Pods-Debug App Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Debug App Tests.release.xcconfig"; path = "Target Support Files/Pods-Debug App Tests/Pods-Debug App Tests.release.xcconfig"; sourceTree = ""; }; 876140D42B63F7DB0058CA8C /* MerchantHeadlessCheckoutKlarnaViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantHeadlessCheckoutKlarnaViewController.swift; sourceTree = ""; }; 876140E52B67F3B30058CA8C /* MerchantHeadlessCheckoutKlarnaViewController+Klarna.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MerchantHeadlessCheckoutKlarnaViewController+Klarna.swift"; sourceTree = ""; }; 876140EE2B6BE8C20058CA8C /* MerchantHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantHelpers.swift; sourceTree = ""; }; @@ -147,11 +146,13 @@ 9874F439DA3EA5854A454687 /* MerchantDropInUIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantDropInUIViewController.swift; sourceTree = ""; }; A1604A656AF654D7422A2A5E /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Main.strings; sourceTree = ""; }; A19EF5622B20E22E00A72F60 /* .swiftlint.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = ""; }; + A226AFCE5F67A270D5CD1A7A /* Pods-Debug App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Debug App.debug.xcconfig"; path = "Target Support Files/Pods-Debug App/Pods-Debug App.debug.xcconfig"; sourceTree = ""; }; A6AEF11B151368BF993C3EA9 /* TestScenario.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestScenario.swift; sourceTree = ""; }; B18D7E7738BF86467B0F1465 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; B1FD8065D40A2D691F643F3B /* UIViewController+API.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+API.swift"; sourceTree = ""; }; B866FF13033A5CB8B4C3388E /* MerchantHeadlessCheckoutRawDataViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantHeadlessCheckoutRawDataViewController.swift; sourceTree = ""; }; - BB7C19D2A72C70B70AA4DF8C /* Pods-Debug App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Debug App.debug.xcconfig"; path = "Target Support Files/Pods-Debug App/Pods-Debug App.debug.xcconfig"; sourceTree = ""; }; + BF7765EA0354CB6AEB6DCDF0 /* Pods-Debug App Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Debug App Tests.release.xcconfig"; path = "Target Support Files/Pods-Debug App Tests/Pods-Debug App Tests.release.xcconfig"; sourceTree = ""; }; + C03F162817FA88FE027BAD75 /* Pods_Debug_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Debug_App.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C18C9664115CFDEB59FED19A /* MerchantSessionAndSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantSessionAndSettingsViewController.swift; sourceTree = ""; }; C4DFE77F28AB538220A0F6EE /* ka */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ka; path = ka.lproj/Main.strings; sourceTree = ""; }; C7EB86C62BA46BF51C64ABC2 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/LaunchScreen.strings; sourceTree = ""; }; @@ -160,7 +161,6 @@ DAC5687FF32E8661F1A00CE5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; DBC8EA85D1CBC1EC4AB3EB8C /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/LaunchScreen.strings; sourceTree = ""; }; DECCDC4079DC6471CEDDEA84 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/LaunchScreen.strings; sourceTree = ""; }; - E07ED300DA4DBEB8D2BF520D /* Pods_Debug_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Debug_App.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E11F47502B06C5030091C31F /* BanksListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BanksListView.swift; sourceTree = ""; }; E11F47512B06C5030091C31F /* BanksListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BanksListModel.swift; sourceTree = ""; }; E11F47522B06C5030091C31F /* ImageViewWithUrl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageViewWithUrl.swift; sourceTree = ""; }; @@ -172,7 +172,7 @@ F08F63D72B9B5A7C006EF9A9 /* SessionConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionConfiguration.swift; sourceTree = ""; }; F08F63D92B9B5BC5006EF9A9 /* AppetizeConfigProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppetizeConfigProvider.swift; sourceTree = ""; }; F08F63DB2B9F27B0006EF9A9 /* MetadataParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetadataParser.swift; sourceTree = ""; }; - F0FD41735810826EB829619C /* Pods_Debug_App_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Debug_App_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F285660C7775AB2AD591744D /* Pods-Debug App Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Debug App Tests.debug.xcconfig"; path = "Target Support Files/Pods-Debug App Tests/Pods-Debug App Tests.debug.xcconfig"; sourceTree = ""; }; F816A2444633C4336A7CB071 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = ""; }; F9023841AFCE8E3205CB713A /* String+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extensions.swift"; sourceTree = ""; }; FB1F71737862EF5D0F4FE5AB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; @@ -186,7 +186,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - BAEBC22D052C55BD8EC53C6B /* Pods_Debug_App_Tests.framework in Frameworks */, + C91883558AE2139022890E15 /* Pods_Debug_App_Tests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -194,7 +194,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - B15DB155FF963676B88B96BF /* Pods_Debug_App.framework in Frameworks */, + 8A9CDDA3DBB1BAE5FC83B41D /* Pods_Debug_App.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -221,15 +221,6 @@ path = Tests; sourceTree = ""; }; - 093C53944BD75C6EB0F2C8C0 /* Frameworks */ = { - isa = PBXGroup; - children = ( - E07ED300DA4DBEB8D2BF520D /* Pods_Debug_App.framework */, - F0FD41735810826EB829619C /* Pods_Debug_App_Tests.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; 094077DEFDC2739B10CF4183 /* Resources */ = { isa = PBXGroup; children = ( @@ -263,7 +254,7 @@ FBDF3F8B5F93A0EC28048640 /* Project */, DF30711EB149C64C364BB79A /* Products */, 61E8D69DF93462D748F446DF /* Pods */, - 093C53944BD75C6EB0F2C8C0 /* Frameworks */, + 6B4B627B7C3D4DEB1756F173 /* Frameworks */, ); sourceTree = ""; }; @@ -308,10 +299,10 @@ 61E8D69DF93462D748F446DF /* Pods */ = { isa = PBXGroup; children = ( - BB7C19D2A72C70B70AA4DF8C /* Pods-Debug App.debug.xcconfig */, - 1F278229D66AFE30C9C39085 /* Pods-Debug App.release.xcconfig */, - 27B211EA3949D1672A82B5F6 /* Pods-Debug App Tests.debug.xcconfig */, - 85AFC960D1A9EB56C4561471 /* Pods-Debug App Tests.release.xcconfig */, + A226AFCE5F67A270D5CD1A7A /* Pods-Debug App.debug.xcconfig */, + 31523817971E2C6BC9635F49 /* Pods-Debug App.release.xcconfig */, + F285660C7775AB2AD591744D /* Pods-Debug App Tests.debug.xcconfig */, + BF7765EA0354CB6AEB6DCDF0 /* Pods-Debug App Tests.release.xcconfig */, ); path = Pods; sourceTree = ""; @@ -325,6 +316,15 @@ path = Network; sourceTree = ""; }; + 6B4B627B7C3D4DEB1756F173 /* Frameworks */ = { + isa = PBXGroup; + children = ( + C03F162817FA88FE027BAD75 /* Pods_Debug_App.framework */, + 4D5E662A6F6F5D1F02A41932 /* Pods_Debug_App_Tests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 876140D32B63F79E0058CA8C /* KlarnaHeadless */ = { isa = PBXGroup; children = ( @@ -415,7 +415,7 @@ isa = PBXNativeTarget; buildConfigurationList = 4700FFD06E10F0EE123A7B8B /* Build configuration list for PBXNativeTarget "Debug App Tests" */; buildPhases = ( - 1130539E7FE8944445055CB5 /* [CP] Check Pods Manifest.lock */, + 1553FF32D57BEA4D922D9F1D /* [CP] Check Pods Manifest.lock */, 1E0FCAD905F5F8F13B6A164B /* Sources */, 9CED4C4EFACB340F3C55B1F0 /* Resources */, D11E367C3560C383BC4CA0A7 /* Embed Frameworks */, @@ -435,13 +435,13 @@ isa = PBXNativeTarget; buildConfigurationList = CA98A6B11506835A81F6391A /* Build configuration list for PBXNativeTarget "Debug App" */; buildPhases = ( - F95E0F04FEDC53EFF22A8FAD /* [CP] Check Pods Manifest.lock */, + 480368A876AD9A07D7D4341F /* [CP] Check Pods Manifest.lock */, 66BB6A7BADD3A9CDD6412CE2 /* Sources */, 10FBAAC827CE0E3983CD7597 /* Resources */, 73B416AD9A0CB3B0EA16AF79 /* Embed Frameworks */, CB612F7DF16CD3190025327F /* Frameworks */, A18BD8BD2AFE4B0900923C87 /* SwiftLint */, - B23FED1E6EB620606C7965BB /* [CP] Embed Pods Frameworks */, + C0776B16C5A20C5E1F9A7A8E /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -522,7 +522,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 1130539E7FE8944445055CB5 /* [CP] Check Pods Manifest.lock */ = { + 1553FF32D57BEA4D922D9F1D /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -544,62 +544,62 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - A18BD8BD2AFE4B0900923C87 /* SwiftLint */ = { + 480368A876AD9A07D7D4341F /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); - name = SwiftLint; + name = "[CP] Check Pods Manifest.lock"; outputFileListPaths = ( ); outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Debug App-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\nif which swiftlint > /dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; }; - B23FED1E6EB620606C7965BB /* [CP] Embed Pods Frameworks */ = { + A18BD8BD2AFE4B0900923C87 /* SwiftLint */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Debug App/Pods-Debug App-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Embed Pods Frameworks"; + inputPaths = ( + ); + name = SwiftLint; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Debug App/Pods-Debug App-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Debug App/Pods-Debug App-frameworks.sh\"\n"; - showEnvVarsInLog = 0; + shellScript = "if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\nif which swiftlint > /dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; }; - F95E0F04FEDC53EFF22A8FAD /* [CP] Check Pods Manifest.lock */ = { + C0776B16C5A20C5E1F9A7A8E /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Debug App/Pods-Debug App-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; + name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Debug App-checkManifestLockResult.txt", + "${PODS_ROOT}/Target Support Files/Pods-Debug App/Pods-Debug App-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Debug App/Pods-Debug App-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -724,7 +724,7 @@ /* Begin XCBuildConfiguration section */ 313E094F25A94116E340B043 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = BB7C19D2A72C70B70AA4DF8C /* Pods-Debug App.debug.xcconfig */; + baseConfigurationReference = A226AFCE5F67A270D5CD1A7A /* Pods-Debug App.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/ExampleApp.entitlements"; @@ -759,7 +759,7 @@ }; 44381669975E0C07E78FA641 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 1F278229D66AFE30C9C39085 /* Pods-Debug App.release.xcconfig */; + baseConfigurationReference = 31523817971E2C6BC9635F49 /* Pods-Debug App.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/ExampleApp.entitlements"; @@ -793,7 +793,7 @@ }; 5434DA74E34D2EBEBD3D74C7 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 27B211EA3949D1672A82B5F6 /* Pods-Debug App Tests.debug.xcconfig */; + baseConfigurationReference = F285660C7775AB2AD591744D /* Pods-Debug App Tests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_IDENTITY = "iPhone Developer"; @@ -876,7 +876,7 @@ }; F10A44A87CE1B40DAFF5D30F /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 85AFC960D1A9EB56C4561471 /* Pods-Debug App Tests.release.xcconfig */; + baseConfigurationReference = BF7765EA0354CB6AEB6DCDF0 /* Pods-Debug App Tests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_IDENTITY = "iPhone Developer"; diff --git a/Debug App/Sources/AppDelegate.swift b/Debug App/Sources/AppDelegate.swift index 395b24a62e..92439f28cb 100644 --- a/Debug App/Sources/AppDelegate.swift +++ b/Debug App/Sources/AppDelegate.swift @@ -29,7 +29,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { if let url = userActivity.webpageURL { let handled = AppetizeUrlHandler.handleUrl(url) - if handled == true { + if handled { return handled } } diff --git a/Debug App/Sources/Model/CreateClientToken.swift b/Debug App/Sources/Model/CreateClientToken.swift index 362f91e906..030ae6f82b 100644 --- a/Debug App/Sources/Model/CreateClientToken.swift +++ b/Debug App/Sources/Model/CreateClientToken.swift @@ -433,7 +433,7 @@ struct ClientSessionRequestBody { dic["extraMerchantData"] = extraMerchantData } - if let captureVaultedCardCvv = captureVaultedCardCvv, captureVaultedCardCvv == true { + if let captureVaultedCardCvv = captureVaultedCardCvv, captureVaultedCardCvv { dic["captureVaultedCardCvv"] = captureVaultedCardCvv } diff --git a/Debug App/Sources/Utilities/AppetizeConfigProvider.swift b/Debug App/Sources/Utilities/AppetizeConfigProvider.swift index 7def43e9c4..f5c6b6ad82 100644 --- a/Debug App/Sources/Utilities/AppetizeConfigProvider.swift +++ b/Debug App/Sources/Utilities/AppetizeConfigProvider.swift @@ -24,7 +24,7 @@ class AppetizeConfigProvider { } func fetchConfig() -> SessionConfiguration? { - guard payloadProvider.isAppetize == true, + guard let isAppetize = payloadProvider.isAppetize, isAppetize, let jwt = payloadProvider.configJwt, let config = getConfig(from: jwt) else { return nil diff --git a/Debug App/Sources/View Controllers/MerchantSessionAndSettingsViewController.swift b/Debug App/Sources/View Controllers/MerchantSessionAndSettingsViewController.swift index 90ec974365..eb1ed68bfc 100644 --- a/Debug App/Sources/View Controllers/MerchantSessionAndSettingsViewController.swift +++ b/Debug App/Sources/View Controllers/MerchantSessionAndSettingsViewController.swift @@ -445,7 +445,7 @@ class MerchantSessionAndSettingsViewController: UIViewController { func populateSessionSettingsFields() { clientSession = MerchantMockDataManager.getClientSession(sessionType: paymentSessionType) - enableCVVRecaptureFlowSwitch.isOn = clientSession.paymentMethod?.options?.PAYMENT_CARD?.captureVaultedCardCvv == true + enableCVVRecaptureFlowSwitch.isOn = clientSession.paymentMethod?.options?.PAYMENT_CARD?.captureVaultedCardCvv ?? false currencyTextField.text = clientSession.currencyCode?.code countryCodeTextField.text = clientSession.order?.countryCode?.rawValue diff --git a/Sources/PrimerSDK/Classes/Core/Connectivity/Connectivity.swift b/Sources/PrimerSDK/Classes/Core/Connectivity/Connectivity.swift index 4dda62445e..05ae36011f 100644 --- a/Sources/PrimerSDK/Classes/Core/Connectivity/Connectivity.swift +++ b/Sources/PrimerSDK/Classes/Core/Connectivity/Connectivity.swift @@ -39,7 +39,7 @@ internal class Connectivity { if needsConnection { return .none } if !isReachable { return .none } - if flags.contains(.isWWAN) == true { + if flags.contains(.isWWAN) { return .cellular } else { return .wifi diff --git a/Sources/PrimerSDK/Classes/Core/Models/BanksTokenizationComponent.swift b/Sources/PrimerSDK/Classes/Core/Models/BanksTokenizationComponent.swift index 8136ab7a4d..cc83b5aabf 100644 --- a/Sources/PrimerSDK/Classes/Core/Models/BanksTokenizationComponent.swift +++ b/Sources/PrimerSDK/Classes/Core/Models/BanksTokenizationComponent.swift @@ -449,7 +449,7 @@ final class BanksTokenizationComponent: NSObject, LogReporter { func handleDecodedClientTokenIfNeeded(_ decodedJWTToken: DecodedJWTToken) -> Promise { return Promise { seal in - if decodedJWTToken.intent?.contains("_REDIRECTION") == true { + if let intent = decodedJWTToken.intent, intent.contains("_REDIRECTION") { if let redirectUrlStr = decodedJWTToken.redirectUrl, let redirectUrl = URL(string: redirectUrlStr), let statusUrlStr = decodedJWTToken.statusUrl, diff --git a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionAuthorization.swift b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionAuthorization.swift index 790b59ffdc..c399dc13f4 100644 --- a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionAuthorization.swift +++ b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionAuthorization.swift @@ -64,14 +64,14 @@ extension PrimerHeadlessKlarnaComponent: PrimerKlarnaProviderAuthorizationDelega public func primerKlarnaWrapperAuthorized(approved: Bool, authToken: String?, finalizeRequired: Bool) { isFinalizationRequired = finalizeRequired if approved == false { - if finalizeRequired == true { + if finalizeRequired { let step = KlarnaStep.paymentSessionFinalizationRequired stepDelegate?.didReceiveStep(step: step) } else { createSessionError(.klarnaAuthorizationFailed) } } - if let authToken = authToken, approved == true { + if let authToken = authToken, approved { if PrimerInternal.shared.sdkIntegrationType == .headless { finalizeSession(token: authToken, fromAuthorization: true) } else { @@ -80,7 +80,7 @@ extension PrimerHeadlessKlarnaComponent: PrimerKlarnaProviderAuthorizationDelega self.stepDelegate?.didReceiveStep(step: step) } } - if finalizeRequired == true { + if finalizeRequired { let step = KlarnaStep.paymentSessionFinalizationRequired stepDelegate?.didReceiveStep(step: step) } diff --git a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionFinalization.swift b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionFinalization.swift index 8bd589b323..1fe22d53bd 100644 --- a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionFinalization.swift +++ b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionFinalization.swift @@ -28,7 +28,7 @@ extension PrimerHeadlessKlarnaComponent: PrimerKlarnaProviderFinalizationDelegat if approved == false { createSessionError(.klarnaFinalizationFailed) } - if let authToken = authToken, approved == true { + if let authToken = authToken, approved { if PrimerInternal.shared.sdkIntegrationType == .headless { finalizeSession(token: authToken, fromAuthorization: false) } else { diff --git a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/Payment Method Managers/CardComponentsManager.swift b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/Payment Method Managers/CardComponentsManager.swift index 7681aed3ca..a79bbca4ad 100644 --- a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/Payment Method Managers/CardComponentsManager.swift +++ b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/Payment Method Managers/CardComponentsManager.swift @@ -695,7 +695,7 @@ Make sure you call the decision handler otherwise the SDK will hang. seal.reject(err) } - } else if decodedJWTToken.intent?.contains("_REDIRECTION") == true { + } else if let intent = decodedJWTToken.intent, intent.contains("_REDIRECTION") { if let redirectUrlStr = decodedJWTToken.redirectUrl, let redirectUrl = URL(string: redirectUrlStr), let statusUrlStr = decodedJWTToken.statusUrl, diff --git a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/Payment Method Managers/RawDataManager.swift b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/Payment Method Managers/RawDataManager.swift index 9428b24259..0bd02c67a2 100644 --- a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/Payment Method Managers/RawDataManager.swift +++ b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/Payment Method Managers/RawDataManager.swift @@ -597,7 +597,7 @@ Make sure you call the decision handler otherwise the SDK will hang." seal.reject(err) } - } else if decodedJWTToken.intent?.contains("_REDIRECTION") == true { + } else if let intent = decodedJWTToken.intent, intent.contains("_REDIRECTION") { if let statusUrlStr = decodedJWTToken.statusUrl, let statusUrl = URL(string: statusUrlStr), decodedJWTToken.intent != nil { diff --git a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/VaultManager.swift b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/VaultManager.swift index 64b602eb5a..d3b6c111fa 100644 --- a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/VaultManager.swift +++ b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Managers/VaultManager.swift @@ -596,7 +596,7 @@ extension PrimerHeadlessUniversalCheckout { seal.reject(err) } - } else if decodedJWTToken.intent?.contains("_REDIRECTION") == true { + } else if let intent = decodedJWTToken.intent, intent.contains("_REDIRECTION") { if let statusUrlStr = decodedJWTToken.statusUrl, let statusUrl = URL(string: statusUrlStr), decodedJWTToken.intent != nil { diff --git a/Sources/PrimerSDK/Classes/Data Models/ClientToken.swift b/Sources/PrimerSDK/Classes/Data Models/ClientToken.swift index 8a2d950ab3..b272ee4030 100644 --- a/Sources/PrimerSDK/Classes/Data Models/ClientToken.swift +++ b/Sources/PrimerSDK/Classes/Data Models/ClientToken.swift @@ -229,7 +229,7 @@ struct DecodedJWTToken: Codable { try? container.encode(expDate?.timeIntervalSince1970, forKey: .expiration) try? container.encode(expDate?.timeIntervalSince1970, forKey: .exp) - if qrCode?.isHttpOrHttpsURL == true { + if let qrCode = qrCode, qrCode.isHttpOrHttpsURL { try? container.encode(qrCode, forKey: .qrCodeUrl) } else { try? container.encode(qrCode, forKey: .qrCode) diff --git a/Sources/PrimerSDK/Classes/Data Models/OrderItem.swift b/Sources/PrimerSDK/Classes/Data Models/OrderItem.swift index c2cb54fab0..6fa9c3826d 100644 --- a/Sources/PrimerSDK/Classes/Data Models/OrderItem.swift +++ b/Sources/PrimerSDK/Classes/Data Models/OrderItem.swift @@ -29,7 +29,7 @@ internal struct OrderItem: Codable { let tmpTaxAmount = taxAmount ?? 0 let tmpTotalOrderItemAmount = tmpAmount - tmpDiscountAmount + tmpTaxAmount - if AppState.current.currency?.isZeroDecimal == true { + if let currency = AppState.current.currency, currency.isZeroDecimal { applePayItemAmount = NSDecimalNumber(value: tmpTotalOrderItemAmount) } else { applePayItemAmount = NSDecimalNumber(value: tmpTotalOrderItemAmount).dividing(by: 100) diff --git a/Sources/PrimerSDK/Classes/Data Models/PrimerConfiguration.swift b/Sources/PrimerSDK/Classes/Data Models/PrimerConfiguration.swift index e6faab53d8..d9adaff2cf 100644 --- a/Sources/PrimerSDK/Classes/Data Models/PrimerConfiguration.swift +++ b/Sources/PrimerSDK/Classes/Data Models/PrimerConfiguration.swift @@ -114,7 +114,7 @@ extension Response.Body { let supportedNetworks = ApplePayUtils.supportedPKPaymentNetworks() var canMakePayment: Bool - if PrimerSettings.current.paymentMethodOptions.applePayOptions?.checkProvidedNetworks == true { + if let options = PrimerSettings.current.paymentMethodOptions.applePayOptions, options.checkProvidedNetworks { canMakePayment = PKPaymentAuthorizationController.canMakePayments(usingNetworks: supportedNetworks) } else { canMakePayment = PKPaymentAuthorizationController.canMakePayments() diff --git a/Sources/PrimerSDK/Classes/Extensions & Utilities/ImageFileProcessor.swift b/Sources/PrimerSDK/Classes/Extensions & Utilities/ImageFileProcessor.swift index 6e33846140..89bd3fbaa1 100644 --- a/Sources/PrimerSDK/Classes/Extensions & Utilities/ImageFileProcessor.swift +++ b/Sources/PrimerSDK/Classes/Extensions & Utilities/ImageFileProcessor.swift @@ -115,9 +115,9 @@ class ImageFileProcessor { let coloredImageFile = paymentMethodImageFiles .filter({ $0.fileName.contains("dark") == false && $0.fileName.contains("light") == false }).first let darkImageFile = paymentMethodImageFiles - .filter({ $0.fileName.contains("dark") == true }).first + .filter({ $0.fileName.contains("dark") }).first let lightImageFile = paymentMethodImageFiles - .filter({ $0.fileName.contains("light") == true }).first + .filter({ $0.fileName.contains("light") }).first let baseImage = PrimerTheme.BaseImage( colored: coloredImageFile?.image, diff --git a/Sources/PrimerSDK/Classes/Modules/ImageManager.swift b/Sources/PrimerSDK/Classes/Modules/ImageManager.swift index 4bf6911fa7..4db7f00b01 100644 --- a/Sources/PrimerSDK/Classes/Modules/ImageManager.swift +++ b/Sources/PrimerSDK/Classes/Modules/ImageManager.swift @@ -68,7 +68,7 @@ internal class ImageFile: File { var bundledImage: UIImage? { let paymentMethodType = ImageFile.getPaymentMethodType(fromFileName: self.fileName) ?? self.fileName - if self.fileName.contains("dark") == true { + if self.fileName.contains("dark") { if let paymentMethodLogoFileName = ImageFile.getBundledImageFileName(forPaymentMethodType: paymentMethodType, themeMode: .dark, assetType: .logo), @@ -81,7 +81,7 @@ internal class ImageFile: File { compatibleWith: nil) { return image } - } else if self.fileName.contains("light") == true { + } else if self.fileName.contains("light") { if let paymentMethodLogoFileName = ImageFile.getBundledImageFileName(forPaymentMethodType: paymentMethodType, themeMode: .light, assetType: .logo), @@ -94,7 +94,7 @@ internal class ImageFile: File { compatibleWith: nil) { return image } - } else if self.fileName.contains("colored") == true { + } else if self.fileName.contains("colored") { if let paymentMethodLogoFileName = ImageFile.getBundledImageFileName(forPaymentMethodType: paymentMethodType, themeMode: .colored, assetType: .logo), diff --git a/Sources/PrimerSDK/Classes/Modules/UserInterfaceModule.swift b/Sources/PrimerSDK/Classes/Modules/UserInterfaceModule.swift index bdd5b95a0d..58f2d360fb 100644 --- a/Sources/PrimerSDK/Classes/Modules/UserInterfaceModule.swift +++ b/Sources/PrimerSDK/Classes/Modules/UserInterfaceModule.swift @@ -1002,7 +1002,7 @@ class UserInterfaceModule: NSObject, UserInterfaceModuleProtocol { }() var isSubmitButtonAnimating: Bool { - submitButton?.isAnimating == true + submitButton?.isAnimating ?? false } // MARK: - INITIALIZATION diff --git a/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/CardFormPaymentMethodTokenizationViewModel.swift b/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/CardFormPaymentMethodTokenizationViewModel.swift index e8204c20be..7b4fe4b0a3 100644 --- a/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/CardFormPaymentMethodTokenizationViewModel.swift +++ b/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/CardFormPaymentMethodTokenizationViewModel.swift @@ -78,7 +78,7 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM .filter({ $0.type == "BILLING_ADDRESS" }) .first else { return false } let options = (billingAddressModule.options as? PrimerAPIConfiguration.CheckoutModule.PostalCodeOptions) - return options?.postalCode == true + return options?.postalCode ?? false } internal lazy var countrySelectorViewController: CountrySelectorViewController = { @@ -485,7 +485,7 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM override func handleDecodedClientTokenIfNeeded(_ decodedJWTToken: DecodedJWTToken) -> Promise { return Promise { seal in - if decodedJWTToken.intent?.contains("_REDIRECTION") == true { + if let intent = decodedJWTToken.intent, intent.contains("_REDIRECTION") { if let redirectUrlStr = decodedJWTToken.redirectUrl, let redirectUrl = URL(string: redirectUrlStr), let statusUrlStr = decodedJWTToken.statusUrl, @@ -753,14 +753,13 @@ extension CardFormPaymentMethodTokenizationViewModel: InternalCardComponentsMana } fileprivate func autofocusToNextFieldIfNeeded(for primerTextFieldView: PrimerTextFieldView, isValid: Bool?) { - if isValid == true { - if primerTextFieldView is PrimerCardNumberFieldView { - _ = expiryDateField.becomeFirstResponder() - } else if primerTextFieldView is PrimerExpiryDateFieldView { - _ = cvvField.becomeFirstResponder() - } else if primerTextFieldView is PrimerCVVFieldView { - _ = cardholderNameField?.becomeFirstResponder() - } + guard let isValid = isValid, isValid else { return } + if primerTextFieldView is PrimerCardNumberFieldView { + _ = expiryDateField.becomeFirstResponder() + } else if primerTextFieldView is PrimerExpiryDateFieldView { + _ = cvvField.becomeFirstResponder() + } else if primerTextFieldView is PrimerCVVFieldView { + _ = cardholderNameField?.becomeFirstResponder() } } @@ -849,7 +848,7 @@ extension CardFormPaymentMethodTokenizationViewModel: InternalCardComponentsMana if cardholderNameField != nil { validations.append(cardholderNameField!.isTextValid) } - if validations.allSatisfy({ $0 == true }) { + if validations.allSatisfy({ $0 }) { self.uiModule.submitButton?.isEnabled = true self.uiModule.submitButton?.backgroundColor = theme.mainButton.color(for: .enabled) } else { @@ -986,7 +985,7 @@ extension CardFormPaymentMethodTokenizationViewModel: UITextFieldDelegate { var countryResults: [CountryCode] = [] for country in countries where - country.country.lowercasedAndFolded().contains(query.lowercasedAndFolded()) == true { + country.country.lowercasedAndFolded().contains(query.lowercasedAndFolded()) { countryResults.append(country) } diff --git a/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/FormPaymentMethodTokenizationViewModel.swift b/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/FormPaymentMethodTokenizationViewModel.swift index ded9a8b316..6e3fc6f8b9 100644 --- a/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/FormPaymentMethodTokenizationViewModel.swift +++ b/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/FormPaymentMethodTokenizationViewModel.swift @@ -569,14 +569,14 @@ class FormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewModel override func handleDecodedClientTokenIfNeeded(_ decodedJWTToken: DecodedJWTToken) -> Promise { return Promise { seal in - if decodedJWTToken.intent?.contains("_REDIRECTION") == true { + if let intent = decodedJWTToken.intent, intent.contains("_REDIRECTION") { if let statusUrlStr = decodedJWTToken.statusUrl, let statusUrl = URL(string: statusUrlStr), decodedJWTToken.intent != nil { let paymentMethodType = PrimerPaymentMethodType(rawValue: self.config.type) let isPaymentMethodNeedingExternalCompletion = (needingExternalCompletionPaymentMethodDictionary - .first { $0.key == paymentMethodType } != nil) == true + .first { $0.key == paymentMethodType } != nil) firstly { self.presentPaymentMethodAppropriateViewController(shouldCompletePaymentExternally: isPaymentMethodNeedingExternalCompletion) @@ -916,7 +916,7 @@ extension FormPaymentMethodTokenizationViewModel: PrimerTextFieldViewDelegate { func primerTextFieldViewDidBeginEditing(_ primerTextFieldView: PrimerTextFieldView) {} func primerTextFieldView(_ primerTextFieldView: PrimerTextFieldView, isValid: Bool?) { - let isTextsValid = inputs.allSatisfy { $0.primerTextFieldView?.isTextValid == true } + let isTextsValid = inputs.allSatisfy { $0.primerTextFieldView?.isTextValid ?? false } if isTextsValid { enableSubmitButton(true) } else { @@ -995,7 +995,7 @@ extension FormPaymentMethodTokenizationViewModel: UITextFieldDelegate { locale: nil) .contains(query.lowercased() .folding(options: .diacriticInsensitive, - locale: nil)) == true { + locale: nil)) { countryResults.append(country) } diff --git a/Sources/PrimerSDK/Classes/PCI/User Interface/Text Fields/PrimerCardholderNameFieldView.swift b/Sources/PrimerSDK/Classes/PCI/User Interface/Text Fields/PrimerCardholderNameFieldView.swift index 5cff0bab83..ea4ad8908d 100644 --- a/Sources/PrimerSDK/Classes/PCI/User Interface/Text Fields/PrimerCardholderNameFieldView.swift +++ b/Sources/PrimerSDK/Classes/PCI/User Interface/Text Fields/PrimerCardholderNameFieldView.swift @@ -30,7 +30,7 @@ public final class PrimerCardholderNameFieldView: PrimerSimpleCardFormTextFieldV } public override func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { - guard string.isValidNonDecimalString == true || string.isEmpty else { return false } + guard string.isValidNonDecimalString || string.isEmpty else { return false } return super.textField(textField, shouldChangeCharactersIn: range, replacementString: string) } } diff --git a/Sources/PrimerSDK/Classes/User Interface/Root/CVVRecapture/CVVRecaptureViewController.swift b/Sources/PrimerSDK/Classes/User Interface/Root/CVVRecapture/CVVRecaptureViewController.swift index c7a0c7ed0a..ba0e355246 100644 --- a/Sources/PrimerSDK/Classes/User Interface/Root/CVVRecapture/CVVRecaptureViewController.swift +++ b/Sources/PrimerSDK/Classes/User Interface/Root/CVVRecapture/CVVRecaptureViewController.swift @@ -60,10 +60,11 @@ class CVVRecaptureViewController: UIViewController { private func bindViewModel() { viewModel.onContinueButtonStateChange = { [weak self] isEnabled in - if self?.continueButton.isAnimating == true { return } - self?.continueButton.isEnabled = isEnabled - let continueButtonColor = self?.theme.mainButton.color(for: isEnabled ? .enabled : .disabled) - self?.continueButton.backgroundColor = continueButtonColor + guard let self = self else { return } + if self.continueButton.isAnimating { return } + self.continueButton.isEnabled = isEnabled + let continueButtonColor = self.theme.mainButton.color(for: isEnabled ? .enabled : .disabled) + self.continueButton.backgroundColor = continueButtonColor } } diff --git a/Sources/PrimerSDK/Classes/User Interface/Root/PrimerFormViewController.swift b/Sources/PrimerSDK/Classes/User Interface/Root/PrimerFormViewController.swift index d5ef3658e2..61bc1cab1d 100644 --- a/Sources/PrimerSDK/Classes/User Interface/Root/PrimerFormViewController.swift +++ b/Sources/PrimerSDK/Classes/User Interface/Root/PrimerFormViewController.swift @@ -67,7 +67,7 @@ class PrimerFormViewController: PrimerViewController { .filter({ $0.config.hasUnknownSurcharge == false && ($0.config.surcharge ?? 0) != 0 }) // Unknown surcharge fee let unknownFeePaymentMethodsViewModels = paymentMethodTokenizationViewModels - .filter({ $0.config.hasUnknownSurcharge == true }) + .filter({ $0.config.hasUnknownSurcharge }) if !noAdditionalFeePaymentMethodsViewModels.isEmpty, additionalFeePaymentMethodsViewModels.isEmpty, diff --git a/Sources/PrimerSDK/Classes/User Interface/Root/PrimerUniversalCheckoutViewController.swift b/Sources/PrimerSDK/Classes/User Interface/Root/PrimerUniversalCheckoutViewController.swift index 39269ef050..200a945161 100644 --- a/Sources/PrimerSDK/Classes/User Interface/Root/PrimerUniversalCheckoutViewController.swift +++ b/Sources/PrimerSDK/Classes/User Interface/Root/PrimerUniversalCheckoutViewController.swift @@ -292,7 +292,7 @@ internal class PrimerUniversalCheckoutViewController: PrimerFormViewController { Analytics.Service.record(event: viewEvent) if let captureVaultedCardCvv = (config.options as? CardOptions)?.captureVaultedCardCvv, - captureVaultedCardCvv == true, + captureVaultedCardCvv, config.internalPaymentMethodType == .paymentCard { let cvvViewController = CVVRecaptureViewController(viewModel: CVVRecaptureViewModel()) cvvViewController.viewModel.cardButtonViewModel = cardButtonViewModel diff --git a/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerFirstNameFieldView.swift b/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerFirstNameFieldView.swift index 8fe1b25bcb..815189bf8d 100644 --- a/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerFirstNameFieldView.swift +++ b/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerFirstNameFieldView.swift @@ -23,7 +23,7 @@ public final class PrimerFirstNameFieldView: PrimerSimpleCardFormTextFieldView { } public override func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { - guard string.isValidNonDecimalString == true || string.isEmpty else { return false } + guard string.isValidNonDecimalString || string.isEmpty else { return false } return super.textField(textField, shouldChangeCharactersIn: range, replacementString: string) } } diff --git a/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerLastNameFieldView.swift b/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerLastNameFieldView.swift index 349d7ab5e5..8392bc7874 100644 --- a/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerLastNameFieldView.swift +++ b/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerLastNameFieldView.swift @@ -23,7 +23,7 @@ public final class PrimerLastNameFieldView: PrimerSimpleCardFormTextFieldView { } public override func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { - guard string.isValidNonDecimalString == true || string.isEmpty else { return false } + guard string.isValidNonDecimalString || string.isEmpty else { return false } return super.textField(textField, shouldChangeCharactersIn: range, replacementString: string) } } diff --git a/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerStateFieldView.swift b/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerStateFieldView.swift index 4ba82b05d3..42065addb7 100644 --- a/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerStateFieldView.swift +++ b/Sources/PrimerSDK/Classes/User Interface/Text Fields/PrimerStateFieldView.swift @@ -23,7 +23,7 @@ public final class PrimerStateFieldView: PrimerSimpleCardFormTextFieldView { } public override func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { - guard string.isValidNonDecimalString == true || string.isEmpty else { return false } + guard string.isValidNonDecimalString || string.isEmpty else { return false } return super.textField(textField, shouldChangeCharactersIn: range, replacementString: string) } } diff --git a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewControllers/QRCodeViewController.swift b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewControllers/QRCodeViewController.swift index b2404bb48a..42706f7daf 100644 --- a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewControllers/QRCodeViewController.swift +++ b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewControllers/QRCodeViewController.swift @@ -100,7 +100,7 @@ internal class QRCodeViewController: PrimerFormViewController { separatorView.heightAnchor.constraint(equalToConstant: 10).isActive = true var qrCodeImageView = PrimerImageView() - if qrCodeStr.isHttpOrHttpsURL == true, let qrCodeURL = URL(string: qrCodeStr) { + if qrCodeStr.isHttpOrHttpsURL, let qrCodeURL = URL(string: qrCodeStr) { qrCodeImageView = PrimerImageView(from: qrCodeURL) } else if let qrCodeImg = convertBase64StringToImage(qrCodeStr) { qrCodeImageView.image = qrCodeImg diff --git a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/ApplePayTokenizationViewModel.swift b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/ApplePayTokenizationViewModel.swift index b96a6c7af5..43fac20c7c 100644 --- a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/ApplePayTokenizationViewModel.swift +++ b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/ApplePayTokenizationViewModel.swift @@ -220,7 +220,7 @@ class ApplePayTokenizationViewModel: PaymentMethodTokenizationViewModel { let supportedNetworks = ApplePayUtils.supportedPKPaymentNetworks() var canMakePayment: Bool - if PrimerSettings.current.paymentMethodOptions.applePayOptions?.checkProvidedNetworks == true { + if let options = PrimerSettings.current.paymentMethodOptions.applePayOptions, options.checkProvidedNetworks { canMakePayment = PKPaymentAuthorizationController.canMakePayments(usingNetworks: supportedNetworks) } else { canMakePayment = PKPaymentAuthorizationController.canMakePayments() @@ -229,7 +229,7 @@ class ApplePayTokenizationViewModel: PaymentMethodTokenizationViewModel { if canMakePayment { let request = PKPaymentRequest() let applePayOptions = PrimerSettings.current.paymentMethodOptions.applePayOptions - let isBillingContactFieldsRequired = applePayOptions?.isCaptureBillingAddressEnabled == true + let isBillingContactFieldsRequired = applePayOptions?.isCaptureBillingAddressEnabled ?? false request.requiredBillingContactFields = isBillingContactFieldsRequired ? [.postalAddress] : [] request.currencyCode = applePayRequest.currency.code request.countryCode = applePayRequest.countryCode.rawValue @@ -263,7 +263,7 @@ class ApplePayTokenizationViewModel: PaymentMethodTokenizationViewModel { } else { let errorMessage = "Cannot run ApplePay on this device" - if PrimerSettings.current.paymentMethodOptions.applePayOptions?.checkProvidedNetworks == true { + if let options = PrimerSettings.current.paymentMethodOptions.applePayOptions, options.checkProvidedNetworks { self.logger.error(message: "APPLE PAY") self.logger.error(message: errorMessage) let err = PrimerError.unableToMakePaymentsOnProvidedNetworks(userInfo: .errorUserInfoDictionary(), diff --git a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/NolPayTokenizationViewModel.swift b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/NolPayTokenizationViewModel.swift index a2bc895f05..5c4afdbeb5 100644 --- a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/NolPayTokenizationViewModel.swift +++ b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/NolPayTokenizationViewModel.swift @@ -242,7 +242,7 @@ class NolPayTokenizationViewModel: PaymentMethodTokenizationViewModel { override func handleDecodedClientTokenIfNeeded(_ decodedJWTToken: DecodedJWTToken) -> Promise { return Promise { seal in - if decodedJWTToken.intent?.contains("NOL_PAY_REDIRECTION") == true { + if let intent = decodedJWTToken.intent, intent.contains("NOL_PAY_REDIRECTION") { if let transactionNo = decodedJWTToken.nolPayTransactionNo, let redirectUrlStr = decodedJWTToken.redirectUrl, let redirectUrl = URL(string: redirectUrlStr), diff --git a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/WebRedirectPaymentMethodTokenizationViewModel.swift b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/WebRedirectPaymentMethodTokenizationViewModel.swift index 33aef8b9a0..11e4be523c 100644 --- a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/WebRedirectPaymentMethodTokenizationViewModel.swift +++ b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/WebRedirectPaymentMethodTokenizationViewModel.swift @@ -324,7 +324,7 @@ class WebRedirectPaymentMethodTokenizationViewModel: PaymentMethodTokenizationVi override func handleDecodedClientTokenIfNeeded(_ decodedJWTToken: DecodedJWTToken) -> Promise { return Promise { seal in - if decodedJWTToken.intent?.contains("_REDIRECTION") == true { + if let intent = decodedJWTToken.intent, intent.contains("_REDIRECTION") { if let redirectUrlStr = decodedJWTToken.redirectUrl, let redirectUrl = URL(string: redirectUrlStr), let statusUrlStr = decodedJWTToken.statusUrl, diff --git a/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift b/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift index 141239cfe8..47a9def50a 100644 --- a/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift +++ b/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift @@ -426,7 +426,7 @@ final class HUC_TokenizationViewModelTests: XCTestCase { } } - if paymentMethod.paymentMethodManagerCategories?.contains(.nativeUI) == true { + if paymentMethod.paymentMethodManagerCategories?.contains(.nativeUI) { do { let paymentMethodNativeUIManager = try PrimerHeadlessUniversalCheckout.NativeUIManager(paymentMethodType: paymentMethod.type) try paymentMethodNativeUIManager.showPaymentMethod(intent: .checkout) @@ -436,7 +436,7 @@ final class HUC_TokenizationViewModelTests: XCTestCase { expectation.fulfill() } - } else if paymentMethod.paymentMethodManagerCategories?.contains(.rawData) == true { + } else if paymentMethod.paymentMethodManagerCategories?.contains(.rawData) { do { let rawDataManager = try PrimerHeadlessUniversalCheckout.RawDataManager(paymentMethodType: paymentMethod.type, delegate: self) diff --git a/Tests/Unit Tests/Network/Legacy/URLSessionStackTests.swift b/Tests/Unit Tests/Network/Legacy/URLSessionStackTests.swift index dc9282b0a4..1b5f561027 100644 --- a/Tests/Unit Tests/Network/Legacy/URLSessionStackTests.swift +++ b/Tests/Unit Tests/Network/Legacy/URLSessionStackTests.swift @@ -53,8 +53,8 @@ final class URLSessionStackTests: XCTestCase { func testQueryParameters() { let endpoint = DummyEndpoint(baseURL: "https://www.example.com", queryParameters: ["key1": "value1", "key2": "value2"]) let url = sut.url(for: endpoint) - XCTAssertTrue(url?.absoluteString.contains("key1=value1") == true) - XCTAssertTrue(url?.absoluteString.contains("key2=value2") == true) + XCTAssertTrue(url?.absoluteString.contains("key1=value1")) + XCTAssertTrue(url?.absoluteString.contains("key2=value2")) } // Test for nil base URL @@ -75,8 +75,8 @@ final class URLSessionStackTests: XCTestCase { func testQueryParametersWithEmptyPath() { let endpoint = DummyEndpoint(baseURL: "https://www.example.com", path: "", queryParameters: ["key1": "value1", "key2": "value2"]) let url = sut.url(for: endpoint) - XCTAssertTrue(url?.absoluteString.contains("key1=value1") == true) - XCTAssertTrue(url?.absoluteString.contains("key2=value2") == true) + XCTAssertTrue(url?.absoluteString.contains("key1=value1")) + XCTAssertTrue(url?.absoluteString.contains("key2=value2")) } // Test that /sdk-logs and polling endpoints are omitted from network analytics reporting diff --git a/Tests/Unit Tests/Primer/NolPay/NolPayUnlinkCardComponentTest.swift b/Tests/Unit Tests/Primer/NolPay/NolPayUnlinkCardComponentTest.swift index c156e311ff..e68bbe1e57 100644 --- a/Tests/Unit Tests/Primer/NolPay/NolPayUnlinkCardComponentTest.swift +++ b/Tests/Unit Tests/Primer/NolPay/NolPayUnlinkCardComponentTest.swift @@ -48,7 +48,7 @@ final class NolPayUnlinkCardComponentTest: XCTestCase { XCTAssertNotNil(mockValidationDelegate.validationsReceived, "No validations received.") if case let .invalid(errors: errors) = mockValidationDelegate.validationsReceived { - XCTAssertTrue(errors.contains(where: { $0.errorId == "invalid-phone-number" }) == true, "Expected invalid phone number validation error.") + XCTAssertTrue(errors.contains(where: { $0.errorId == "invalid-phone-number" }), "Expected invalid phone number validation error.") } else { XCTFail("Expected validation error") } diff --git a/Tests/Unit Tests/Utils/WebViewUtilTests.swift b/Tests/Unit Tests/Utils/WebViewUtilTests.swift index 92e74746db..aa291c4bf3 100644 --- a/Tests/Unit Tests/Utils/WebViewUtilTests.swift +++ b/Tests/Unit Tests/Utils/WebViewUtilTests.swift @@ -17,7 +17,7 @@ class WebViewUtilTests: XCTestCase { WebViewUtil.allowedHostsContain("app.primer.io"), WebViewUtil.allowedHostsContain("livedemostore.primer.io") ] - XCTAssertTrue(allowedPatterns.allSatisfy { $0 == true }) + XCTAssertTrue(allowedPatterns.allSatisfy { $0 }) } func test_disallowed_patterns_return_false() throws { From 2d7d7208b56946ae397370c60fb57c660243fb39 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 16:11:47 +0100 Subject: [PATCH 02/26] Remove all 'value == false' instances --- .../xcschemes/PrimerSDKTests.xcscheme | 5 -- ...KlarnaComponent+SessionAuthorization.swift | 2 +- ...sKlarnaComponent+SessionFinalization.swift | 2 +- .../EncodingDecodingContainerExtensions.swift | 6 +-- .../ImageFileProcessor.swift | 2 +- .../Modules/ClientSessionActionsModule.swift | 4 +- .../Network/Legacy/URLSessionStack.swift | 2 +- ...rmPaymentMethodTokenizationViewModel.swift | 26 +++++----- ...rmPaymentMethodTokenizationViewModel.swift | 20 ++++---- .../InternalCardComponentsManager.swift | 2 +- .../User Interface/PrimerUIManager.swift | 4 +- .../Root/PrimerFormViewController.swift | 4 +- .../ApplePayTokenizationViewModel.swift | 2 +- .../QRCodeTokenizationViewModel.swift | 2 +- .../HUC_TokenizationViewModelTests.swift | 50 +++++++++++-------- .../Network/Legacy/URLSessionStackTests.swift | 8 +-- Tests/Unit Tests/Utils/WebViewUtilTests.swift | 2 +- 17 files changed, 72 insertions(+), 71 deletions(-) diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/PrimerSDKTests.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/PrimerSDKTests.xcscheme index a026ae7f37..c80078874c 100644 --- a/.swiftpm/xcode/xcshareddata/xcschemes/PrimerSDKTests.xcscheme +++ b/.swiftpm/xcode/xcshareddata/xcschemes/PrimerSDKTests.xcscheme @@ -34,11 +34,6 @@ BlueprintName = "PrimerSDKTests" ReferencedContainer = "container:"> - - - - diff --git a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionAuthorization.swift b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionAuthorization.swift index c399dc13f4..4381ac7cc8 100644 --- a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionAuthorization.swift +++ b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionAuthorization.swift @@ -63,7 +63,7 @@ extension PrimerHeadlessKlarnaComponent: PrimerKlarnaProviderAuthorizationDelega */ public func primerKlarnaWrapperAuthorized(approved: Bool, authToken: String?, finalizeRequired: Bool) { isFinalizationRequired = finalizeRequired - if approved == false { + if approved { if finalizeRequired { let step = KlarnaStep.paymentSessionFinalizationRequired stepDelegate?.didReceiveStep(step: step) diff --git a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionFinalization.swift b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionFinalization.swift index 1fe22d53bd..ebd09f5a9f 100644 --- a/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionFinalization.swift +++ b/Sources/PrimerSDK/Classes/Core/PrimerHeadlessUniversalCheckout/Composable/Klarna/Components/PrimerHeadlessKlarnaComponent+SessionFinalization.swift @@ -25,7 +25,7 @@ extension PrimerHeadlessKlarnaComponent: PrimerKlarnaProviderFinalizationDelegat * - `authToken` - An optional `String` containing the authorization token, which is returned only if `approved` is `true`. */ public func primerKlarnaWrapperFinalized(approved: Bool, authToken: String?) { - if approved == false { + if approved { createSessionError(.klarnaFinalizationFailed) } if let authToken = authToken, approved { diff --git a/Sources/PrimerSDK/Classes/Extensions & Utilities/EncodingDecodingContainerExtensions.swift b/Sources/PrimerSDK/Classes/Extensions & Utilities/EncodingDecodingContainerExtensions.swift index e81f56ff30..4cb490b9b2 100644 --- a/Sources/PrimerSDK/Classes/Extensions & Utilities/EncodingDecodingContainerExtensions.swift +++ b/Sources/PrimerSDK/Classes/Extensions & Utilities/EncodingDecodingContainerExtensions.swift @@ -70,7 +70,7 @@ extension KeyedDecodingContainer { guard contains(key) else { return nil } - guard try decodeNil(forKey: key) == false else { + guard try decodeNil(forKey: key) else { return nil } return try decode(type, forKey: key) @@ -85,7 +85,7 @@ extension KeyedDecodingContainer { guard contains(key) else { return nil } - guard try decodeNil(forKey: key) == false else { + guard try decodeNil(forKey: key) else { return nil } return try decode(type, forKey: key) @@ -117,7 +117,7 @@ extension UnkeyedDecodingContainer { mutating func decode(_ type: Array.Type) throws -> [Any] { var array: [Any] = [] - while isAtEnd == false { + while isAtEnd { // See if the current value in the JSON array is `null` first and prevent infite recursion with nested arrays. if try decodeNil() { continue diff --git a/Sources/PrimerSDK/Classes/Extensions & Utilities/ImageFileProcessor.swift b/Sources/PrimerSDK/Classes/Extensions & Utilities/ImageFileProcessor.swift index 89bd3fbaa1..53275f27a2 100644 --- a/Sources/PrimerSDK/Classes/Extensions & Utilities/ImageFileProcessor.swift +++ b/Sources/PrimerSDK/Classes/Extensions & Utilities/ImageFileProcessor.swift @@ -113,7 +113,7 @@ class ImageFileProcessor { } let coloredImageFile = paymentMethodImageFiles - .filter({ $0.fileName.contains("dark") == false && $0.fileName.contains("light") == false }).first + .filter({ $0.fileName.contains("dark") && $0.fileName.contains("light") }).first let darkImageFile = paymentMethodImageFiles .filter({ $0.fileName.contains("dark") }).first let lightImageFile = paymentMethodImageFiles diff --git a/Sources/PrimerSDK/Classes/Modules/ClientSessionActionsModule.swift b/Sources/PrimerSDK/Classes/Modules/ClientSessionActionsModule.swift index e2a3e16cd5..6fa7d0f836 100644 --- a/Sources/PrimerSDK/Classes/Modules/ClientSessionActionsModule.swift +++ b/Sources/PrimerSDK/Classes/Modules/ClientSessionActionsModule.swift @@ -23,7 +23,7 @@ class ClientSessionActionsModule: ClientSessionActionsProtocol { return } - if (PrimerAPIConfigurationModule.apiConfiguration?.hasSurchargeEnabled ?? false) == false { + if (PrimerAPIConfigurationModule.apiConfiguration?.hasSurchargeEnabled ?? false) { seal.fulfill() return } @@ -65,7 +65,7 @@ class ClientSessionActionsModule: ClientSessionActionsProtocol { return } - if (PrimerAPIConfigurationModule.apiConfiguration?.hasSurchargeEnabled ?? false) == false { + if (PrimerAPIConfigurationModule.apiConfiguration?.hasSurchargeEnabled ?? false) { seal.fulfill() return } diff --git a/Sources/PrimerSDK/Classes/PCI/Services/Network/Legacy/URLSessionStack.swift b/Sources/PrimerSDK/Classes/PCI/Services/Network/Legacy/URLSessionStack.swift index 854eb67774..742381ae7d 100644 --- a/Sources/PrimerSDK/Classes/PCI/Services/Network/Legacy/URLSessionStack.swift +++ b/Sources/PrimerSDK/Classes/PCI/Services/Network/Legacy/URLSessionStack.swift @@ -179,7 +179,7 @@ internal class URLSessionStack: NetworkService, LogReporter { } #endif - if endpoint.shouldParseResponseBody == false, httpResponse?.statusCode == 200 { + if endpoint.shouldParseResponseBody , httpResponse?.statusCode == 200 { guard let dummyRes: T = DummySuccess(success: true) as? T else { fatalError() diff --git a/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/CardFormPaymentMethodTokenizationViewModel.swift b/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/CardFormPaymentMethodTokenizationViewModel.swift index 7b4fe4b0a3..4b1e9e4695 100644 --- a/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/CardFormPaymentMethodTokenizationViewModel.swift +++ b/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/CardFormPaymentMethodTokenizationViewModel.swift @@ -130,7 +130,7 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM // MARK: - Billing address private var countryField: BillingAddressField { - (countryFieldView, countryFieldContainerView, billingAddressCheckoutModuleOptions?.countryCode == false) + (countryFieldView, countryFieldContainerView, billingAddressCheckoutModuleOptions?.countryCode ?? true) } // MARK: First name @@ -144,7 +144,7 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM }() private var firstNameField: BillingAddressField { - (firstNameFieldView, firstNameContainerView, billingAddressCheckoutModuleOptions?.firstName == false) + (firstNameFieldView, firstNameContainerView, billingAddressCheckoutModuleOptions?.firstName ?? true) } // MARK: Last name @@ -158,7 +158,7 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM }() private var lastNameField: BillingAddressField { - (lastNameFieldView, lastNameContainerView, billingAddressCheckoutModuleOptions?.lastName == false) + (lastNameFieldView, lastNameContainerView, billingAddressCheckoutModuleOptions?.lastName ?? true) } // MARK: Address Line 1 @@ -172,7 +172,7 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM }() private var addressLine1Field: BillingAddressField { - (addressLine1FieldView, addressLine1ContainerView, billingAddressCheckoutModuleOptions?.addressLine1 == false) + (addressLine1FieldView, addressLine1ContainerView, billingAddressCheckoutModuleOptions?.addressLine1 ?? true) } // MARK: Address Line 2 @@ -186,7 +186,7 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM }() private var addressLine2Field: BillingAddressField { - (addressLine2FieldView, addressLine2ContainerView, billingAddressCheckoutModuleOptions?.addressLine2 == false) + (addressLine2FieldView, addressLine2ContainerView, billingAddressCheckoutModuleOptions?.addressLine2 ?? true) } // MARK: Postal code @@ -200,7 +200,7 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM }() private var postalCodeField: BillingAddressField { - (postalCodeFieldView, postalCodeContainerView, billingAddressCheckoutModuleOptions?.postalCode == false) + (postalCodeFieldView, postalCodeContainerView, billingAddressCheckoutModuleOptions?.postalCode ?? true) } // MARK: City @@ -214,7 +214,7 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM }() private var cityField: BillingAddressField { - (cityFieldView, cityContainerView, billingAddressCheckoutModuleOptions?.city == false) + (cityFieldView, cityContainerView, billingAddressCheckoutModuleOptions?.city ?? true) } // MARK: State @@ -228,7 +228,7 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM }() private var stateField: BillingAddressField { - (stateFieldView, stateContainerView, billingAddressCheckoutModuleOptions?.state == false) + (stateFieldView, stateContainerView, billingAddressCheckoutModuleOptions?.state ?? true) } // MARK: Country @@ -266,12 +266,12 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM } internal var allVisibleBillingAddressFieldViews: [PrimerTextFieldView] { - billingAddressFields.flatMap { $0.filter { $0.isFieldHidden == false } }.map { $0.fieldView } + billingAddressFields.flatMap { $0.filter { $0.isFieldHidden } }.map { $0.fieldView } } // swiftlint:disable:next identifier_name internal var allVisibleBillingAddressFieldContainerViews: [[PrimerCustomFieldView]] { - let allVisibleBillingAddressFields = billingAddressFields.map { $0.filter { $0.isFieldHidden == false } } + let allVisibleBillingAddressFields = billingAddressFields.map { $0.filter { $0.isFieldHidden } } return allVisibleBillingAddressFields.map { $0.map { $0.containerFieldView } } } @@ -765,8 +765,8 @@ extension CardFormPaymentMethodTokenizationViewModel: InternalCardComponentsMana // swiftlint:disable cyclomatic_complexity fileprivate func showTexfieldViewErrorIfNeeded(for primerTextFieldView: PrimerTextFieldView, isValid: Bool?) { - - if isValid == false { + + if let isValid = isValid, !isValid { // We know for sure that the text is not valid, even if the user hasn't finished typing. if primerTextFieldView is PrimerCardNumberFieldView, !primerTextFieldView.isEmpty { cardNumberContainerView.errorText = Strings.CardFormView.CardNumber.invalidErrorMessage @@ -909,7 +909,7 @@ extension CardFormPaymentMethodTokenizationViewModel: PrimerTextFieldViewDelegat extension CardFormPaymentMethodTokenizationViewModel { private func updateButtonUI() { - if let amount = AppState.current.amount, self.uiModule.isSubmitButtonAnimating == false { + if let amount = AppState.current.amount, self.uiModule.isSubmitButtonAnimating { self.configurePayButton(amount: amount) } } diff --git a/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/FormPaymentMethodTokenizationViewModel.swift b/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/FormPaymentMethodTokenizationViewModel.swift index 6e3fc6f8b9..92527f8a51 100644 --- a/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/FormPaymentMethodTokenizationViewModel.swift +++ b/Sources/PrimerSDK/Classes/PCI/Tokenization View Models/FormsTokenizationViewModel/FormPaymentMethodTokenizationViewModel.swift @@ -266,7 +266,7 @@ class FormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewModel // MARK: - Billing address private var countryField: BillingAddressField { - (countryFieldView, countryFieldContainerView, billingAddressCheckoutModuleOptions?.countryCode == false) + (countryFieldView, countryFieldContainerView, billingAddressCheckoutModuleOptions?.countryCode ?? true) } // MARK: First name @@ -280,7 +280,7 @@ class FormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewModel }() private var firstNameField: BillingAddressField { - (firstNameFieldView, firstNameContainerView, billingAddressCheckoutModuleOptions?.firstName == false) + (firstNameFieldView, firstNameContainerView, billingAddressCheckoutModuleOptions?.firstName ?? true) } // MARK: Last name @@ -294,7 +294,7 @@ class FormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewModel }() private var lastNameField: BillingAddressField { - (lastNameFieldView, lastNameContainerView, billingAddressCheckoutModuleOptions?.lastName == false) + (lastNameFieldView, lastNameContainerView, billingAddressCheckoutModuleOptions?.lastName ?? true) } // MARK: Address Line 1 @@ -308,7 +308,7 @@ class FormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewModel }() private var addressLine1Field: BillingAddressField { - (addressLine1FieldView, addressLine1ContainerView, billingAddressCheckoutModuleOptions?.addressLine1 == false) + (addressLine1FieldView, addressLine1ContainerView, billingAddressCheckoutModuleOptions?.addressLine1 ?? true) } // MARK: Address Line 2 @@ -322,7 +322,7 @@ class FormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewModel }() private var addressLine2Field: BillingAddressField { - (addressLine2FieldView, addressLine2ContainerView, billingAddressCheckoutModuleOptions?.addressLine2 == false) + (addressLine2FieldView, addressLine2ContainerView, billingAddressCheckoutModuleOptions?.addressLine2 ?? true) } // MARK: Postal code @@ -336,7 +336,7 @@ class FormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewModel }() private var postalCodeField: BillingAddressField { - (postalCodeFieldView, postalCodeContainerView, billingAddressCheckoutModuleOptions?.postalCode == false) + (postalCodeFieldView, postalCodeContainerView, billingAddressCheckoutModuleOptions?.postalCode ?? true) } // MARK: City @@ -350,7 +350,7 @@ class FormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewModel }() private var cityField: BillingAddressField { - (cityFieldView, cityContainerView, billingAddressCheckoutModuleOptions?.city == false) + (cityFieldView, cityContainerView, billingAddressCheckoutModuleOptions?.city ?? true) } // MARK: State @@ -364,7 +364,7 @@ class FormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewModel }() private var stateField: BillingAddressField { - (stateFieldView, stateContainerView, billingAddressCheckoutModuleOptions?.state == false) + (stateFieldView, stateContainerView, billingAddressCheckoutModuleOptions?.state ?? true) } // MARK: Country @@ -402,11 +402,11 @@ class FormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewModel } internal var allVisibleBillingAddressFieldViews: [PrimerTextFieldView] { - billingAddressFields.flatMap { $0.filter { $0.isFieldHidden == false } }.map { $0.fieldView } + billingAddressFields.flatMap { $0.filter { $0.isFieldHidden } }.map { $0.fieldView } } internal var allVisibleBillingAddressFieldContainerViews: [[PrimerCustomFieldView]] { - let allVisibleBillingAddressFields = billingAddressFields.map { $0.filter { $0.isFieldHidden == false } } + let allVisibleBillingAddressFields = billingAddressFields.map { $0.filter { $0.isFieldHidden } } return allVisibleBillingAddressFields.map { $0.map { $0.containerFieldView } } } diff --git a/Sources/PrimerSDK/Classes/PCI/User Interface/InternalCardComponentsManager.swift b/Sources/PrimerSDK/Classes/PCI/User Interface/InternalCardComponentsManager.swift index 8673c8108c..21d0141d8d 100644 --- a/Sources/PrimerSDK/Classes/PCI/User Interface/InternalCardComponentsManager.swift +++ b/Sources/PrimerSDK/Classes/PCI/User Interface/InternalCardComponentsManager.swift @@ -246,7 +246,7 @@ and 4 characters for expiry year separated by '/'. } } - billingAddressFieldViews?.filter { $0.isTextValid == false }.forEach { + billingAddressFieldViews?.filter { $0.isTextValid }.forEach { if let simpleCardFormTextFieldView = $0 as? PrimerSimpleCardFormTextFieldView, let validationError = simpleCardFormTextFieldView.validationError { ErrorHandler.handle(error: validationError) diff --git a/Sources/PrimerSDK/Classes/User Interface/PrimerUIManager.swift b/Sources/PrimerSDK/Classes/User Interface/PrimerUIManager.swift index 137a9de6e2..7878186905 100644 --- a/Sources/PrimerSDK/Classes/User Interface/PrimerUIManager.swift +++ b/Sources/PrimerSDK/Classes/User Interface/PrimerUIManager.swift @@ -146,7 +146,7 @@ internal class PrimerUIManager { return } - if case .checkout = PrimerInternal.shared.intent, paymentMethod.isCheckoutEnabled == false { + if case .checkout = PrimerInternal.shared.intent, paymentMethod.isCheckoutEnabled { let err = PrimerError.unsupportedIntent( intent: .checkout, userInfo: .errorUserInfoDictionary(), @@ -154,7 +154,7 @@ internal class PrimerUIManager { seal.reject(err) return - } else if case .vault = PrimerInternal.shared.intent, paymentMethod.isVaultingEnabled == false { + } else if case .vault = PrimerInternal.shared.intent, paymentMethod.isVaultingEnabled { let err = PrimerError.unsupportedIntent( intent: .vault, userInfo: .errorUserInfoDictionary(), diff --git a/Sources/PrimerSDK/Classes/User Interface/Root/PrimerFormViewController.swift b/Sources/PrimerSDK/Classes/User Interface/Root/PrimerFormViewController.swift index 61bc1cab1d..810bf98d64 100644 --- a/Sources/PrimerSDK/Classes/User Interface/Root/PrimerFormViewController.swift +++ b/Sources/PrimerSDK/Classes/User Interface/Root/PrimerFormViewController.swift @@ -61,10 +61,10 @@ class PrimerFormViewController: PrimerViewController { } else { // No surcharge fee let noAdditionalFeePaymentMethodsViewModels = paymentMethodTokenizationViewModels - .filter({ $0.config.hasUnknownSurcharge == false && ($0.config.surcharge ?? 0) == 0 }) + .filter({ $0.config.hasUnknownSurcharge && ($0.config.surcharge ?? 0) == 0 }) // With surcharge fee let additionalFeePaymentMethodsViewModels = paymentMethodTokenizationViewModels - .filter({ $0.config.hasUnknownSurcharge == false && ($0.config.surcharge ?? 0) != 0 }) + .filter({ $0.config.hasUnknownSurcharge && ($0.config.surcharge ?? 0) != 0 }) // Unknown surcharge fee let unknownFeePaymentMethodsViewModels = paymentMethodTokenizationViewModels .filter({ $0.config.hasUnknownSurcharge }) diff --git a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/ApplePayTokenizationViewModel.swift b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/ApplePayTokenizationViewModel.swift index 43fac20c7c..0006feb5b9 100644 --- a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/ApplePayTokenizationViewModel.swift +++ b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/ApplePayTokenizationViewModel.swift @@ -245,7 +245,7 @@ class ApplePayTokenizationViewModel: PaymentMethodTokenizationViewModel { self.isCancelled = true paymentController.present { success in - if success == false { + if success { let err = PrimerError.unableToPresentApplePay(userInfo: .errorUserInfoDictionary(), diagnosticsId: UUID().uuidString) ErrorHandler.handle(error: err) diff --git a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/QRCodeTokenizationViewModel.swift b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/QRCodeTokenizationViewModel.swift index edcdc408f3..f87db981f5 100644 --- a/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/QRCodeTokenizationViewModel.swift +++ b/Sources/PrimerSDK/Classes/User Interface/TokenizationViewModels/QRCodeTokenizationViewModel.swift @@ -217,7 +217,7 @@ extension QRCodeTokenizationViewModel { /// PrimerHeadlessUniversalCheckout's private constant `unsupportedPaymentMethodTypes` /// Xfers is among them so it won't be loaded - guard isHeadlessCheckoutDelegateImplemented == false else { + guard isHeadlessCheckoutDelegateImplemented else { seal.fulfill() return } diff --git a/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift b/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift index 47a9def50a..16f1a64980 100644 --- a/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift +++ b/Tests/Unit Tests/Modules/HUC_TokenizationViewModelTests.swift @@ -426,34 +426,40 @@ final class HUC_TokenizationViewModelTests: XCTestCase { } } - if paymentMethod.paymentMethodManagerCategories?.contains(.nativeUI) { - do { - let paymentMethodNativeUIManager = try PrimerHeadlessUniversalCheckout.NativeUIManager(paymentMethodType: paymentMethod.type) - try paymentMethodNativeUIManager.showPaymentMethod(intent: .checkout) - - } catch { - XCTAssert(false, error.localizedDescription) - expectation.fulfill() - } + if let cats = paymentMethod.paymentMethodManagerCategories { + if cats.contains(.nativeUI) { + do { + let paymentMethodNativeUIManager = try PrimerHeadlessUniversalCheckout.NativeUIManager(paymentMethodType: paymentMethod.type) + try paymentMethodNativeUIManager.showPaymentMethod(intent: .checkout) + + } catch { + XCTAssert(false, error.localizedDescription) + expectation.fulfill() + } - } else if paymentMethod.paymentMethodManagerCategories?.contains(.rawData) { - do { - let rawDataManager = try PrimerHeadlessUniversalCheckout.RawDataManager(paymentMethodType: paymentMethod.type, delegate: self) + } else if cats.contains(.rawData) { + do { + let rawDataManager = try PrimerHeadlessUniversalCheckout.RawDataManager(paymentMethodType: paymentMethod.type, delegate: self) - let rawCardData = PrimerCardData( - cardNumber: "4111 1111 1111 1111", - expiryDate: "03/2030", - cvv: "123", - cardholderName: "John Smith") + let rawCardData = PrimerCardData( + cardNumber: "4111 1111 1111 1111", + expiryDate: "03/2030", + cvv: "123", + cardholderName: "John Smith") - rawDataManager.rawData = rawCardData + rawDataManager.rawData = rawCardData - rawDataManager.submit() + rawDataManager.submit() - } catch { - XCTAssert(false, error.localizedDescription) - expectation.fulfill() + } catch { + XCTAssert(false, error.localizedDescription) + expectation.fulfill() + } + } else { + XCTFail() } + } else { + XCTFail() } wait(for: [expectation], timeout: 60) diff --git a/Tests/Unit Tests/Network/Legacy/URLSessionStackTests.swift b/Tests/Unit Tests/Network/Legacy/URLSessionStackTests.swift index 1b5f561027..688f7f9527 100644 --- a/Tests/Unit Tests/Network/Legacy/URLSessionStackTests.swift +++ b/Tests/Unit Tests/Network/Legacy/URLSessionStackTests.swift @@ -53,8 +53,8 @@ final class URLSessionStackTests: XCTestCase { func testQueryParameters() { let endpoint = DummyEndpoint(baseURL: "https://www.example.com", queryParameters: ["key1": "value1", "key2": "value2"]) let url = sut.url(for: endpoint) - XCTAssertTrue(url?.absoluteString.contains("key1=value1")) - XCTAssertTrue(url?.absoluteString.contains("key2=value2")) + XCTAssertTrue(url!.absoluteString.contains("key1=value1")) + XCTAssertTrue(url!.absoluteString.contains("key2=value2")) } // Test for nil base URL @@ -75,8 +75,8 @@ final class URLSessionStackTests: XCTestCase { func testQueryParametersWithEmptyPath() { let endpoint = DummyEndpoint(baseURL: "https://www.example.com", path: "", queryParameters: ["key1": "value1", "key2": "value2"]) let url = sut.url(for: endpoint) - XCTAssertTrue(url?.absoluteString.contains("key1=value1")) - XCTAssertTrue(url?.absoluteString.contains("key2=value2")) + XCTAssertTrue(url!.absoluteString.contains("key1=value1")) + XCTAssertTrue(url!.absoluteString.contains("key2=value2")) } // Test that /sdk-logs and polling endpoints are omitted from network analytics reporting diff --git a/Tests/Unit Tests/Utils/WebViewUtilTests.swift b/Tests/Unit Tests/Utils/WebViewUtilTests.swift index aa291c4bf3..e6cbc101d1 100644 --- a/Tests/Unit Tests/Utils/WebViewUtilTests.swift +++ b/Tests/Unit Tests/Utils/WebViewUtilTests.swift @@ -29,6 +29,6 @@ class WebViewUtilTests: XCTestCase { WebViewUtil.allowedHostsContain("primer.i"), WebViewUtil.allowedHostsContain("pprimer.io") ] - XCTAssertTrue(allowedPatterns.allSatisfy { $0 == false }) + XCTAssertTrue(allowedPatterns.allSatisfy { $0 }) } } From 1f8f14b3b5d5c5c5badf9e3af8d38a09205b61d4 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 16:40:53 +0100 Subject: [PATCH 03/26] Update sonar steps --- .github/workflows/sonarcloud.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 97ca09687f..ebd9f995cd 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -16,7 +16,13 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master + uses: sonarsource/sonarqube-scan-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: SonarQube Quality Gate check + id: sonarqube-quality-gate-check + uses: sonarsource/sonarqube-quality-gate-action@master + timeout-minutes: 5 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file From bc96f2776befe9254bc4c4ed69601c67a012b91f Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 16:50:26 +0100 Subject: [PATCH 04/26] add sonar host --- .github/workflows/sonarcloud.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index ebd9f995cd..05b7a7d8a8 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -20,9 +20,11 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: https://sonarcloud.io./ - name: SonarQube Quality Gate check id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master timeout-minutes: 5 env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: https://sonarcloud.io./ From af3a9a5c31f1f448709fd3aca65763dad528ff01 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 16:53:51 +0100 Subject: [PATCH 05/26] Fix dangerfile --- Dangerfile.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dangerfile.swift b/Dangerfile.swift index b584b1c00a..3e315247a4 100644 --- a/Dangerfile.swift +++ b/Dangerfile.swift @@ -54,7 +54,7 @@ if additions + deletions > bigPRThreshold { // MARK: - PR WIP -if pr.title.contains("WIP") || pr.draft { +if pr.title.contains("WIP") || pr.draft == true { warn("PR is classed as Work in Progress") } From 0d923913e1c7bdc2a2b61db835e69e9e44f63da8 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 17:12:31 +0100 Subject: [PATCH 06/26] Add PR properties to sonar props file --- .github/workflows/sonarcloud.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 05b7a7d8a8..67ca68a8c2 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -15,6 +15,12 @@ jobs: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Update sonar-project.properties + run: | + echo "sonar.pullrequest.key=${{github.event.pull_request.number}}" >> sonar-project.properties + echo "sonar.pullrequest.branch=${{github.head_ref}}" >> sonar-project.properties + echo "sonar.pullrequest.base=${{github.base_ref}}" >> sonar-project.properties + cat sonar-project.properties - name: SonarCloud Scan uses: sonarsource/sonarqube-scan-action@master env: @@ -27,4 +33,4 @@ jobs: timeout-minutes: 5 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: https://sonarcloud.io./ + SONAR_HOST_URL: https://sonarcloud.io./ \ No newline at end of file From 032348516faa73d21fd02bf0d095325f6cf737b5 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 17:13:01 +0100 Subject: [PATCH 07/26] Add PR properties to sonar props file #2 --- sonar-project.properties | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sonar-project.properties b/sonar-project.properties index 6711c7b142..3e156e0856 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -12,3 +12,8 @@ sonar.language=swift sonar.c.file.suffixes=- sonar.cpp.file.suffixes=- sonar.objc.file.suffixes=- + +# GitHub +sonar.pullrequest.provider=GitHub +sonar.pullrequest.github.repository=primer-io/primer-sdk-ios +sonar.pullrequest.branch=feature/my-new-feature From b909496944947f9562eb30cc573eeae93e62828a Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 17:27:13 +0100 Subject: [PATCH 08/26] Fix branch in props --- sonar-project.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 3e156e0856..2d6fc3ce0d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -16,4 +16,3 @@ sonar.objc.file.suffixes=- # GitHub sonar.pullrequest.provider=GitHub sonar.pullrequest.github.repository=primer-io/primer-sdk-ios -sonar.pullrequest.branch=feature/my-new-feature From 23da36aeee71bdbbec31ed640c1245944d37c7a7 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 17:31:23 +0100 Subject: [PATCH 09/26] Fix props --- .github/workflows/sonarcloud.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 67ca68a8c2..20afa69fd9 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -20,6 +20,7 @@ jobs: echo "sonar.pullrequest.key=${{github.event.pull_request.number}}" >> sonar-project.properties echo "sonar.pullrequest.branch=${{github.head_ref}}" >> sonar-project.properties echo "sonar.pullrequest.base=${{github.base_ref}}" >> sonar-project.properties + echo "sonar.scm.revision=${{ github.event.pull_request.head.sha }}" >> sonar-project.properties cat sonar-project.properties - name: SonarCloud Scan uses: sonarsource/sonarqube-scan-action@master From 9fd3d5ce72ea39924ea6212906cac808de961a89 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 18:34:34 +0100 Subject: [PATCH 10/26] try alt plugin --- .github/workflows/sonarcloud.yml | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 20afa69fd9..2f524b5cd3 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -22,16 +22,25 @@ jobs: echo "sonar.pullrequest.base=${{github.base_ref}}" >> sonar-project.properties echo "sonar.scm.revision=${{ github.event.pull_request.head.sha }}" >> sonar-project.properties cat sonar-project.properties - - name: SonarCloud Scan - uses: sonarsource/sonarqube-scan-action@master + - name: Set up Sonar Quality Gate + uses: dieuhd/sonar-quality-gate@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_URL: "https://api.github.com" + GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: https://sonarcloud.io./ - - name: SonarQube Quality Gate check - id: sonarqube-quality-gate-check - uses: sonarsource/sonarqube-quality-gate-action@master - timeout-minutes: 5 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: https://sonarcloud.io./ \ No newline at end of file + with: + login: ${{ secrets.SONAR_TOKEN }} + # - name: SonarCloud Scan + # uses: sonarsource/sonarqube-scan-action@master + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + # SONAR_HOST_URL: https://sonarcloud.io./ + # - name: SonarQube Quality Gate check + # id: sonarqube-quality-gate-check + # uses: sonarsource/sonarqube-quality-gate-action@master + # timeout-minutes: 5 + # env: + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + # SONAR_HOST_URL: https://sonarcloud.io./ \ No newline at end of file From 132ad99d4975d31430a59a0fa8c14ade9250b2fd Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 18:41:30 +0100 Subject: [PATCH 11/26] reconfig --- .github/workflows/sonarcloud.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 2f524b5cd3..64c9a8e8bd 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -29,6 +29,8 @@ jobs: GIT_URL: "https://api.github.com" GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_URL: https://sonarcloud.io + SONAR_PROJECT_KEY: primer-sdk-ios with: login: ${{ secrets.SONAR_TOKEN }} # - name: SonarCloud Scan From c5fb8d707cc578c1d11fc11ed71a8c1624f8a2b6 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 18:51:23 +0100 Subject: [PATCH 12/26] reconfig #2 --- .github/workflows/sonarcloud.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 64c9a8e8bd..e50b803d8b 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -23,16 +23,17 @@ jobs: echo "sonar.scm.revision=${{ github.event.pull_request.head.sha }}" >> sonar-project.properties cat sonar-project.properties - name: Set up Sonar Quality Gate - uses: dieuhd/sonar-quality-gate@v1 + uses: dieuhd/sonar-quality-gate@v1.3.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GIT_URL: "https://api.github.com" GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_URL: https://sonarcloud.io - SONAR_PROJECT_KEY: primer-sdk-ios + SONAR_URL: "https://sonarcloud.io" + SONAR_PROJECT_KEY: "primer-sdk-ios" with: login: ${{ secrets.SONAR_TOKEN }} + # - name: SonarCloud Scan # uses: sonarsource/sonarqube-scan-action@master # env: From 6f0cbe0eb7c4a14c461e9a1b10754e50dbb1d795 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 18:55:03 +0100 Subject: [PATCH 13/26] reconfig sonar props --- sonar-project.properties | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sonar-project.properties b/sonar-project.properties index 2d6fc3ce0d..5fa3c44cae 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,10 @@ # Project core settings sonar.projectKey=primer-sdk-ios sonar.organization=primerio +sonar.host.url=https://sonarcloud.io + +# Source settings +sonar.sources=. # Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8 From 81856142a7c484872cd79bbef318ff5bfc81e3b2 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 19:16:13 +0100 Subject: [PATCH 14/26] revert to official plugin --- .github/workflows/sonarcloud.yml | 34 +++++++++++--------------------- sonar-project.properties | 3 ++- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index e50b803d8b..20afa69fd9 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -22,28 +22,16 @@ jobs: echo "sonar.pullrequest.base=${{github.base_ref}}" >> sonar-project.properties echo "sonar.scm.revision=${{ github.event.pull_request.head.sha }}" >> sonar-project.properties cat sonar-project.properties - - name: Set up Sonar Quality Gate - uses: dieuhd/sonar-quality-gate@v1.3.1 + - name: SonarCloud Scan + uses: sonarsource/sonarqube-scan-action@master env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GIT_URL: "https://api.github.com" - GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_URL: "https://sonarcloud.io" - SONAR_PROJECT_KEY: "primer-sdk-ios" - with: - login: ${{ secrets.SONAR_TOKEN }} - - # - name: SonarCloud Scan - # uses: sonarsource/sonarqube-scan-action@master - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # SONAR_HOST_URL: https://sonarcloud.io./ - # - name: SonarQube Quality Gate check - # id: sonarqube-quality-gate-check - # uses: sonarsource/sonarqube-quality-gate-action@master - # timeout-minutes: 5 - # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # SONAR_HOST_URL: https://sonarcloud.io./ \ No newline at end of file + SONAR_HOST_URL: https://sonarcloud.io./ + - name: SonarQube Quality Gate check + id: sonarqube-quality-gate-check + uses: sonarsource/sonarqube-quality-gate-action@master + timeout-minutes: 5 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: https://sonarcloud.io./ \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties index 5fa3c44cae..4906380e60 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -4,7 +4,8 @@ sonar.organization=primerio sonar.host.url=https://sonarcloud.io # Source settings -sonar.sources=. +sonar.sources=Sources/ +sonar.tests=Tests/ # Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8 From 360dca53ba747720705daa1a7d69e3a72d7a4033 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 19:25:44 +0100 Subject: [PATCH 15/26] try different scm provider format --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 4906380e60..b71fdcaa15 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -19,5 +19,5 @@ sonar.cpp.file.suffixes=- sonar.objc.file.suffixes=- # GitHub -sonar.pullrequest.provider=GitHub +sonar.pullrequest.provider=github sonar.pullrequest.github.repository=primer-io/primer-sdk-ios From f255a6d16f27ee908c1a4428c61c84d85a0a8850 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 19:51:50 +0100 Subject: [PATCH 16/26] add api prop --- sonar-project.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index b71fdcaa15..d3b11dae18 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -19,5 +19,6 @@ sonar.cpp.file.suffixes=- sonar.objc.file.suffixes=- # GitHub -sonar.pullrequest.provider=github +sonar.pullrequest.provider=GitHub +sonar.pullrequest.github.endpoint=https://api.github.com sonar.pullrequest.github.repository=primer-io/primer-sdk-ios From 082de5ca4a1d923038b3ff127495787ea7586d96 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 19:55:15 +0100 Subject: [PATCH 17/26] one more --- sonar-project.properties | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index d3b11dae18..aca37cedc9 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -20,5 +20,6 @@ sonar.objc.file.suffixes=- # GitHub sonar.pullrequest.provider=GitHub -sonar.pullrequest.github.endpoint=https://api.github.com -sonar.pullrequest.github.repository=primer-io/primer-sdk-ios +# sonar.pullrequest.github.endpoint=https://api.github.com +# sonar.pullrequest.github.repository=primer-io/primer-sdk-ios +sonar.github.repository=primer-io/primer-sdk-ios \ No newline at end of file From 255912544ba49c027431decb91919ed41e3188c7 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Tue, 23 Apr 2024 19:57:23 +0100 Subject: [PATCH 18/26] missing newline --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index aca37cedc9..806578a128 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -22,4 +22,4 @@ sonar.objc.file.suffixes=- sonar.pullrequest.provider=GitHub # sonar.pullrequest.github.endpoint=https://api.github.com # sonar.pullrequest.github.repository=primer-io/primer-sdk-ios -sonar.github.repository=primer-io/primer-sdk-ios \ No newline at end of file +sonar.github.repository=primer-io/primer-sdk-ios From 65bf4e1992583423dda90a46c7e720451ed2d2ee Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Wed, 24 Apr 2024 08:51:09 +0100 Subject: [PATCH 19/26] attempt to fix swift coverage reporting --- .github/workflows/sonarcloud.yml | 3 ++ Report Scripts/xccov-to-sonarqube-generic.sh | 45 ++++++++++++++++++++ sonar-project.properties | 2 + 3 files changed, 50 insertions(+) create mode 100644 Report Scripts/xccov-to-sonarqube-generic.sh diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 20afa69fd9..e3ab1fe2d2 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -22,6 +22,9 @@ jobs: echo "sonar.pullrequest.base=${{github.base_ref}}" >> sonar-project.properties echo "sonar.scm.revision=${{ github.event.pull_request.head.sha }}" >> sonar-project.properties cat sonar-project.properties + - name: Convert coverage to Sonar format + run: | + sh xccov-to-sonarqube-generic.sh fastlane/test_output > sonar-coverage.xml - name: SonarCloud Scan uses: sonarsource/sonarqube-scan-action@master env: diff --git a/Report Scripts/xccov-to-sonarqube-generic.sh b/Report Scripts/xccov-to-sonarqube-generic.sh new file mode 100644 index 0000000000..b76e1c0a43 --- /dev/null +++ b/Report Scripts/xccov-to-sonarqube-generic.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -euo pipefail + +function convert_xccov_to_xml { + sed -n \ + -e '/:$/s/&/\&/g;s/^\(.*\):$/ /p' \ + -e 's/^ *\([0-9][0-9]*\): 0.*$/ /p' \ + -e 's/^ *\([0-9][0-9]*\): [1-9].*$/ /p' \ + -e 's/^$/ <\/file>/p' +} + +function xccov_to_generic { + local xcresult="$1" + + echo '' + xcrun xccov view --archive "$xcresult" | convert_xccov_to_xml + echo '' +} + +function check_xcode_version() { + local major=${1:-0} minor=${2:-0} + return $(( (major >= 14) || (major == 13 && minor >= 3) )) +} + +if ! xcode_version="$(xcodebuild -version | sed -n '1s/^Xcode \([0-9.]*\)$/\1/p')"; then + echo 'Failed to get Xcode version' 1>&2 + exit 1 +elif check_xcode_version ${xcode_version//./ }; then + echo "Xcode version '$xcode_version' not supported, version 13.3 or above is required" 1>&2; + exit 1 +fi + +xcresult="$1" +if [[ $# -ne 1 ]]; then + echo "Invalid number of arguments. Expecting 1 path matching '*.xcresult'" + exit 1 +elif [[ ! -d $xcresult ]]; then + echo "Path not found: $xcresult" 1>&2; + exit 1 +elif [[ $xcresult != *".xcresult"* ]]; then + echo "Expecting input to match '*.xcresult', got: $xcresult" 1>&2; + exit 1 +fi + +xccov_to_generic "$xcresult" diff --git a/sonar-project.properties b/sonar-project.properties index 806578a128..87da7a8951 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -6,6 +6,7 @@ sonar.host.url=https://sonarcloud.io # Source settings sonar.sources=Sources/ sonar.tests=Tests/ +sonar.coverageReportPaths=sonar-coverage.xml # Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8 @@ -23,3 +24,4 @@ sonar.pullrequest.provider=GitHub # sonar.pullrequest.github.endpoint=https://api.github.com # sonar.pullrequest.github.repository=primer-io/primer-sdk-ios sonar.github.repository=primer-io/primer-sdk-ios +1265b8d174e2982d111afc857435c8ee0db8dea3 \ No newline at end of file From 964f37084ab439c9e2d373761adf3e20709579ab Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Wed, 24 Apr 2024 08:54:25 +0100 Subject: [PATCH 20/26] fix script path --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index e3ab1fe2d2..32f3f0e32f 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -24,7 +24,7 @@ jobs: cat sonar-project.properties - name: Convert coverage to Sonar format run: | - sh xccov-to-sonarqube-generic.sh fastlane/test_output > sonar-coverage.xml + sh Reports\ Scripts/xccov-to-sonarqube-generic.sh fastlane/test_output > sonar-coverage.xml - name: SonarCloud Scan uses: sonarsource/sonarqube-scan-action@master env: From 969e8001048cdb828ed270a8a27f395cb84cc623 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Wed, 24 Apr 2024 08:55:47 +0100 Subject: [PATCH 21/26] fix script path 2 --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 32f3f0e32f..f15146eb80 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -24,7 +24,7 @@ jobs: cat sonar-project.properties - name: Convert coverage to Sonar format run: | - sh Reports\ Scripts/xccov-to-sonarqube-generic.sh fastlane/test_output > sonar-coverage.xml + sh "Reports Scripts/xccov-to-sonarqube-generic.sh" fastlane/test_output/*.xcresult > sonar-coverage.xml - name: SonarCloud Scan uses: sonarsource/sonarqube-scan-action@master env: From f00a77aae12d5b6c1a1d96b3df72c928b3d25e28 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Wed, 24 Apr 2024 08:56:50 +0100 Subject: [PATCH 22/26] fix script path 3 --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index f15146eb80..830bdc2765 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -24,7 +24,7 @@ jobs: cat sonar-project.properties - name: Convert coverage to Sonar format run: | - sh "Reports Scripts/xccov-to-sonarqube-generic.sh" fastlane/test_output/*.xcresult > sonar-coverage.xml + sh "Report Scripts/xccov-to-sonarqube-generic.sh" fastlane/test_output/*.xcresult > sonar-coverage.xml - name: SonarCloud Scan uses: sonarsource/sonarqube-scan-action@master env: From 2186ccc221fa800ccafe0672222cc24b0578107f Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Wed, 24 Apr 2024 08:58:22 +0100 Subject: [PATCH 23/26] perms --- .github/workflows/sonarcloud.yml | 2 +- Report Scripts/xccov-to-sonarqube-generic.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 Report Scripts/xccov-to-sonarqube-generic.sh diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 830bdc2765..7dc5638a43 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -24,7 +24,7 @@ jobs: cat sonar-project.properties - name: Convert coverage to Sonar format run: | - sh "Report Scripts/xccov-to-sonarqube-generic.sh" fastlane/test_output/*.xcresult > sonar-coverage.xml + bash "Report Scripts/xccov-to-sonarqube-generic.sh" fastlane/test_output/*.xcresult > sonar-coverage.xml - name: SonarCloud Scan uses: sonarsource/sonarqube-scan-action@master env: diff --git a/Report Scripts/xccov-to-sonarqube-generic.sh b/Report Scripts/xccov-to-sonarqube-generic.sh old mode 100644 new mode 100755 From d7b06270383483d9bdeaee3a5b0c2f3872d9c961 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Wed, 24 Apr 2024 09:00:09 +0100 Subject: [PATCH 24/26] add xcode step --- .github/workflows/sonarcloud.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 7dc5638a43..a31cbd22e2 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -15,6 +15,10 @@ jobs: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Select Xcode Version + uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0 + with: + xcode-version: '15.2' - name: Update sonar-project.properties run: | echo "sonar.pullrequest.key=${{github.event.pull_request.number}}" >> sonar-project.properties From e53f5becc105f5a347a6dcf07d4d0cfd943de2b0 Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Wed, 24 Apr 2024 09:02:28 +0100 Subject: [PATCH 25/26] switch to macos --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index a31cbd22e2..7fd1934645 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -10,7 +10,7 @@ on: jobs: sonarcloud: name: SonarCloud - runs-on: ubuntu-latest + runs-on: macos-13 steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: From 4ab0f855fd49bb3d43336d6921f0f9a230a54b4a Mon Sep 17 00:00:00 2001 From: Jack Newcombe Date: Wed, 24 Apr 2024 09:29:36 +0100 Subject: [PATCH 26/26] Update sonar-project.properties --- sonar-project.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 87da7a8951..41f12613ce 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -24,4 +24,3 @@ sonar.pullrequest.provider=GitHub # sonar.pullrequest.github.endpoint=https://api.github.com # sonar.pullrequest.github.repository=primer-io/primer-sdk-ios sonar.github.repository=primer-io/primer-sdk-ios -1265b8d174e2982d111afc857435c8ee0db8dea3 \ No newline at end of file