Skip to content

Commit c112d18

Browse files
committed
Fixed linting issues
1 parent 6db058a commit c112d18

File tree

9 files changed

+68
-72
lines changed

9 files changed

+68
-72
lines changed

Sources/Misc/PriceFormatterProvider.swift

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import Foundation
1616
/// A `NumberFormatter` provider class for prices.
1717
/// This provider caches the formatter to improve the performance.
1818
final class PriceFormatterProvider: Sendable {
19-
19+
2020
private let priceFormattingRuleSet: PriceFormattingRuleSet?
21-
21+
2222
init(priceFormattingRuleSet: PriceFormattingRuleSet? = nil) {
2323
self.priceFormattingRuleSet = priceFormattingRuleSet
2424
}
@@ -49,24 +49,23 @@ final class PriceFormatterProvider: Sendable {
4949
formatter.currencySymbolOverride == priceFormattingRuleSet?.currencySymbolOverride(currencyCode: formatter.currencyCode) {
5050
return formatter
5151
}
52-
}
53-
else if let formatter = formatter, formatter.locale == locale {
52+
} else if let formatter = formatter, formatter.locale == locale {
5453
return formatter
5554
}
56-
55+
5756
var newFormatter = makePriceFormatterForSK1(
5857
with: locale,
5958
currencySymbolOverride: nil
6059
)
61-
60+
6261
// If there is a currency symbol override for the currencyCode of the new formatter, use that
6362
if let currencySymbolOverride = priceFormattingRuleSet?.currencySymbolOverride(currencyCode: newFormatter.currencyCode) {
6463
newFormatter = makePriceFormatterForSK1(
6564
with: locale,
6665
currencySymbolOverride: currencySymbolOverride
6766
)
6867
}
69-
68+
7069
formatter = newFormatter
7170

7271
return newFormatter
@@ -110,7 +109,7 @@ final class PriceFormatterProvider: Sendable {
110109
return newFormatter
111110
}
112111
}
113-
112+
114113
private func createPriceFormatterIfNeeded(
115114
cachedPriceFormatter: NumberFormatter?,
116115
currencyCode: String,
@@ -119,23 +118,22 @@ final class PriceFormatterProvider: Sendable {
119118
let currencySymbolOverride = priceFormattingRuleSet?.currencySymbolOverride(
120119
currencyCode: currencyCode
121120
)
122-
121+
123122
if let formatter = cachedPriceFormatter as? CurrencySymbolOverridingPriceFormatter {
124123
if formatter.currencyCode == currencyCode, formatter.locale == locale, formatter.currencySymbolOverride == currencySymbolOverride {
125124
return formatter
126125
}
127-
}
128-
else if let formatter = cachedPriceFormatter, formatter.currencyCode == currencyCode, formatter.locale == locale {
126+
} else if let formatter = cachedPriceFormatter, formatter.currencyCode == currencyCode, formatter.locale == locale {
129127
return formatter
130128
}
131-
129+
132130
return makePriceFormatter(
133131
with: currencyCode,
134132
locale: locale,
135133
currencySymbolOverride: currencySymbolOverride
136134
)
137135
}
138-
136+
139137
private func makePriceFormatter(
140138
with currencyCode: String,
141139
locale: Locale,
@@ -157,23 +155,23 @@ final class PriceFormatterProvider: Sendable {
157155
}
158156

159157
class CurrencySymbolOverridingPriceFormatter: NumberFormatter, @unchecked Sendable {
160-
158+
161159
let currencySymbolOverride: PriceFormattingRuleSet.CurrencySymbolOverride
162160
private var numberFormatterCache = [PriceFormattingRuleSet.CurrencySymbolOverride.PluralRule: NumberFormatter]()
163-
161+
164162
init(currencySymbolOverride: PriceFormattingRuleSet.CurrencySymbolOverride) {
165163
self.currencySymbolOverride = currencySymbolOverride
166164
super.init()
167165
}
168-
166+
169167
required init?(coder: NSCoder) {
170168
fatalError("init(coder:) has not been implemented")
171169
}
172-
170+
173171
override func string(from number: NSNumber) -> String? {
174172
formatter(for: rule(for: number)).string(from: number)
175173
}
176-
174+
177175
/// Cardinal plural selection per CLDR/ICU baseline:
178176
/// - Non-integers → .other
179177
/// - Integers: 0 → .zero, 1 → .one, 2 → .two, else → .other
@@ -184,11 +182,11 @@ class CurrencySymbolOverridingPriceFormatter: NumberFormatter, @unchecked Sendab
184182

185183
// Guard weird numerics
186184
if n.isNaN || n.isInfinite { return .other }
187-
185+
188186
guard let intValue = Int64(exactly: n) else {
189187
return .other
190188
}
191-
189+
192190
// Check if value has any fractional part
193191
let isInteger = n == Double(intValue)
194192

@@ -203,12 +201,12 @@ class CurrencySymbolOverridingPriceFormatter: NumberFormatter, @unchecked Sendab
203201
default: return .other
204202
}
205203
}
206-
204+
207205
private func formatter(for rule: PriceFormattingRuleSet.CurrencySymbolOverride.PluralRule) -> NumberFormatter {
208206
if let formatter = numberFormatterCache[rule] {
209207
return formatter
210208
}
211-
209+
212210
let formatter = NumberFormatter()
213211
formatter.numberStyle = numberStyle
214212
formatter.locale = locale

Sources/Networking/Responses/RevenueCatUI/UIConfig.swift

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public struct UIConfig: Codable, Equatable, Sendable {
115115
public var app: AppConfig
116116
public var localizations: [String: [String: String]]
117117
public var variableConfig: VariableConfig
118-
118+
119119
@DefaultDecodable.EmptyDictionary
120120
var priceFormattingRuleSets: [
121121
// storefront country code -> ruleset
@@ -132,7 +132,6 @@ public struct UIConfig: Codable, Equatable, Sendable {
132132
self.variableConfig = variableConfig
133133
self.priceFormattingRuleSets = priceFormattingRuleSets
134134
}
135-
136135
}
137136

138137
#else
@@ -143,7 +142,7 @@ public struct UIConfig: Codable, Equatable, Sendable {
143142
// storefront country code -> ruleset
144143
String: PriceFormattingRuleSet
145144
]
146-
145+
147146
@_spi(Internal)
148147
public init(priceFormattingRuleSets: [String: PriceFormattingRuleSet]) {
149148
self.priceFormattingRuleSets = priceFormattingRuleSets
@@ -158,20 +157,20 @@ public struct UIConfig: Codable, Equatable, Sendable {
158157
*/
159158
@_spi(Internal)
160159
public struct PriceFormattingRuleSet: Sendable {
161-
160+
162161
// currencyCode: CurrencySymbolOverride
163162
private var currencySymbolOverrides: [String: CurrencySymbolOverride]
164-
165-
init(currencySymbolOverrides: [String : CurrencySymbolOverride]) {
163+
164+
init(currencySymbolOverrides: [String: CurrencySymbolOverride]) {
166165
self.currencySymbolOverrides = currencySymbolOverrides
167166
}
168-
167+
169168
func currencySymbolOverride(
170169
currencyCode: String
171170
) -> CurrencySymbolOverride? {
172171
return self.currencySymbolOverrides[currencyCode]
173172
}
174-
173+
175174
/*
176175
Contains a set of currencySymbol overrides for different pluralization rules
177176
*/
@@ -182,7 +181,7 @@ public struct PriceFormattingRuleSet: Sendable {
182181
let few: String
183182
let many: String
184183
let other: String
185-
184+
186185
func value(for rule: PluralRule) -> String {
187186
switch rule {
188187
case .zero:
@@ -199,7 +198,7 @@ public struct PriceFormattingRuleSet: Sendable {
199198
return self.other
200199
}
201200
}
202-
201+
203202
public enum PluralRule {
204203
case zero, one, two, few, many, other
205204
}

Sources/Purchasing/ProductsManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ extension ProductsManagerType {
172172
// MARK: -
173173
struct PriceFormattingRuleSetProvider {
174174
let priceFormattingRuleSet: () -> PriceFormattingRuleSet?
175-
175+
176176
static let empty = PriceFormattingRuleSetProvider(
177177
priceFormattingRuleSet: { nil }
178178
)

Sources/Purchasing/Purchases/Purchases.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,14 @@ public typealias StartPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void
393393
let offeringsFactory = OfferingsFactory()
394394
let receiptParser = PurchasesReceiptParser.default
395395
let transactionsManager = TransactionsManager(receiptParser: receiptParser)
396-
396+
397397
let priceFormattingRuleSetProvider: PriceFormattingRuleSetProvider = .init {
398398
var priceFormattingRuleSet: PriceFormattingRuleSet?
399399
if Self.isConfigured, let offeringsResponse = Self.shared.cachedOfferings?.response,
400-
let storeFrontCountryCode = systemInfo.storefront?.countryCode
401-
{
400+
let storeFrontCountryCode = systemInfo.storefront?.countryCode {
402401
priceFormattingRuleSet = offeringsResponse.uiConfig?.priceFormattingRuleSets[storeFrontCountryCode]
403402
}
404-
403+
405404
return priceFormattingRuleSet
406405
}
407406

Sources/Purchasing/StoreKit2/ProductsFetcherSK2.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import StoreKit
1616

1717
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
1818
actor ProductsFetcherSK2 {
19-
19+
2020
private let priceFormattingRuleSetProvider: PriceFormattingRuleSetProvider
21-
21+
2222
init(priceFormattingRuleSetProvider: PriceFormattingRuleSetProvider = .empty) {
2323
self.priceFormattingRuleSetProvider = priceFormattingRuleSetProvider
2424
}

Sources/Purchasing/StoreKitAbstractions/SK2StoreProduct.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import StoreKit
1515

1616
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
1717
internal struct SK2StoreProduct: StoreProductType {
18-
18+
1919
init(sk2Product: SK2Product, priceFormatterProvider: PriceFormatterProvider = .init(priceFormattingRuleSet: nil)) {
2020
self._underlyingSK2Product = .init(sk2Product)
2121
self.priceFormatterProvider = priceFormatterProvider
@@ -59,7 +59,7 @@ internal struct SK2StoreProduct: StoreProductType {
5959
Logger.appleError("Can't initialize priceFormatter for SK2 product! Could not find the currency code")
6060
return nil
6161
}
62-
62+
6363
return self.priceFormatterProvider.priceFormatterForSK2(
6464
withCurrencyCode: currencyCode,
6565
locale: locale ?? .autoupdatingCurrent

Sources/Purchasing/StoreKitAbstractions/StoreProduct.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ extension StoreProduct {
306306
public convenience init(sk1Product: SK1Product) {
307307
self.init(SK1StoreProduct(sk1Product: sk1Product))
308308
}
309-
309+
310310
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
311311
public convenience init(
312312
sk2Product: SK2Product

0 commit comments

Comments
 (0)