Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix swiftlint warnings #6612

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ios/.swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
- type_body_length
- opening_brace # Differs from Google swift guidelines enforced by swiftformat
- trailing_comma
- switch_case_alignment # Enables expressions such as [return switch location {}]

Check warning on line 10 in ios/.swiftlint.yml

View workflow job for this annotation

GitHub Actions / check-formatting

10:27 [comments] too few spaces before comment
- orphaned_doc_comment
opt_in_rules:
- empty_count

Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadREST/ApiHandlers/RESTRequestFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension REST {
let networkTimeout: Duration
let bodyEncoder: JSONEncoder

class func withDefaultAPICredentials(
static func withDefaultAPICredentials(
pathPrefix: String,
bodyEncoder: JSONEncoder
) -> RequestFactory {
Expand Down
7 changes: 1 addition & 6 deletions ios/MullvadSettings/SettingsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion ios/PacketTunnelCore/Pinger/Pinger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading