Skip to content

Commit 4bbce20

Browse files
authored
chore Fix all warnings (#1468)
## Summary - Using `Void?` as associated key type as described [here](https://github.com/atrick/swift-evolution/blob/diagnose-implicit-raw-bitwise/proposals/nnnn-implicit-raw-bitwise-conversion.md#workarounds-for-common-cases) - ~Using `PKShippingContactEditingMode.available` instead of `.enabled` because of deprecation~ - Actually this is only available/deprecated using Xcode 15 🤷 - Increasing linting file-line-limit-warning to 500 - Splitting up function/class bodies - Reducing `swiftlint:disable`
2 parents ed9c64f + a1d3bc1 commit 4bbce20

File tree

30 files changed

+160
-110
lines changed

30 files changed

+160
-110
lines changed

.swiftlint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ line_length:
1919
ignores_function_declarations: true
2020
ignores_urls: true
2121
warning: 140
22+
23+
file_length:
24+
warning: 500

Adyen/Core/Components/AbstractPersonalInformationComponent/AbstractPersonalInformationComponent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ open class AbstractPersonalInformationComponent: PaymentComponent, PresentableCo
235235
lastNameItem?.value = $0.lastName
236236
}
237237
shopperInformation.emailAddress.map { emailItem?.value = $0 }
238-
shopperInformation.telephoneNumber.map { phoneItem?.value = $0 }
238+
shopperInformation.phoneNumber.map { phoneItem?.value = $0.value }
239239
shopperInformation.billingAddress.map { addressItem?.value = $0 }
240240
shopperInformation.deliveryAddress.map { deliveryAddressItem?.value = $0 }
241241
}

Adyen/Core/Core Protocols/Component.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) 2022 Adyen N.V.
2+
// Copyright (c) 2023 Adyen N.V.
33
//
44
// This file is open source and available under the MIT license. See the LICENSE file for more info.
55
//
@@ -65,9 +65,9 @@ public extension Component {
6565
}
6666

6767
private enum AssociatedKeys {
68-
internal static var isDropIn = "isDropInObject"
68+
internal static var isDropIn: Void?
6969

70-
internal static var environment = "environmentObject"
70+
internal static var environment: Void?
7171

72-
internal static var clientKey = "clientKeyObject"
72+
internal static var clientKey: Void?
7373
}

Adyen/Core/Core Protocols/PaymentAwareComponent.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) 2022 Adyen N.V.
2+
// Copyright (c) 2023 Adyen N.V.
33
//
44
// This file is open source and available under the MIT license. See the LICENSE file for more info.
55
//
@@ -37,7 +37,7 @@ extension PartialPaymentOrderAware {
3737

3838
private enum AssociatedKeys {
3939

40-
internal static var payment = "paymentObject"
40+
internal static var payment: Void?
4141

42-
internal static var order = "orderObject"
42+
internal static var order: Void?
4343
}

Adyen/Core/Models/CardType.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public enum CardType: RawRepresentable, Codable, Equatable, Hashable {
8383

8484
/// Korea Cyber Payment
8585
case kcp
86-
86+
8787
/// Korean local card
8888
case koreanLocalCard
8989

@@ -141,7 +141,7 @@ public enum CardType: RawRepresentable, Codable, Equatable, Hashable {
141141
/// Fallback option for any other scheme name
142142
case other(named: String)
143143

144-
// swiftlint:disable cyclomatic_complexity
144+
// swiftlint:disable cyclomatic_complexity function_body_length
145145
public init(rawValue: String) {
146146
switch rawValue {
147147
case "accel": self = .accel
@@ -292,7 +292,7 @@ public enum CardType: RawRepresentable, Codable, Equatable, Hashable {
292292
case let .other(name): return name.replacingOccurrences(of: "_", with: " ")
293293
}
294294
}
295-
// swiftlint:enable cyclomatic_complexity
295+
// swiftlint:enable cyclomatic_complexity function_body_length
296296
}
297297

298298
extension CardType {

Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable {
6363
case other(String)
6464

6565
// swiftlint:disable cyclomatic_complexity function_body_length
66-
66+
6767
public init?(rawValue: String) {
6868
switch rawValue {
6969
case "card": self = .card
@@ -122,7 +122,7 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable {
122122
default: self = .other(rawValue)
123123
}
124124
}
125-
125+
126126
public var rawValue: String {
127127
switch self {
128128
case .card: return "card"
@@ -180,6 +180,9 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable {
180180
case let .other(value): return value
181181
}
182182
}
183+
}
184+
185+
extension PaymentMethodType {
183186

184187
/// The brand name of the card type
185188
///

Adyen/Helpers/UIViewAnimation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import UIKit
88

99
private enum AssociatedKeys {
10-
internal static var animations = "animations"
10+
internal static var animations: Void?
1111
}
1212

1313
@_spi(AdyenInternal)

Adyen/UI/Form/Items/Phone Number/FormPhoneNumberItem.swift

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) 2022 Adyen N.V.
2+
// Copyright (c) 2023 Adyen N.V.
33
//
44
// This file is open source and available under the MIT license. See the LICENSE file for more info.
55
//
@@ -31,11 +31,15 @@ public final class FormPhoneNumberItem: FormTextItem {
3131
selectableValues: [PhoneExtensionPickerItem],
3232
style: FormTextItemStyle,
3333
localizationParameters: LocalizationParameters? = nil) {
34-
// swiftlint:disable:next line_length
35-
let preselectedValue = selectableValues.first(where: { $0.element.value == phoneNumber?.callingCode }) ?? selectableValues.first(where: { $0.identifier == Locale.current.regionCode }) ?? selectableValues[0]
36-
37-
phonePrefixItem = FormPhoneExtensionPickerItem(preselectedValue: preselectedValue, selectableValues: selectableValues, style: style)
34+
35+
phonePrefixItem = FormPhoneExtensionPickerItem(
36+
preselectedValue: selectableValues.preselectedPhoneNumberPrefix(for: phoneNumber),
37+
selectableValues: selectableValues,
38+
style: style
39+
)
40+
3841
super.init(style: style)
42+
3943
phonePrefixItem.identifier = ViewIdentifierBuilder.build(scopeInstance: self, postfix: "phoneExtensionPickerItem")
4044
value = phoneNumber?.value ?? ""
4145

@@ -50,5 +54,25 @@ public final class FormPhoneNumberItem: FormTextItem {
5054
override public func build(with builder: FormItemViewBuilder) -> AnyFormItemView {
5155
builder.build(with: self)
5256
}
57+
}
58+
59+
private extension [PhoneExtensionPickerItem] {
5360

61+
func preselectedPhoneNumberPrefix(for phoneNumber: PhoneNumber?) -> PhoneExtensionPickerItem {
62+
63+
if let matchingCallingCode = first(where: { $0.element.value == phoneNumber?.callingCode }) {
64+
return matchingCallingCode
65+
}
66+
67+
if let matchingLocaleRegion = first(where: { $0.identifier == Locale.current.regionCode }) {
68+
return matchingLocaleRegion
69+
}
70+
71+
if let firstSelectableValue = first {
72+
return firstSelectableValue
73+
}
74+
75+
AdyenAssertion.assertionFailure(message: "Empty list of selectableValues provided")
76+
return .init(identifier: "", element: .init(value: "+1", countryCode: "US"))
77+
}
5478
}

Adyen/UI/List/ListItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class ListItem: FormItem {
9494

9595
private func setLoading(_ isLoading: Bool) {
9696
guard let loadingHandler else {
97-
assertionFailure("No loadingHandler provided")
97+
AdyenAssertion.assertionFailure(message: "No loadingHandler provided")
9898
return
9999
}
100100

Adyen/UI/View Controllers/AddressLookup/AddressLookupViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ private extension AddressLookupViewController {
7979
}
8080
}
8181

82-
internal extension AddressLookupViewController.ViewModel {
82+
extension AddressLookupViewController.ViewModel {
8383

84-
func buildAddressInputFormViewModel(
84+
internal func buildAddressInputFormViewModel(
8585
with prefillAddress: PostalAddress?
8686
) -> AddressInputFormViewController.ViewModel {
8787

@@ -96,7 +96,7 @@ internal extension AddressLookupViewController.ViewModel {
9696
)
9797
}
9898

99-
func buildAddressSearchViewModel(
99+
internal func buildAddressSearchViewModel(
100100
presentationHandler: @escaping (UIViewController) -> Void
101101
) -> AddressLookupSearchViewController.ViewModel {
102102

0 commit comments

Comments
 (0)