diff options
| author | mojganii <mojgan.jelodar@codic.se> | 2024-08-13 15:49:14 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2024-08-14 13:32:45 +0200 |
| commit | 28a337cb13436eac19dd529faeead536a321b7c6 (patch) | |
| tree | 93ce5064082d5aa321e3394229862da85365819a | |
| parent | a14ae1437d2f792c8911bda06ff7be8b462b889f (diff) | |
| download | mullvadvpn-28a337cb13436eac19dd529faeead536a321b7c6.tar.xz mullvadvpn-28a337cb13436eac19dd529faeead536a321b7c6.zip | |
Fix some Swiftlint warnings
10 files changed, 15 insertions, 20 deletions
diff --git a/ios/MullvadREST/ApiHandlers/RESTRequestFactory.swift b/ios/MullvadREST/ApiHandlers/RESTRequestFactory.swift index f0a3f3334e..584495ee06 100644 --- a/ios/MullvadREST/ApiHandlers/RESTRequestFactory.swift +++ b/ios/MullvadREST/ApiHandlers/RESTRequestFactory.swift @@ -16,7 +16,7 @@ extension REST { let networkTimeout: Duration let bodyEncoder: JSONEncoder - class func withDefaultAPICredentials( + static func withDefaultAPICredentials( pathPrefix: String, bodyEncoder: JSONEncoder ) -> RequestFactory { diff --git a/ios/MullvadSettings/SettingsManager.swift b/ios/MullvadSettings/SettingsManager.swift index 660858c786..7a6d4ba2e9 100644 --- a/ios/MullvadSettings/SettingsManager.swift +++ b/ios/MullvadSettings/SettingsManager.swift @@ -47,12 +47,7 @@ public enum SettingsManager { public static func getLastUsedAccount() throws -> String { let data = try store.read(key: .lastUsedAccount) - - if let string = String(data: data, encoding: .utf8) { - return string - } else { - throw StringDecodingError(data: data) - } + return String(decoding: data, as: UTF8.self) } public static func setLastUsedAccount(_ string: String?) throws { diff --git a/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift b/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift index 9db60518d7..dc2025df1e 100644 --- a/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift +++ b/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift @@ -44,7 +44,7 @@ final class StorePaymentManager: NSObject, SKPaymentTransactionObserver { private var paymentToAccountToken = [SKPayment: String]() /// Returns true if the device is able to make payments. - class var canMakePayments: Bool { + static var canMakePayments: Bool { SKPaymentQueue.canMakePayments() } diff --git a/ios/MullvadVPN/View controllers/SelectLocation/LocationCellViewModel.swift b/ios/MullvadVPN/View controllers/SelectLocation/LocationCellViewModel.swift index 355e7a6fb1..ce578d13ba 100644 --- a/ios/MullvadVPN/View controllers/SelectLocation/LocationCellViewModel.swift +++ b/ios/MullvadVPN/View controllers/SelectLocation/LocationCellViewModel.swift @@ -80,7 +80,7 @@ extension LocationCellViewModel { return false } - var proxyNode = RootLocationNode(children: [node]) + let proxyNode = RootLocationNode(children: [node]) let allLocations = Set(proxyNode.flattened.flatMap { $0.locations }) let hostCount = allLocations.filter { location in if case .hostname = location { true } else { false } diff --git a/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift b/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift index 8e7cac0676..38c02748a4 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift @@ -388,7 +388,7 @@ final class TunnelControlView: UIView { ) } - private class func makeBoldTextLabel(ofSize fontSize: CGFloat, numberOfLines: Int = 1) -> UILabel { + private static func makeBoldTextLabel(ofSize fontSize: CGFloat, numberOfLines: Int = 1) -> UILabel { let textLabel = UILabel() textLabel.translatesAutoresizingMaskIntoConstraints = false textLabel.font = UIFont.boldSystemFont(ofSize: fontSize) diff --git a/ios/MullvadVPNTests/MullvadSettings/APIAccessMethodsTests.swift b/ios/MullvadVPNTests/MullvadSettings/APIAccessMethodsTests.swift index b7f3e18b78..4ed3bdc1a3 100644 --- a/ios/MullvadVPNTests/MullvadSettings/APIAccessMethodsTests.swift +++ b/ios/MullvadVPNTests/MullvadSettings/APIAccessMethodsTests.swift @@ -13,11 +13,11 @@ import XCTest final class APIAccessMethodsTests: XCTestCase { static let store = InMemorySettingsStore<SettingNotFound>() - override class func setUp() { + override static func setUp() { SettingsManager.unitTestStore = store } - override class func tearDown() { + override static func tearDown() { SettingsManager.unitTestStore = nil } diff --git a/ios/MullvadVPNTests/MullvadSettings/IPOverrideRepositoryTests.swift b/ios/MullvadVPNTests/MullvadSettings/IPOverrideRepositoryTests.swift index 961d938b54..4562ae44a4 100644 --- a/ios/MullvadVPNTests/MullvadSettings/IPOverrideRepositoryTests.swift +++ b/ios/MullvadVPNTests/MullvadSettings/IPOverrideRepositoryTests.swift @@ -14,11 +14,11 @@ final class IPOverrideRepositoryTests: XCTestCase { static let store = InMemorySettingsStore<SettingNotFound>() let repository = IPOverrideRepository() - override class func setUp() { + override static func setUp() { SettingsManager.unitTestStore = store } - override class func tearDown() { + override static func tearDown() { SettingsManager.unitTestStore = nil } diff --git a/ios/MullvadVPNTests/MullvadSettings/MigrationManagerTests.swift b/ios/MullvadVPNTests/MullvadSettings/MigrationManagerTests.swift index 6bc92398b7..9b3739f9d0 100644 --- a/ios/MullvadVPNTests/MullvadSettings/MigrationManagerTests.swift +++ b/ios/MullvadVPNTests/MullvadSettings/MigrationManagerTests.swift @@ -16,11 +16,11 @@ final class MigrationManagerTests: XCTestCase { static let store = InMemorySettingsStore<SettingNotFound>() var manager: MigrationManager! - override class func setUp() { + override static func setUp() { SettingsManager.unitTestStore = store } - override class func tearDown() { + override static func tearDown() { SettingsManager.unitTestStore = nil } @@ -72,7 +72,7 @@ final class MigrationManagerTests: XCTestCase { func testFailedMigrationResetsSettings() throws { let store = Self.store - let data = try XCTUnwrap("Migration test".data(using: .utf8)) + let data = Data("Migration test".utf8) try store.write(data, for: .settings) try store.write(data, for: .deviceState) diff --git a/ios/MullvadVPNTests/MullvadVPN/TunnelManager/TunnelManagerTests.swift b/ios/MullvadVPNTests/MullvadVPN/TunnelManager/TunnelManagerTests.swift index 806cc7a412..d862678345 100644 --- a/ios/MullvadVPNTests/MullvadVPN/TunnelManager/TunnelManagerTests.swift +++ b/ios/MullvadVPNTests/MullvadVPN/TunnelManager/TunnelManagerTests.swift @@ -27,11 +27,11 @@ class TunnelManagerTests: XCTestCase { var transportProvider: TransportProvider! - override class func setUp() { + override static func setUp() { SettingsManager.unitTestStore = store } - override class func tearDown() { + override static func tearDown() { SettingsManager.unitTestStore = nil } diff --git a/ios/PacketTunnelCore/Pinger/Pinger.swift b/ios/PacketTunnelCore/Pinger/Pinger.swift index 8f63648061..68a06a7028 100644 --- a/ios/PacketTunnelCore/Pinger/Pinger.swift +++ b/ios/PacketTunnelCore/Pinger/Pinger.swift @@ -217,7 +217,7 @@ public final class Pinger: PingerProtocol { } } - private class func makeIPAddress(from sa: sockaddr) -> IPAddress? { + private static func makeIPAddress(from sa: sockaddr) -> IPAddress? { if sa.sa_family == AF_INET { return withUnsafeBytes(of: sa) { buffer -> IPAddress? in buffer.bindMemory(to: sockaddr_in.self).baseAddress.flatMap { boundPointer in |
