diff options
| author | Bug Magnet <marco.nikic@mullvad.net> | 2023-06-21 16:20:05 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2023-06-27 15:54:20 +0200 |
| commit | 7e8e9d306d56e4534c95ed07a796aa0475ff0721 (patch) | |
| tree | 76537805fc481f828728a4d67eee39a287dc26e0 | |
| parent | 28b3234f329d715c8dc8a11da97ee6fa9bf19b2f (diff) | |
| download | mullvadvpn-7e8e9d306d56e4534c95ed07a796aa0475ff0721.tar.xz mullvadvpn-7e8e9d306d56e4534c95ed07a796aa0475ff0721.zip | |
New swiftformat rule, enable google swift guidelines
163 files changed, 526 insertions, 510 deletions
diff --git a/ios/.swiftformat b/ios/.swiftformat index 0813595faf..1eb3f50cc8 100644 --- a/ios/.swiftformat +++ b/ios/.swiftformat @@ -6,10 +6,77 @@ # format options --indent 4 +# Google suggests 100, but Mullvad historically uses 120 --maxwidth 120 +# The cardinal rules of Google Swift style for line-wrapping are: + # If the entire declaration, statement, or expression fits on one line, then do that. + # All elements must fit on the same line, or each element must be on its own line. --wraparguments before-first --wrapcollections before-first --wrapternary before-operators --redundanttype inferred --ifdef no-indent ---disable initCoderUnavailable, redundantReturn, unusedArguments, redundantRawValues, preferKeyPath, extensionAccessControl, hoistTry +# Use K&R brace style, which is what Apple also uses +--allman false +# Use consistent ordering for member modifiers. +--modifierorder +--disable \ +initCoderUnavailable, \ +unusedArguments, \ +redundantRawValues, \ +preferKeyPath, \ +extensionAccessControl, \ +hoistTry, \ +# Do not reorganize declarations +organizeDeclarations, \ +# Do not reorder switch case statements +sortedSwitchCases, \ +# Do not add // MARK: ClassName before every type +markTypes + + +--rules \ +blankLinesAroundMark, \ +blankLinesAtEndOfScope, \ +blankLinesAtStartOfScope, \ +blankLinesBetweenScopes, \ +braces, \ +consecutiveBlankLines, \ +consecutiveSpaces, \ +duplicateImports, \ +elseOnSameLine, \ +emptyBraces, \ +enumNamespaces, \ +extensionAccessControl, \ +hoistPatternLet, \ +indent, \ +leadingDelimiters, \ +linebreakAtEndOfFile, \ +redundantInit, \ +redundantParens, \ +redundantPattern, \ +redundantRawValues, \ +redundantType, \ +redundantVoidReturnType, \ +semicolons, \ +sortedImports, \ +spaceAroundBraces, \ +spaceAroundBrackets, \ +spaceAroundComments, \ +spaceAroundGenerics, \ +spaceAroundOperators, \ +spaceAroundParens, \ +spaceInsideBraces, \ +spaceInsideBrackets, \ +spaceInsideComments, \ +spaceInsideGenerics, \ +spaceInsideParens, \ +todos, \ +trailingClosures, \ +trailingCommas, \ +trailingSpace, \ +typeSugar, \ +void, \ +wrap, \ +wrapArguments, \ +wrapAttributes
\ No newline at end of file diff --git a/ios/MullvadLogging/CustomFormatLogHandler.swift b/ios/MullvadLogging/CustomFormatLogHandler.swift index 4c86a75f51..3ed4fe24cb 100644 --- a/ios/MullvadLogging/CustomFormatLogHandler.swift +++ b/ios/MullvadLogging/CustomFormatLogHandler.swift @@ -31,7 +31,7 @@ public struct CustomFormatLogHandler: LogHandler { public subscript(metadataKey metadataKey: String) -> Logger.Metadata.Value? { get { - return metadata[metadataKey] + metadata[metadataKey] } set(newValue) { metadata[metadataKey] = newValue @@ -49,7 +49,7 @@ public struct CustomFormatLogHandler: LogHandler { ) { let mergedMetadata = self.metadata .merging(metadata ?? [:]) { lhs, rhs -> Logger.MetadataValue in - return rhs + rhs } let prettyMetadata = Self.formatMetadata(mergedMetadata) let metadataOutput = prettyMetadata.isEmpty ? "" : " \(prettyMetadata)" @@ -62,6 +62,6 @@ public struct CustomFormatLogHandler: LogHandler { } private static func formatMetadata(_ metadata: Logger.Metadata) -> String { - return metadata.map { "\($0)=\($1)" }.joined(separator: " ") + metadata.map { "\($0)=\($1)" }.joined(separator: " ") } } diff --git a/ios/MullvadLogging/LogRotation.swift b/ios/MullvadLogging/LogRotation.swift index 132b0c31c7..57c5597327 100644 --- a/ios/MullvadLogging/LogRotation.swift +++ b/ios/MullvadLogging/LogRotation.swift @@ -46,8 +46,7 @@ public enum LogRotation { // .fileNoSuchFile is returned when both backup and source log files do not exist // .fileReadNoSuchFile is returned when backup exists but source log file does not if fileError.code == .fileNoSuchFile || fileError.code == .fileReadNoSuchFile, - fileError.url == source - { + fileError.url == source { throw Error.noSourceLogFile } } diff --git a/ios/MullvadLogging/OSLogHandler.swift b/ios/MullvadLogging/OSLogHandler.swift index 61375b37ea..25501108ee 100644 --- a/ios/MullvadLogging/OSLogHandler.swift +++ b/ios/MullvadLogging/OSLogHandler.swift @@ -46,7 +46,7 @@ public struct OSLogHandler: LogHandler { public subscript(metadataKey metadataKey: String) -> Logging.Logger.Metadata.Value? { get { - return metadata[metadataKey] + metadata[metadataKey] } set(newValue) { metadata[metadataKey] = newValue @@ -64,7 +64,7 @@ public struct OSLogHandler: LogHandler { ) { let mergedMetadata = self.metadata .merging(metadata ?? [:]) { lhs, rhs -> Logging.Logger.MetadataValue in - return rhs + rhs } let prettyMetadata = Self.formatMetadata(mergedMetadata) let logMessage = prettyMetadata.isEmpty ? message : "\(prettyMetadata) \(message)" @@ -73,7 +73,7 @@ public struct OSLogHandler: LogHandler { } private static func formatMetadata(_ metadata: Logging.Logger.Metadata) -> String { - return metadata.map { "\($0)=\($1)" }.joined(separator: " ") + metadata.map { "\($0)=\($1)" }.joined(separator: " ") } } diff --git a/ios/MullvadREST/Duration.swift b/ios/MullvadREST/Duration.swift index d773d944c1..3ce42719d8 100644 --- a/ios/MullvadREST/Duration.swift +++ b/ios/MullvadREST/Duration.swift @@ -13,11 +13,11 @@ extension REST { public let milliseconds: UInt64 public var seconds: UInt64 { - return milliseconds / 1000 + milliseconds / 1000 } public var timeInterval: TimeInterval { - return TimeInterval(milliseconds) / 1000 + TimeInterval(milliseconds) / 1000 } private init(milliseconds: UInt64) { @@ -40,23 +40,23 @@ extension REST { } public static func seconds(_ seconds: UInt64) -> Duration { - return Duration(milliseconds: seconds.saturatingMultiplication(1000)) + Duration(milliseconds: seconds.saturatingMultiplication(1000)) } public static func milliseconds(_ milliseconds: UInt64) -> Duration { - return Duration(milliseconds: milliseconds) + Duration(milliseconds: milliseconds) } public static func < (lhs: Duration, rhs: Duration) -> Bool { - return lhs.milliseconds < rhs.milliseconds + lhs.milliseconds < rhs.milliseconds } public static func == (lhs: Duration, rhs: Duration) -> Bool { - return lhs.milliseconds == rhs.milliseconds + lhs.milliseconds == rhs.milliseconds } public static func * (lhs: Duration, factor: UInt64) -> Duration { - return Duration(milliseconds: lhs.milliseconds.saturatingMultiplication(factor)) + Duration(milliseconds: lhs.milliseconds.saturatingMultiplication(factor)) } } } diff --git a/ios/MullvadREST/ExponentialBackoff.swift b/ios/MullvadREST/ExponentialBackoff.swift index 04a84c8dfb..39c9e01923 100644 --- a/ios/MullvadREST/ExponentialBackoff.swift +++ b/ios/MullvadREST/ExponentialBackoff.swift @@ -34,8 +34,7 @@ struct ExponentialBackoff: IteratorProtocol { } struct Jittered<InnerIterator: IteratorProtocol>: IteratorProtocol - where InnerIterator.Element == REST.Duration -{ + where InnerIterator.Element == REST.Duration { private var inner: InnerIterator init(_ inner: InnerIterator) { diff --git a/ios/MullvadREST/HTTP.swift b/ios/MullvadREST/HTTP.swift index f6e8ff247d..900ab2a49a 100644 --- a/ios/MullvadREST/HTTP.swift +++ b/ios/MullvadREST/HTTP.swift @@ -27,7 +27,7 @@ struct HTTPStatus: RawRepresentable, Equatable { static let notFound = HTTPStatus(rawValue: 404) static func isSuccess(_ code: Int) -> Bool { - return (200 ..< 300).contains(code) + (200 ..< 300).contains(code) } let rawValue: Int @@ -36,7 +36,7 @@ struct HTTPStatus: RawRepresentable, Equatable { } var isSuccess: Bool { - return Self.isSuccess(rawValue) + Self.isSuccess(rawValue) } } diff --git a/ios/MullvadREST/RESTAPIProxy.swift b/ios/MullvadREST/RESTAPIProxy.swift index 25b80a2c50..fe7d795b9b 100644 --- a/ios/MullvadREST/RESTAPIProxy.swift +++ b/ios/MullvadREST/RESTAPIProxy.swift @@ -30,7 +30,7 @@ extension REST { completionHandler: @escaping CompletionHandler<[AnyIPEndpoint]> ) -> Cancellable { let requestHandler = AnyRequestHandler { endpoint in - return try self.requestFactory.createRequest( + try self.requestFactory.createRequest( endpoint: endpoint, method: .get, pathTemplate: "api-addrs" @@ -323,7 +323,7 @@ extension REST { public let newExpiry: Date public var dateComponents: DateComponents { - return DateComponents(second: timeAdded) + DateComponents(second: timeAdded) } } } diff --git a/ios/MullvadREST/RESTAccountsProxy.swift b/ios/MullvadREST/RESTAccountsProxy.swift index 11426bb415..f6eacfe65c 100644 --- a/ios/MullvadREST/RESTAccountsProxy.swift +++ b/ios/MullvadREST/RESTAccountsProxy.swift @@ -28,7 +28,7 @@ extension REST { completion: @escaping CompletionHandler<NewAccountData> ) -> Cancellable { let requestHandler = AnyRequestHandler { endpoint in - return try self.requestFactory.createRequest( + try self.requestFactory.createRequest( endpoint: endpoint, method: .post, pathTemplate: "accounts" diff --git a/ios/MullvadREST/RESTAuthorization.swift b/ios/MullvadREST/RESTAuthorization.swift index cce6e23f1f..7e81b1f8cb 100644 --- a/ios/MullvadREST/RESTAuthorization.swift +++ b/ios/MullvadREST/RESTAuthorization.swift @@ -31,9 +31,9 @@ extension REST { completion: @escaping (Result<REST.Authorization, Swift.Error>) -> Void ) -> Cancellable { - return accessTokenManager.getAccessToken(accountNumber: accountNumber) { result in + accessTokenManager.getAccessToken(accountNumber: accountNumber) { result in completion(result.map { tokenData in - return tokenData.accessToken + tokenData.accessToken }) } } @@ -42,7 +42,7 @@ extension REST { extension REST.Proxy where ConfigurationType == REST.AuthProxyConfiguration { func createAuthorizationProvider(accountNumber: String) -> RESTAuthorizationProvider { - return REST.AccessTokenProvider( + REST.AccessTokenProvider( accessTokenManager: configuration.accessTokenManager, accountNumber: accountNumber ) diff --git a/ios/MullvadREST/RESTDevicesProxy.swift b/ios/MullvadREST/RESTDevicesProxy.swift index 37cfd809d7..f273fac7d5 100644 --- a/ios/MullvadREST/RESTDevicesProxy.swift +++ b/ios/MullvadREST/RESTDevicesProxy.swift @@ -62,7 +62,7 @@ extension REST { if httpStatus.isSuccess { return .decoding { - return try self.responseDecoder.decode(Device.self, from: data) + try self.responseDecoder.decode(Device.self, from: data) } } else { return .unhandledResponse( diff --git a/ios/MullvadREST/RESTError.swift b/ios/MullvadREST/RESTError.swift index 3b4ef3d77e..cc8e1e9ecb 100644 --- a/ios/MullvadREST/RESTError.swift +++ b/ios/MullvadREST/RESTError.swift @@ -124,7 +124,7 @@ extension REST { public struct NoTransportError: LocalizedError { public var errorDescription: String? { - return "Transport is not configured." + "Transport is not configured." } } } diff --git a/ios/MullvadREST/RESTNetworkOperation.swift b/ios/MullvadREST/RESTNetworkOperation.swift index 372991ed8d..8828c54453 100644 --- a/ios/MullvadREST/RESTNetworkOperation.swift +++ b/ios/MullvadREST/RESTNetworkOperation.swift @@ -226,7 +226,7 @@ extension REST { // Response handler returned a block decoding value. let decodeResult = Result { try decoderBlock() } .mapError { error -> REST.Error in - return .decodeResponse(error) + .decodeResponse(error) } finish(result: decodeResult.mapError { $0 }) @@ -234,8 +234,7 @@ extension REST { // Response handler couldn't handle the response. if serverErrorResponse?.code == .invalidAccessToken, requiresAuthorization, - retryInvalidAccessTokenError - { + retryInvalidAccessTokenError { logger.debug("Received invalid access token error. Retry once.") retryInvalidAccessTokenError = false startRequest() diff --git a/ios/MullvadREST/RESTProxyFactory.swift b/ios/MullvadREST/RESTProxyFactory.swift index 6bc793a722..215c9c61e9 100644 --- a/ios/MullvadREST/RESTProxyFactory.swift +++ b/ios/MullvadREST/RESTProxyFactory.swift @@ -41,15 +41,15 @@ extension REST { } public func createAPIProxy() -> REST.APIProxy { - return REST.APIProxy(configuration: configuration) + REST.APIProxy(configuration: configuration) } public func createAccountsProxy() -> REST.AccountsProxy { - return REST.AccountsProxy(configuration: configuration) + REST.AccountsProxy(configuration: configuration) } public func createDevicesProxy() -> REST.DevicesProxy { - return REST.DevicesProxy(configuration: configuration) + REST.DevicesProxy(configuration: configuration) } } } diff --git a/ios/MullvadREST/RESTRequestFactory.swift b/ios/MullvadREST/RESTRequestFactory.swift index ec01821cfd..d1e1c06a63 100644 --- a/ios/MullvadREST/RESTRequestFactory.swift +++ b/ios/MullvadREST/RESTRequestFactory.swift @@ -20,7 +20,7 @@ extension REST { pathPrefix: String, bodyEncoder: JSONEncoder ) -> RequestFactory { - return RequestFactory( + RequestFactory( hostname: defaultAPIHostname, pathPrefix: pathPrefix, networkTimeout: defaultAPINetworkTimeout, @@ -120,7 +120,7 @@ extension REST { } func getRequest() -> REST.Request { - return restRequest + restRequest } } @@ -227,7 +227,7 @@ extension REST { } static func + (lhs: URLPathTemplate, rhs: URLPathTemplate) -> URLPathTemplate { - return URLPathTemplate(components: lhs.components + rhs.components) + URLPathTemplate(components: lhs.components + rhs.components) } } } diff --git a/ios/MullvadREST/RESTRequestHandler.swift b/ios/MullvadREST/RESTRequestHandler.swift index ba6d7a43bb..675553b852 100644 --- a/ios/MullvadREST/RESTRequestHandler.swift +++ b/ios/MullvadREST/RESTRequestHandler.swift @@ -31,7 +31,7 @@ extension REST { init(createURLRequest: @escaping (AnyIPEndpoint) throws -> REST.Request) { _createURLRequest = { endpoint, authorization in - return try createURLRequest(endpoint) + try createURLRequest(endpoint) } authorizationProvider = nil } @@ -41,7 +41,7 @@ extension REST { authorizationProvider: RESTAuthorizationProvider ) { _createURLRequest = { endpoint, authorization in - return try createURLRequest(endpoint, authorization!) + try createURLRequest(endpoint, authorization!) } self.authorizationProvider = authorizationProvider } @@ -50,7 +50,7 @@ extension REST { endpoint: AnyIPEndpoint, authorization: REST.Authorization? ) throws -> REST.Request { - return try _createURLRequest(endpoint, authorization) + try _createURLRequest(endpoint, authorization) } } } diff --git a/ios/MullvadREST/RESTResponseHandler.swift b/ios/MullvadREST/RESTResponseHandler.swift index fd3b7d2e2b..5b8ee99ce6 100644 --- a/ios/MullvadREST/RESTResponseHandler.swift +++ b/ios/MullvadREST/RESTResponseHandler.swift @@ -40,9 +40,8 @@ extension REST { } func handleURLResponse(_ response: HTTPURLResponse, data: Data) -> REST - .ResponseHandlerResult<Success> - { - return handlerBlock(response, data) + .ResponseHandlerResult<Success> { + handlerBlock(response, data) } } @@ -53,7 +52,7 @@ extension REST { decoding type: T.Type, with decoder: JSONDecoder ) -> AnyResponseHandler<T> { - return AnyResponseHandler { response, data in + AnyResponseHandler { response, data in if HTTPStatus.isSuccess(response.statusCode) { return .decoding { try decoder.decode(type, from: data) diff --git a/ios/MullvadREST/RESTRetryStrategy.swift b/ios/MullvadREST/RESTRetryStrategy.swift index 954a22bde9..99613811be 100644 --- a/ios/MullvadREST/RESTRetryStrategy.swift +++ b/ios/MullvadREST/RESTRetryStrategy.swift @@ -73,12 +73,12 @@ extension REST { switch self { case .never: return AnyIterator { - return nil + nil } case let .constant(duration): return AnyIterator { - return duration + duration } case let .exponentialBackoff(initial, multiplier, maxDelay): diff --git a/ios/MullvadREST/SSLPinningURLSessionDelegate.swift b/ios/MullvadREST/SSLPinningURLSessionDelegate.swift index 0e9cb36168..6ab457fd49 100644 --- a/ios/MullvadREST/SSLPinningURLSessionDelegate.swift +++ b/ios/MullvadREST/SSLPinningURLSessionDelegate.swift @@ -30,8 +30,7 @@ final class SSLPinningURLSessionDelegate: NSObject, URLSessionDelegate { ) { if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust, let serverTrust = challenge.protectionSpace.serverTrust, - verifyServerTrust(serverTrust) - { + verifyServerTrust(serverTrust) { completionHandler(.useCredential, URLCredential(trust: serverTrust)) } else { completionHandler(.rejectProtectionSpace, nil) diff --git a/ios/MullvadREST/URLSessionTransport.swift b/ios/MullvadREST/URLSessionTransport.swift index 0be25162a4..c5b4cf6a67 100644 --- a/ios/MullvadREST/URLSessionTransport.swift +++ b/ios/MullvadREST/URLSessionTransport.swift @@ -14,7 +14,7 @@ extension URLSessionTask: Cancellable {} extension REST { public final class URLSessionTransport: RESTTransport { public var name: String { - return "url-session" + "url-session" } public let urlSession: URLSession @@ -43,7 +43,7 @@ extension REST { public let urlSession: URLSession public var name: String { - return "shadow-socks-url-session" + "shadow-socks-url-session" } public init( diff --git a/ios/MullvadTransport/URLSessionShadowsocksTransport.swift b/ios/MullvadTransport/URLSessionShadowsocksTransport.swift index a4e7e34403..ad587ba27c 100644 --- a/ios/MullvadTransport/URLSessionShadowsocksTransport.swift +++ b/ios/MullvadTransport/URLSessionShadowsocksTransport.swift @@ -21,7 +21,7 @@ public final class URLSessionShadowsocksTransport: RESTTransport { public let urlSession: URLSession public var name: String { - return "shadow-socks-url-session" + "shadow-socks-url-session" } public init( diff --git a/ios/MullvadTransport/URLSessionTransport.swift b/ios/MullvadTransport/URLSessionTransport.swift index 4ecef05870..0061823085 100644 --- a/ios/MullvadTransport/URLSessionTransport.swift +++ b/ios/MullvadTransport/URLSessionTransport.swift @@ -14,7 +14,7 @@ extension URLSessionTask: Cancellable {} public final class URLSessionTransport: RESTTransport { public var name: String { - return "url-session" + "url-session" } public let urlSession: URLSession diff --git a/ios/MullvadTypes/AnyIPAddress.swift b/ios/MullvadTypes/AnyIPAddress.swift index 77c4413a45..ca88f73632 100644 --- a/ios/MullvadTypes/AnyIPAddress.swift +++ b/ios/MullvadTypes/AnyIPAddress.swift @@ -28,7 +28,7 @@ public enum AnyIPAddress: IPAddress, Codable, Equatable, CustomDebugStringConver } public var rawValue: Data { - return innerAddress.rawValue + innerAddress.rawValue } public init(from decoder: Decoder) throws { @@ -79,19 +79,19 @@ public enum AnyIPAddress: IPAddress, Codable, Equatable, CustomDebugStringConver } public var interface: NWInterface? { - return innerAddress.interface + innerAddress.interface } public var isLoopback: Bool { - return innerAddress.isLoopback + innerAddress.isLoopback } public var isLinkLocal: Bool { - return innerAddress.isLinkLocal + innerAddress.isLinkLocal } public var isMulticast: Bool { - return innerAddress.isMulticast + innerAddress.isMulticast } public var debugDescription: String { diff --git a/ios/MullvadTypes/FileCache.swift b/ios/MullvadTypes/FileCache.swift index 4e16a73c41..381bfb41a4 100644 --- a/ios/MullvadTypes/FileCache.swift +++ b/ios/MullvadTypes/FileCache.swift @@ -20,7 +20,7 @@ public struct FileCache<Content: Codable>: FileCacheProtocol { let fileCoordinator = NSFileCoordinator(filePresenter: nil) return try fileCoordinator.coordinate(readingItemAt: fileURL, options: [.withoutChanges]) { fileURL in - return try JSONDecoder().decode(Content.self, from: Data(contentsOf: fileURL)) + try JSONDecoder().decode(Content.self, from: Data(contentsOf: fileURL)) } } diff --git a/ios/MullvadTypes/IPv4Endpoint.swift b/ios/MullvadTypes/IPv4Endpoint.swift index 16ab09b8ec..2a6f0ef414 100644 --- a/ios/MullvadTypes/IPv4Endpoint.swift +++ b/ios/MullvadTypes/IPv4Endpoint.swift @@ -26,8 +26,7 @@ public struct IPv4Endpoint: Hashable, Equatable, Codable, CustomStringConvertibl ) if components.count == 2, let parsedIP = IPv4Address(String(components[0])), - let parsedPort = UInt16(components[1]) - { + let parsedPort = UInt16(components[1]) { ip = parsedIP port = parsedPort } else { @@ -56,10 +55,10 @@ public struct IPv4Endpoint: Hashable, Equatable, Codable, CustomStringConvertibl } public var description: String { - return "\(ip):\(port)" + "\(ip):\(port)" } public static func == (lhs: IPv4Endpoint, rhs: IPv4Endpoint) -> Bool { - return lhs.ip.rawValue == rhs.ip.rawValue && lhs.port == rhs.port + lhs.ip.rawValue == rhs.ip.rawValue && lhs.port == rhs.port } } diff --git a/ios/MullvadTypes/IPv6Endpoint.swift b/ios/MullvadTypes/IPv6Endpoint.swift index 4aa51343a2..d6fb323455 100644 --- a/ios/MullvadTypes/IPv6Endpoint.swift +++ b/ios/MullvadTypes/IPv6Endpoint.swift @@ -62,10 +62,10 @@ public struct IPv6Endpoint: Hashable, Equatable, Codable, CustomStringConvertibl } public var description: String { - return "[\(ip)]:\(port)" + "[\(ip)]:\(port)" } public static func == (lhs: IPv6Endpoint, rhs: IPv6Endpoint) -> Bool { - return lhs.ip.rawValue == rhs.ip.rawValue && lhs.port == rhs.port + lhs.ip.rawValue == rhs.ip.rawValue && lhs.port == rhs.port } } diff --git a/ios/MullvadTypes/KeychainError.swift b/ios/MullvadTypes/KeychainError.swift index d0766bdc9c..904c9ef652 100644 --- a/ios/MullvadTypes/KeychainError.swift +++ b/ios/MullvadTypes/KeychainError.swift @@ -16,7 +16,7 @@ public struct KeychainError: LocalizedError, Equatable { } public var errorDescription: String? { - return SecCopyErrorMessageString(code, nil) as String? + SecCopyErrorMessageString(code, nil) as String? } public static let duplicateItem = KeychainError(code: errSecDuplicateItem) @@ -24,6 +24,6 @@ public struct KeychainError: LocalizedError, Equatable { public static let interactionNotAllowed = KeychainError(code: errSecInteractionNotAllowed) public static func == (lhs: KeychainError, rhs: KeychainError) -> Bool { - return lhs.code == rhs.code + lhs.code == rhs.code } } diff --git a/ios/MullvadTypes/Location.swift b/ios/MullvadTypes/Location.swift index 06e44a91d6..f324acb410 100644 --- a/ios/MullvadTypes/Location.swift +++ b/ios/MullvadTypes/Location.swift @@ -18,7 +18,7 @@ public struct Location: Codable, Equatable { public var longitude: Double public var geoCoordinate: CLLocationCoordinate2D { - return CLLocationCoordinate2D(latitude: latitude, longitude: longitude) + CLLocationCoordinate2D(latitude: latitude, longitude: longitude) } public init( diff --git a/ios/MullvadTypes/RelayConstraint.swift b/ios/MullvadTypes/RelayConstraint.swift index 5c12f1d8d7..189bee9568 100644 --- a/ios/MullvadTypes/RelayConstraint.swift +++ b/ios/MullvadTypes/RelayConstraint.swift @@ -11,8 +11,7 @@ import Foundation private let anyConstraint = "any" public enum RelayConstraint<T>: Codable, Equatable, - CustomDebugStringConvertible where T: Codable & Equatable -{ + CustomDebugStringConvertible where T: Codable & Equatable { case any case only(T) diff --git a/ios/MullvadTypes/RelayConstraints.swift b/ios/MullvadTypes/RelayConstraints.swift index 9b32fdf16e..c37833823b 100644 --- a/ios/MullvadTypes/RelayConstraints.swift +++ b/ios/MullvadTypes/RelayConstraints.swift @@ -15,7 +15,7 @@ public struct RelayConstraints: Codable, Equatable, CustomDebugStringConvertible public var port: RelayConstraint<UInt16> public var debugDescription: String { - return "RelayConstraints { location: \(location), port: \(port) }" + "RelayConstraints { location: \(location), port: \(port) }" } public init( diff --git a/ios/MullvadTypes/Result+Extensions.swift b/ios/MullvadTypes/Result+Extensions.swift index a471d9ab26..957a6058a3 100644 --- a/ios/MullvadTypes/Result+Extensions.swift +++ b/ios/MullvadTypes/Result+Extensions.swift @@ -37,7 +37,7 @@ extension Result { } public func tryMap<NewSuccess>(_ body: (Success) throws -> NewSuccess) -> Result<NewSuccess, Error> { - return Result<NewSuccess, Error> { + Result<NewSuccess, Error> { let value = try self.get() return try body(value) diff --git a/ios/MullvadVPN/AddressCacheTracker/AddressCacheTracker.swift b/ios/MullvadVPN/AddressCacheTracker/AddressCacheTracker.swift index d7c402c802..9b9621010f 100644 --- a/ios/MullvadVPN/AddressCacheTracker/AddressCacheTracker.swift +++ b/ios/MullvadVPN/AddressCacheTracker/AddressCacheTracker.swift @@ -173,7 +173,7 @@ final class AddressCacheTracker { private func _nextScheduleDate() -> Date { let nextDate = lastFailureAttemptDate.map { date in - return Date( + Date( timeInterval: Self.retryInterval, since: date ) diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift index f83dce7ee0..149348fbc7 100644 --- a/ios/MullvadVPN/AppDelegate.swift +++ b/ios/MullvadVPN/AppDelegate.swift @@ -421,12 +421,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD /// If (1) is `false` and (2) is `true`, we know that the app has been freshly installed/reinstalled and is /// compatible, thus triggering a settings wipe. private func getWipeSettingsOperation() -> AsyncBlockOperation { - return AsyncBlockOperation { + AsyncBlockOperation { if !FirstTimeLaunch.hasFinished, SettingsManager.getShouldWipeSettings() { if let deviceState = try? SettingsManager.readDeviceState(), let accountData = deviceState.accountData, - let deviceData = deviceState.deviceData - { + let deviceData = deviceState.deviceData { _ = self.devicesProxy.deleteDevice( accountNumber: accountData.number, identifier: deviceData.identifier, @@ -450,7 +449,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // Since we do not persist the relation between payment and account number between the // app launches, we assume that all successful purchases belong to the active account // number. - return tunnelManager.deviceState.accountData?.number + tunnelManager.deviceState.accountData?.number } // MARK: - UNUserNotificationCenterDelegate diff --git a/ios/MullvadVPN/BackgroundTask.swift b/ios/MullvadVPN/BackgroundTask.swift index a27a563891..554a572d67 100644 --- a/ios/MullvadVPN/BackgroundTask.swift +++ b/ios/MullvadVPN/BackgroundTask.swift @@ -26,10 +26,10 @@ enum BackgroundTask: String { /// Returns background task identifier. /// Use it when registering or scheduling tasks with `BGTaskScheduler`. var identifier: String { - return "\(ApplicationTarget.mainApp.bundleIdentifier).\(capitalizedRawValue)" + "\(ApplicationTarget.mainApp.bundleIdentifier).\(capitalizedRawValue)" } private var capitalizedRawValue: String { - return rawValue.prefix(1).uppercased() + rawValue.dropFirst() + rawValue.prefix(1).uppercased() + rawValue.dropFirst() } } diff --git a/ios/MullvadVPN/Classes/AutomaticKeyboardResponder.swift b/ios/MullvadVPN/Classes/AutomaticKeyboardResponder.swift index 15356eeedd..9b13f411b8 100644 --- a/ios/MullvadVPN/Classes/AutomaticKeyboardResponder.swift +++ b/ios/MullvadVPN/Classes/AutomaticKeyboardResponder.swift @@ -127,7 +127,7 @@ class AutomaticKeyboardResponder { // Find the container view that private `_UIFormSheetPresentationController` moves // along with the keyboard. return iterator.first { view -> Bool in - return view.description.starts(with: "<UIDropShadowView") + view.description.starts(with: "<UIDropShadowView") } } diff --git a/ios/MullvadVPN/Classes/ChangeLog.swift b/ios/MullvadVPN/Classes/ChangeLog.swift index a9bbc5c894..d98fe903da 100644 --- a/ios/MullvadVPN/Classes/ChangeLog.swift +++ b/ios/MullvadVPN/Classes/ChangeLog.swift @@ -39,7 +39,7 @@ enum ChangeLog { Reads changelog file from bundle and returns its contents as a string. */ static func readFromFile() throws -> String { - return try String(contentsOfFile: try getPathToChangesFile()) + try String(contentsOfFile: try getPathToChangesFile()) .split(whereSeparator: { $0.isNewline }) .compactMap { line in let trimmedString = line.trimmingCharacters(in: .whitespaces) diff --git a/ios/MullvadVPN/Classes/ConsolidatedApplicationLog.swift b/ios/MullvadVPN/Classes/ConsolidatedApplicationLog.swift index 01818e3aaa..22b9ec86f0 100644 --- a/ios/MullvadVPN/Classes/ConsolidatedApplicationLog.swift +++ b/ios/MullvadVPN/Classes/ConsolidatedApplicationLog.swift @@ -42,7 +42,7 @@ class ConsolidatedApplicationLog: TextOutputStreamable { applicationGroupContainers = securityGroupIdentifiers .compactMap { securityGroupIdentifier -> URL? in - return FileManager.default + FileManager.default .containerURL(forSecurityApplicationGroupIdentifier: securityGroupIdentifier) } } @@ -140,7 +140,7 @@ class ConsolidatedApplicationLog: TextOutputStreamable { String(decoding: data, as: UTF8.self) .drop { ch in // Drop leading replacement characters produced when decoding data - return ch == replacementCharacter + ch == replacementCharacter } ) @@ -148,26 +148,26 @@ class ConsolidatedApplicationLog: TextOutputStreamable { } private func redactCustomStrings(string: String) -> String { - return redactCustomStrings.reduce(string) { resultString, redact -> String in - return resultString.replacingOccurrences(of: redact, with: kRedactedPlaceholder) + redactCustomStrings.reduce(string) { resultString, redact -> String in + resultString.replacingOccurrences(of: redact, with: kRedactedPlaceholder) } } private func redact(string: String) -> String { - return [ + [ redactContainerPaths, Self.redactAccountNumber, Self.redactIPv4Address, Self.redactIPv6Address, redactCustomStrings, ].reduce(string) { resultString, transform -> String in - return transform(resultString) + transform(resultString) } } private func redactContainerPaths(string: String) -> String { - return applicationGroupContainers.reduce(string) { resultString, containerURL -> String in - return resultString.replacingOccurrences( + applicationGroupContainers.reduce(string) { resultString, containerURL -> String in + resultString.replacingOccurrences( of: containerURL.path, with: kRedactedContainerPlaceholder ) @@ -175,7 +175,7 @@ class ConsolidatedApplicationLog: TextOutputStreamable { } private static func redactAccountNumber(string: String) -> String { - return redact( + redact( regularExpression: try! NSRegularExpression(pattern: #"\d{16}"#), string: string, replacementString: kRedactedAccountPlaceholder @@ -183,7 +183,7 @@ class ConsolidatedApplicationLog: TextOutputStreamable { } private static func redactIPv4Address(string: String) -> String { - return redact( + redact( regularExpression: NSRegularExpression.ipv4RegularExpression, string: string, replacementString: kRedactedPlaceholder @@ -191,7 +191,7 @@ class ConsolidatedApplicationLog: TextOutputStreamable { } private static func redactIPv6Address(string: String) -> String { - return redact( + redact( regularExpression: NSRegularExpression.ipv6RegularExpression, string: string, replacementString: kRedactedPlaceholder diff --git a/ios/MullvadVPN/Classes/FirstTimeLaunch.swift b/ios/MullvadVPN/Classes/FirstTimeLaunch.swift index efe2168909..405ea2e8ed 100644 --- a/ios/MullvadVPN/Classes/FirstTimeLaunch.swift +++ b/ios/MullvadVPN/Classes/FirstTimeLaunch.swift @@ -12,7 +12,7 @@ enum FirstTimeLaunch { private static let userDefaultsKey = "hasFinishedFirstTimeLaunch" static var hasFinished: Bool { - return UserDefaults.standard.bool(forKey: userDefaultsKey) + UserDefaults.standard.bool(forKey: userDefaultsKey) } static func setHasFinished() { diff --git a/ios/MullvadVPN/Classes/InputTextFormatter.swift b/ios/MullvadVPN/Classes/InputTextFormatter.swift index ad1e5ea62d..acb95e7960 100644 --- a/ios/MullvadVPN/Classes/InputTextFormatter.swift +++ b/ios/MullvadVPN/Classes/InputTextFormatter.swift @@ -76,8 +76,7 @@ class InputTextFormatter: NSObject, UITextFieldDelegate, UITextPasteDelegate { // Since removing separator alone makes no sense, this computation extends the string range // to include the digit preceding a separator. if replacementString.isEmpty, emptySelection, - !formattedString.isEmpty - { + !formattedString.isEmpty { let precedingDigitIndex = formattedString .prefix(through: stringRange.lowerBound) .lastIndex { isAllowed($0) } ?? formattedString.startIndex @@ -135,8 +134,7 @@ class InputTextFormatter: NSObject, UITextFieldDelegate, UITextPasteDelegate { // Add separator between the groups of digits if numDigits > 0, configuration.groupSize > 0, - numDigits % Int(configuration.groupSize) == 0 - { + numDigits % Int(configuration.groupSize) == 0 { reformattedString.append(configuration.groupSeparator) if originalCaretPosition > index { diff --git a/ios/MullvadVPN/Classes/ObserverList.swift b/ios/MullvadVPN/Classes/ObserverList.swift index 12bcf57885..70ace90b69 100644 --- a/ios/MullvadVPN/Classes/ObserverList.swift +++ b/ios/MullvadVPN/Classes/ObserverList.swift @@ -10,7 +10,7 @@ import Foundation struct WeakBox<T> { var value: T? { - return valueProvider() + valueProvider() } private let valueProvider: () -> T? @@ -19,12 +19,12 @@ struct WeakBox<T> { let reference = value as AnyObject valueProvider = { [weak reference] in - return reference as? T + reference as? T } } static func == (lhs: WeakBox<T>, rhs: T) -> Bool { - return (lhs.value as AnyObject) === (rhs as AnyObject) + (lhs.value as AnyObject) === (rhs as AnyObject) } } @@ -36,7 +36,7 @@ final class ObserverList<T> { lock.lock() let hasObserver = observers.contains { box in - return box == observer + box == observer } if !hasObserver { @@ -50,7 +50,7 @@ final class ObserverList<T> { lock.lock() let index = observers.firstIndex { box in - return box == observer + box == observer } if let index { diff --git a/ios/MullvadVPN/Classes/TermsOfService.swift b/ios/MullvadVPN/Classes/TermsOfService.swift index 8672f92e4d..7c00ca4fc0 100644 --- a/ios/MullvadVPN/Classes/TermsOfService.swift +++ b/ios/MullvadVPN/Classes/TermsOfService.swift @@ -12,7 +12,7 @@ enum TermsOfService { private static let userDefaultsKey = "isAgreedToTermsOfService" static var isAgreed: Bool { - return UserDefaults.standard.bool(forKey: userDefaultsKey) + UserDefaults.standard.bool(forKey: userDefaultsKey) } static func setAgreed() { diff --git a/ios/MullvadVPN/Containers/CustomSplitViewController.swift b/ios/MullvadVPN/Containers/CustomSplitViewController.swift index 64d2380929..c4ef61142d 100644 --- a/ios/MullvadVPN/Containers/CustomSplitViewController.swift +++ b/ios/MullvadVPN/Containers/CustomSplitViewController.swift @@ -47,11 +47,11 @@ class CustomSplitViewController: UISplitViewController, RootContainment { private var dividerView: UIView? { let subviews = view.subviews.flatMap { view -> [UIView] in - return [view] + view.subviews + [view] + view.subviews } return subviews.first { view -> Bool in - return view.description.hasPrefix("<UIPanelBorderView") + view.description.hasPrefix("<UIPanelBorderView") } } @@ -62,8 +62,7 @@ class CustomSplitViewController: UISplitViewController, RootContainment { } override func overrideTraitCollection(forChild childViewController: UIViewController) - -> UITraitCollection? - { + -> UITraitCollection? { guard let traitCollection = super.overrideTraitCollection(forChild: childViewController) else { return nil } diff --git a/ios/MullvadVPN/Containers/Navigation/CustomNavigationController.swift b/ios/MullvadVPN/Containers/Navigation/CustomNavigationController.swift index 55cf9794e7..d45fa3c051 100644 --- a/ios/MullvadVPN/Containers/Navigation/CustomNavigationController.swift +++ b/ios/MullvadVPN/Containers/Navigation/CustomNavigationController.swift @@ -10,11 +10,11 @@ import UIKit class CustomNavigationController: UINavigationController { override var childForStatusBarHidden: UIViewController? { - return topViewController + topViewController } override var childForStatusBarStyle: UIViewController? { - return topViewController + topViewController } override func viewDidLoad() { diff --git a/ios/MullvadVPN/Containers/Root/RootContainerViewController.swift b/ios/MullvadVPN/Containers/Root/RootContainerViewController.swift index ae5f95f16a..93655e624d 100644 --- a/ios/MullvadVPN/Containers/Root/RootContainerViewController.swift +++ b/ios/MullvadVPN/Containers/Root/RootContainerViewController.swift @@ -30,7 +30,7 @@ struct HeaderBarPresentation { let showsDivider: Bool static var `default`: HeaderBarPresentation { - return HeaderBarPresentation(style: .default, showsDivider: false) + HeaderBarPresentation(style: .default, showsDivider: false) } } @@ -83,25 +83,25 @@ class RootContainerViewController: UIViewController { private var interfaceOrientationMask: UIInterfaceOrientationMask? var topViewController: UIViewController? { - return viewControllers.last + viewControllers.last } weak var delegate: RootContainerViewControllerDelegate? override var childForStatusBarStyle: UIViewController? { - return topViewController + topViewController } override var childForStatusBarHidden: UIViewController? { - return topViewController + topViewController } override var shouldAutomaticallyForwardAppearanceMethods: Bool { - return false + false } override var disablesAutomaticKeyboardDismissal: Bool { - return topViewController?.disablesAutomaticKeyboardDismissal ?? super + topViewController?.disablesAutomaticKeyboardDismissal ?? super .disablesAutomaticKeyboardDismissal } @@ -168,11 +168,11 @@ class RootContainerViewController: UIViewController { // MARK: - Autorotation override var shouldAutorotate: Bool { - return true + true } override var supportedInterfaceOrientations: UIInterfaceOrientationMask { - return interfaceOrientationMask ?? super.supportedInterfaceOrientations + interfaceOrientationMask ?? super.supportedInterfaceOrientations } // MARK: - Public @@ -326,7 +326,7 @@ class RootContainerViewController: UIViewController { // MARK: - Accessibility override func accessibilityPerformMagicTap() -> Bool { - return delegate?.rootContainerViewAccessibilityPerformMagicTap(self) ?? super + delegate?.rootContainerViewAccessibilityPerformMagicTap(self) ?? super .accessibilityPerformMagicTap() } @@ -459,14 +459,12 @@ class RootContainerViewController: UIViewController { */ if shouldHandleAppearanceEvents { if let targetViewController, - sourceViewController != targetViewController - { + sourceViewController != targetViewController { self.endChildControllerTransition(targetViewController) } if let sourceViewController, - sourceViewController != targetViewController - { + sourceViewController != targetViewController { self.endChildControllerTransition(sourceViewController) } } @@ -529,8 +527,7 @@ class RootContainerViewController: UIViewController { // Begin appearance transition if shouldHandleAppearanceEvents { if let sourceViewController, - sourceViewController != targetViewController - { + sourceViewController != targetViewController { beginChildControllerTransition( sourceViewController, isAppearing: false, @@ -538,8 +535,7 @@ class RootContainerViewController: UIViewController { ) } if let targetViewController, - sourceViewController != targetViewController - { + sourceViewController != targetViewController { beginChildControllerTransition( targetViewController, isAppearing: true, diff --git a/ios/MullvadVPN/Coordinators/App/AccountCoordinator.swift b/ios/MullvadVPN/Coordinators/App/AccountCoordinator.swift index 4425b624e7..93da1a1404 100644 --- a/ios/MullvadVPN/Coordinators/App/AccountCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/App/AccountCoordinator.swift @@ -20,11 +20,11 @@ final class AccountCoordinator: Coordinator, Presentable, Presenting { let navigationController: UINavigationController var presentedViewController: UIViewController { - return navigationController + navigationController } var presentationContext: UIViewController { - return navigationController + navigationController } var didFinish: ((AccountCoordinator, AccountDismissReason) -> Void)? diff --git a/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift b/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift index 75272cd271..7707c18886 100644 --- a/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift @@ -21,8 +21,7 @@ private let preferredFormSheetContentSize = CGSize(width: 480, height: 640) */ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewControllerDelegate, UISplitViewControllerDelegate, ApplicationRouterDelegate, - NotificationManagerDelegate -{ + NotificationManagerDelegate { /** Application router. */ @@ -78,7 +77,7 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo private var outOfTimeTimer: Timer? var rootViewController: UIViewController { - return primaryNavigationContainer + primaryNavigationContainer } init( @@ -216,7 +215,7 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo _ router: ApplicationRouter, shouldDismissWithContext context: RouteDismissalContext ) -> Bool { - return context.dismissedRoutes.allSatisfy { dismissedRoute in + context.dismissedRoutes.allSatisfy { dismissedRoute in /* Prevent dismissal of "out of time" route in response to device state change when making payment. It will dismiss itself once done. @@ -436,7 +435,7 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo } private var isPad: Bool { - return UIDevice.current.userInterfaceIdiom == .pad + UIDevice.current.userInterfaceIdiom == .pad } private func setupSplitView() { @@ -555,7 +554,7 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo } private func shouldDismissOutOfTime() -> Bool { - return !(tunnelManager.deviceState.accountData?.isExpired ?? false) + !(tunnelManager.deviceState.accountData?.isExpired ?? false) } private func presentSelectLocation( @@ -600,8 +599,7 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo } private func makeSelectLocationCoordinator(forModalPresentation isModalPresentation: Bool) - -> SelectLocationCoordinator - { + -> SelectLocationCoordinator { let navigationController = CustomNavigationController() navigationController.isNavigationBarHidden = !isModalPresentation @@ -790,26 +788,24 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo /// Returns `true` if settings are being presented. var isPresentingSettings: Bool { - return router.isPresenting(.settings) + router.isPresenting(.settings) } /// Returns `true` if account controller is being presented. var isPresentingAccount: Bool { - return router.isPresenting(.account) + router.isPresenting(.account) } // MARK: - UISplitViewControllerDelegate func primaryViewController(forExpanding splitViewController: UISplitViewController) - -> UIViewController? - { - return splitLocationCoordinator?.navigationController + -> UIViewController? { + splitLocationCoordinator?.navigationController } func primaryViewController(forCollapsing splitViewController: UISplitViewController) - -> UIViewController? - { - return splitTunnelCoordinator?.rootViewController + -> UIViewController? { + splitTunnelCoordinator?.rootViewController } func splitViewController( @@ -817,14 +813,14 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController ) -> Bool { - return true + true } func splitViewController( _ splitViewController: UISplitViewController, separateSecondaryFrom primaryViewController: UIViewController ) -> UIViewController? { - return nil + nil } func splitViewControllerDidExpand(_ svc: UISplitViewController) { @@ -849,8 +845,7 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo } func rootContainerViewSupportedInterfaceOrientations(_ controller: RootContainerViewController) - -> UIInterfaceOrientationMask - { + -> UIInterfaceOrientationMask { if isPad { return [.landscape, .portrait] } else { @@ -859,8 +854,7 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo } func rootContainerViewAccessibilityPerformMagicTap(_ controller: RootContainerViewController) - -> Bool - { + -> Bool { guard tunnelManager.deviceState.isLoggedIn else { return false } switch tunnelManager.tunnelStatus.state { @@ -902,12 +896,12 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo // MARK: - Presenting var presentationContext: UIViewController { - return primaryNavigationContainer.presentedViewController ?? primaryNavigationContainer + primaryNavigationContainer.presentedViewController ?? primaryNavigationContainer } } extension DeviceState { var splitViewMode: UISplitViewController.DisplayMode { - return isLoggedIn ? .allVisible : .secondaryOnly + isLoggedIn ? .allVisible : .secondaryOnly } } diff --git a/ios/MullvadVPN/Coordinators/App/ApplicationRouter.swift b/ios/MullvadVPN/Coordinators/App/ApplicationRouter.swift index d1bf19b0a7..3ba14b77f3 100644 --- a/ios/MullvadVPN/Coordinators/App/ApplicationRouter.swift +++ b/ios/MullvadVPN/Coordinators/App/ApplicationRouter.swift @@ -59,7 +59,7 @@ enum AppRouteGroup: Comparable, Equatable, Hashable { } static func < (lhs: AppRouteGroup, rhs: AppRouteGroup) -> Bool { - return lhs.order < rhs.order + lhs.order < rhs.order } } @@ -347,7 +347,7 @@ final class ApplicationRouter { Returns `true` is the given route group is currently being presented. */ func isPresenting(_ group: AppRouteGroup) -> Bool { - return modalStack.contains(group) + modalStack.contains(group) } /** @@ -399,8 +399,7 @@ final class ApplicationRouter { Pass sub-route for routes supporting sub-navigation. */ if route.supportsSubNavigation, modalStack.contains(route.routeGroup), - var presentedRoute = presentedRoutes[route.routeGroup]?.first - { + var presentedRoute = presentedRoutes[route.routeGroup]?.first { let context = RouteSubnavigationContext( presentedRoute: presentedRoute, route: route, @@ -437,8 +436,7 @@ final class ApplicationRouter { Check if route can be presented above the last route in the modal stack. */ if let lastRouteGroup = modalStack.last, lastRouteGroup >= route.routeGroup, - route.routeGroup.isModal, route.isExclusive - { + route.routeGroup.isModal, route.isExclusive { completion(.blockedByModalContext) return } @@ -532,8 +530,7 @@ final class ApplicationRouter { if let lastModalGroup = modalStack.last, lastModalGroup != dismissRoute.routeGroup, dismissRoute.routeGroup.isModal, - isLastRoute - { + isLastRoute { completion(.blockedByModalAbove) return } @@ -569,7 +566,7 @@ final class ApplicationRouter { isProcessingPendingRoutes = true let pendingRoute = pendingRoutes.first { pendingRoute in - return !skipRouteGroups.contains(pendingRoute.operation.routeGroup) + !skipRouteGroups.contains(pendingRoute.operation.routeGroup) } guard let pendingRoute else { @@ -640,7 +637,7 @@ final class ApplicationRouter { var routes = presentedRoutes[route.routeGroup] ?? [] routes.removeAll { presentedRoute in - return presentedRoute.coordinator == coordinator + presentedRoute.coordinator == coordinator } if routes.isEmpty { diff --git a/ios/MullvadVPN/Coordinators/App/LoginCoordinator.swift b/ios/MullvadVPN/Coordinators/App/LoginCoordinator.swift index d8c9bd6d66..02946e1d53 100644 --- a/ios/MullvadVPN/Coordinators/App/LoginCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/App/LoginCoordinator.swift @@ -37,7 +37,7 @@ final class LoginCoordinator: Coordinator, DeviceManagementViewControllerDelegat let loginController = LoginViewController(interactor: interactor) loginController.didFinishLogin = { [weak self] action, error in - return self?.didFinishLogin(action: action, error: error) ?? .nothing + self?.didFinishLogin(action: action, error: error) ?? .nothing } navigationController.pushViewController(loginController, animated: animated) diff --git a/ios/MullvadVPN/Coordinators/App/SafariCoordinator.swift b/ios/MullvadVPN/Coordinators/App/SafariCoordinator.swift index 0d97bd6d3e..baad824d8d 100644 --- a/ios/MullvadVPN/Coordinators/App/SafariCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/App/SafariCoordinator.swift @@ -13,7 +13,7 @@ class SafariCoordinator: Coordinator, Presentable, SFSafariViewControllerDelegat var didFinish: (() -> Void)? var presentedViewController: UIViewController { - return safariController + safariController } private let safariController: SFSafariViewController diff --git a/ios/MullvadVPN/Coordinators/App/SelectLocationCoordinator.swift b/ios/MullvadVPN/Coordinators/App/SelectLocationCoordinator.swift index aab311c924..d29b8eea1b 100644 --- a/ios/MullvadVPN/Coordinators/App/SelectLocationCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/App/SelectLocationCoordinator.swift @@ -14,7 +14,7 @@ class SelectLocationCoordinator: Coordinator, Presentable, RelayCacheTrackerObse let navigationController: UINavigationController var presentedViewController: UIViewController { - return navigationController + navigationController } private let tunnelManager: TunnelManager diff --git a/ios/MullvadVPN/Coordinators/App/SettingsCoordinator.swift b/ios/MullvadVPN/Coordinators/App/SettingsCoordinator.swift index 743c1b1827..53ce4b3a27 100644 --- a/ios/MullvadVPN/Coordinators/App/SettingsCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/App/SettingsCoordinator.swift @@ -18,8 +18,7 @@ enum SettingsNavigationRoute: Equatable { } final class SettingsCoordinator: Coordinator, Presentable, Presenting, SettingsViewControllerDelegate, - UINavigationControllerDelegate -{ + UINavigationControllerDelegate { private let logger = Logger(label: "SettingsNavigationCoordinator") private let interactorFactory: SettingsInteractorFactory @@ -29,11 +28,11 @@ final class SettingsCoordinator: Coordinator, Presentable, Presenting, SettingsV let navigationController: UINavigationController var presentedViewController: UIViewController { - return navigationController + navigationController } var presentationContext: UIViewController { - return navigationController + navigationController } var willNavigate: (( @@ -61,8 +60,7 @@ final class SettingsCoordinator: Coordinator, Presentable, Presenting, SettingsV } if let initialRoute, initialRoute != .root, - let nextController = makeViewController(for: initialRoute) - { + let nextController = makeViewController(for: initialRoute) { navigationController.pushViewController(nextController, animated: false) } } diff --git a/ios/MullvadVPN/Coordinators/App/TermsOfServiceCoordinator.swift b/ios/MullvadVPN/Coordinators/App/TermsOfServiceCoordinator.swift index d37e7f1634..c8f9574e33 100644 --- a/ios/MullvadVPN/Coordinators/App/TermsOfServiceCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/App/TermsOfServiceCoordinator.swift @@ -12,7 +12,7 @@ class TermsOfServiceCoordinator: Coordinator, Presenting { private let navigationController: RootContainerViewController var presentationContext: UIViewController { - return navigationController + navigationController } var didFinish: ((TermsOfServiceCoordinator) -> Void)? diff --git a/ios/MullvadVPN/Coordinators/App/TunnelCoordinator.swift b/ios/MullvadVPN/Coordinators/App/TunnelCoordinator.swift index 771b6ea397..84158992cf 100644 --- a/ios/MullvadVPN/Coordinators/App/TunnelCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/App/TunnelCoordinator.swift @@ -16,7 +16,7 @@ class TunnelCoordinator: Coordinator { private var tunnelObserver: TunnelObserver? var rootViewController: UIViewController { - return controller + controller } var showSelectLocationPicker: (() -> Void)? diff --git a/ios/MullvadVPN/Coordinators/Base/Coordinator.swift b/ios/MullvadVPN/Coordinators/Base/Coordinator.swift index f6c27e4f20..a72f122257 100644 --- a/ios/MullvadVPN/Coordinators/Base/Coordinator.swift +++ b/ios/MullvadVPN/Coordinators/Base/Coordinator.swift @@ -33,12 +33,12 @@ class Coordinator: NSObject { /// Child coordinators. var childCoordinators: [Coordinator] { - return _children + _children } /// Parent coordinator. var parent: Coordinator? { - return _parent + _parent } // MARK: - Children diff --git a/ios/MullvadVPN/Coordinators/Base/PresentationControllerDismissalInterceptor.swift b/ios/MullvadVPN/Coordinators/Base/PresentationControllerDismissalInterceptor.swift index 89951f0665..90d92a8703 100644 --- a/ios/MullvadVPN/Coordinators/Base/PresentationControllerDismissalInterceptor.swift +++ b/ios/MullvadVPN/Coordinators/Base/PresentationControllerDismissalInterceptor.swift @@ -13,8 +13,7 @@ import UIKit `dismissHandler` closure. Forwards all delegate calls to the `forwardingTarget`. */ final class PresentationControllerDismissalInterceptor: NSObject, - UIAdaptivePresentationControllerDelegate -{ + UIAdaptivePresentationControllerDelegate { private let dismissHandler: (UIPresentationController) -> Void private let forwardingTarget: UIAdaptivePresentationControllerDelegate? private let protocolSelectors: [Selector] @@ -34,7 +33,7 @@ final class PresentationControllerDismissalInterceptor: NSObject, } override func responds(to aSelector: Selector!) -> Bool { - return super.responds(to: aSelector) || ( + super.responds(to: aSelector) || ( protocolSelectors.contains(aSelector) && forwardingTarget?.responds(to: aSelector) ?? false ) @@ -73,6 +72,6 @@ private func getProtocolMethods( defer { methodDescriptions.map { free($0) } } return (0 ..< methodCount).compactMap { index in - return methodDescriptions?[Int(index)].name + methodDescriptions?[Int(index)].name } } diff --git a/ios/MullvadVPN/Extensions/Bundle+ProductVersion.swift b/ios/MullvadVPN/Extensions/Bundle+ProductVersion.swift index 410811842f..cc739c163b 100644 --- a/ios/MullvadVPN/Extensions/Bundle+ProductVersion.swift +++ b/ios/MullvadVPN/Extensions/Bundle+ProductVersion.swift @@ -34,6 +34,6 @@ extension Bundle { /// Returns short version XXXX.YY (i.e 2020.5). var shortVersion: String { - return object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "???" + object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "???" } } diff --git a/ios/MullvadVPN/Extensions/CharacterSet+IPAddress.swift b/ios/MullvadVPN/Extensions/CharacterSet+IPAddress.swift index 2131398cc9..0568b9de61 100644 --- a/ios/MullvadVPN/Extensions/CharacterSet+IPAddress.swift +++ b/ios/MullvadVPN/Extensions/CharacterSet+IPAddress.swift @@ -10,10 +10,10 @@ import Foundation extension CharacterSet { static var ipv4AddressCharset: CharacterSet { - return CharacterSet(charactersIn: "0123456789.") + CharacterSet(charactersIn: "0123456789.") } static var ipv6AddressCharset: CharacterSet { - return CharacterSet(charactersIn: "0123456789abcdef:.") + CharacterSet(charactersIn: "0123456789abcdef:.") } } diff --git a/ios/MullvadVPN/Extensions/String+AccountFormatting.swift b/ios/MullvadVPN/Extensions/String+AccountFormatting.swift index a13446948b..cfa1a8c12d 100644 --- a/ios/MullvadVPN/Extensions/String+AccountFormatting.swift +++ b/ios/MullvadVPN/Extensions/String+AccountFormatting.swift @@ -10,6 +10,6 @@ import Foundation extension String { var formattedAccountNumber: String { - return split(every: 4).joined(separator: " ") + split(every: 4).joined(separator: " ") } } diff --git a/ios/MullvadVPN/Extensions/UIBarButtonItem+Blocks.swift b/ios/MullvadVPN/Extensions/UIBarButtonItem+Blocks.swift index 5fbc9d2f28..1d38a4c336 100644 --- a/ios/MullvadVPN/Extensions/UIBarButtonItem+Blocks.swift +++ b/ios/MullvadVPN/Extensions/UIBarButtonItem+Blocks.swift @@ -18,7 +18,7 @@ extension UIBarButtonItem { */ var actionHandler: ActionHandler? { get { - return objc_getAssociatedObject(self, &actionHandlerAssociatedKey) as? ActionHandler + objc_getAssociatedObject(self, &actionHandlerAssociatedKey) as? ActionHandler } set { objc_setAssociatedObject(self, &actionHandlerAssociatedKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) diff --git a/ios/MullvadVPN/Extensions/UIColor+Helpers.swift b/ios/MullvadVPN/Extensions/UIColor+Helpers.swift index a119f64660..f3c89ba889 100644 --- a/ios/MullvadVPN/Extensions/UIColor+Helpers.swift +++ b/ios/MullvadVPN/Extensions/UIColor+Helpers.swift @@ -11,7 +11,7 @@ import UIKit extension UIColor { /// Returns the color lighter by the given percent (in range from 0..1) func lightened(by percent: CGFloat) -> UIColor? { - return darkened(by: -percent) + darkened(by: -percent) } /// Returns the color darker by the given percent (in range from 0..1) @@ -33,5 +33,5 @@ extension UIColor { } private func clampColorComponent(_ value: CGFloat) -> CGFloat { - return min(1.0, max(value, 0.0)) + min(1.0, max(value, 0.0)) } diff --git a/ios/MullvadVPN/Extensions/UITextField+Appearance.swift b/ios/MullvadVPN/Extensions/UITextField+Appearance.swift index 706d3c8caa..16bfb0cf5e 100644 --- a/ios/MullvadVPN/Extensions/UITextField+Appearance.swift +++ b/ios/MullvadVPN/Extensions/UITextField+Appearance.swift @@ -16,7 +16,7 @@ extension UITextField { let leftViewTintColor: UIColor static var active: SearchTextFieldAppearance { - return SearchTextFieldAppearance( + SearchTextFieldAppearance( placeholderTextColor: .SearchTextField.placeholderTextColor, textColor: .SearchTextField.textColor, backgroundColor: .SearchTextField.backgroundColor, @@ -25,7 +25,7 @@ extension UITextField { } static var inactive: SearchTextFieldAppearance { - return SearchTextFieldAppearance( + SearchTextFieldAppearance( placeholderTextColor: .SearchTextField.inactivePlaceholderTextColor, textColor: .SearchTextField.inactiveTextColor, backgroundColor: .SearchTextField.inactiveBackgroundColor, diff --git a/ios/MullvadVPN/Extensions/UIView+AutoLayoutBuilder.swift b/ios/MullvadVPN/Extensions/UIView+AutoLayoutBuilder.swift index 6e5670f3c7..b32243f762 100644 --- a/ios/MullvadVPN/Extensions/UIView+AutoLayoutBuilder.swift +++ b/ios/MullvadVPN/Extensions/UIView+AutoLayoutBuilder.swift @@ -27,14 +27,14 @@ extension UIView { Pin all edges to edges of other view. */ func pinEdgesTo(_ other: AutoLayoutAnchorsProtocol) -> [NSLayoutConstraint] { - return pinEdges(.all(), to: other) + pinEdges(.all(), to: other) } /** Pin edges to edges of other view. */ func pinEdges(_ edges: PinnableEdges, to other: AutoLayoutAnchorsProtocol) -> [NSLayoutConstraint] { - return edges.makeConstraints(firstView: self, secondView: other) + edges.makeConstraints(firstView: self, secondView: other) } /** @@ -80,31 +80,31 @@ extension UIView { */ @resultBuilder enum AutoLayoutBuilder { static func buildBlock(_ components: [NSLayoutConstraint]...) -> [NSLayoutConstraint] { - return components.flatMap { $0 } + components.flatMap { $0 } } static func buildExpression(_ expression: NSLayoutConstraint) -> [NSLayoutConstraint] { - return [expression] + [expression] } static func buildExpression(_ expression: [NSLayoutConstraint]) -> [NSLayoutConstraint] { - return expression + expression } static func buildOptional(_ components: [NSLayoutConstraint]?) -> [NSLayoutConstraint] { - return components ?? [] + components ?? [] } static func buildEither(first components: [NSLayoutConstraint]) -> [NSLayoutConstraint] { - return components + components } static func buildEither(second components: [NSLayoutConstraint]) -> [NSLayoutConstraint] { - return components + components } static func buildArray(_ components: [[NSLayoutConstraint]]) -> [NSLayoutConstraint] { - return components.flatMap { $0 } + components.flatMap { $0 } } } @@ -180,7 +180,7 @@ struct PinnableEdges { } static func == (lhs: Self, rhs: Self) -> Bool { - return lhs.rectEdge == rhs.rectEdge + lhs.rectEdge == rhs.rectEdge } func makeConstraint( @@ -219,7 +219,7 @@ struct PinnableEdges { Returns new `PinnableEdges` with the given edge(s) excluded. */ func excluding(_ excludeEdges: NSDirectionalRectEdge) -> Self { - return Self(inner.filter { !excludeEdges.contains($0.rectEdge) }) + Self(inner.filter { !excludeEdges.contains($0.rectEdge) }) } /** @@ -227,7 +227,7 @@ struct PinnableEdges { `NSDirectionalEdgeInsets`. */ static func all(_ directionalEdgeInsets: NSDirectionalEdgeInsets = .zero) -> Self { - return Self([ + Self([ .top(directionalEdgeInsets.top), .bottom(directionalEdgeInsets.bottom), .leading(directionalEdgeInsets.leading), @@ -242,6 +242,6 @@ struct PinnableEdges { firstView: AutoLayoutAnchorsProtocol, secondView: AutoLayoutAnchorsProtocol ) -> [NSLayoutConstraint] { - return inner.map { $0.makeConstraint(firstView: firstView, secondView: secondView) } + inner.map { $0.makeConstraint(firstView: firstView, secondView: secondView) } } } diff --git a/ios/MullvadVPN/Notifications/InAppNotificationDescriptor.swift b/ios/MullvadVPN/Notifications/InAppNotificationDescriptor.swift index 89825e2447..7ed81c1e77 100644 --- a/ios/MullvadVPN/Notifications/InAppNotificationDescriptor.swift +++ b/ios/MullvadVPN/Notifications/InAppNotificationDescriptor.swift @@ -36,7 +36,7 @@ struct InAppNotificationAction: Equatable { var handler: (() -> Void)? static func == (lhs: InAppNotificationAction, rhs: InAppNotificationAction) -> Bool { - return lhs.image == rhs.image + lhs.image == rhs.image } } diff --git a/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift b/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift index 6babb863c4..520983371a 100644 --- a/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift +++ b/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift @@ -68,12 +68,12 @@ final class AccountExpirySystemNotificationProvider: NotificationProvider, Syste var shouldRemovePendingRequests: Bool { // Remove pending notifications when account expiry is not set (user logged out) - return shouldRemovePendingOrDeliveredRequests + shouldRemovePendingOrDeliveredRequests } var shouldRemoveDeliveredRequests: Bool { // Remove delivered notifications when account expiry is not set (user logged out) - return shouldRemovePendingOrDeliveredRequests + shouldRemovePendingOrDeliveredRequests } // MARK: - Private @@ -100,7 +100,7 @@ final class AccountExpirySystemNotificationProvider: NotificationProvider, Syste } private var shouldRemovePendingOrDeliveredRequests: Bool { - return accountExpiry == nil + accountExpiry == nil } private func invalidate(deviceState: DeviceState) { diff --git a/ios/MullvadVPN/Notifications/Notification Providers/RegisteredDeviceInAppNotificationProvider.swift b/ios/MullvadVPN/Notifications/Notification Providers/RegisteredDeviceInAppNotificationProvider.swift index 67317e30ad..b00b9f0834 100644 --- a/ios/MullvadVPN/Notifications/Notification Providers/RegisteredDeviceInAppNotificationProvider.swift +++ b/ios/MullvadVPN/Notifications/Notification Providers/RegisteredDeviceInAppNotificationProvider.swift @@ -11,8 +11,7 @@ import UIKit.UIColor import UIKit.UIFont final class RegisteredDeviceInAppNotificationProvider: NotificationProvider, - InAppNotificationProvider -{ + InAppNotificationProvider { // MARK: - private properties private let tunnelManager: TunnelManager @@ -84,16 +83,14 @@ final class RegisteredDeviceInAppNotificationProvider: NotificationProvider, tunnelObserver = TunnelBlockObserver(didUpdateDeviceState: { [weak self] tunnelManager, deviceState, previousDeviceState in if previousDeviceState == .loggedOut, - case .loggedIn = deviceState - { + case .loggedIn = deviceState { self?.isNewDeviceRegistered = true DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { [weak self] in self?.invalidate() } } else if case .loggedIn = previousDeviceState, - deviceState == .loggedOut || deviceState == .revoked - { + deviceState == .loggedOut || deviceState == .revoked { self?.isNewDeviceRegistered = false self?.invalidate() } diff --git a/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift b/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift index 9378e264bb..3cd792a150 100644 --- a/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift +++ b/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift @@ -16,7 +16,7 @@ final class TunnelStatusNotificationProvider: NotificationProvider, InAppNotific private var tunnelObserver: TunnelBlockObserver? override var identifier: NotificationProviderIdentifier { - return .tunnelStatusNotificationProvider + .tunnelStatusNotificationProvider } var notificationDescriptor: InAppNotificationDescriptor? { @@ -117,7 +117,7 @@ final class TunnelStatusNotificationProvider: NotificationProvider, InAppNotific } private func notificationDescription(for packetTunnelError: String) -> InAppNotificationDescriptor { - return InAppNotificationDescriptor( + InAppNotificationDescriptor( identifier: identifier, style: .error, title: NSLocalizedString( @@ -174,7 +174,7 @@ final class TunnelStatusNotificationProvider: NotificationProvider, InAppNotific } private func connectivityNotificationDescription() -> InAppNotificationDescriptor { - return InAppNotificationDescriptor( + InAppNotificationDescriptor( identifier: identifier, style: .warning, title: NSLocalizedString( @@ -196,7 +196,7 @@ final class TunnelStatusNotificationProvider: NotificationProvider, InAppNotific } private func noNetworkNotificationDescription() -> InAppNotificationDescriptor { - return InAppNotificationDescriptor( + InAppNotificationDescriptor( identifier: identifier, style: .warning, title: NSLocalizedString( diff --git a/ios/MullvadVPN/Notifications/NotificationManager.swift b/ios/MullvadVPN/Notifications/NotificationManager.swift index c40d7d2f49..a1b5949e5e 100644 --- a/ios/MullvadVPN/Notifications/NotificationManager.swift +++ b/ios/MullvadVPN/Notifications/NotificationManager.swift @@ -30,7 +30,7 @@ final class NotificationManager: NotificationProviderDelegate { _notificationProviders = newNotificationProviders } get { - return _notificationProviders + _notificationProviders } } @@ -218,13 +218,13 @@ final class NotificationManager: NotificationProviderDelegate { return replaceNotificationDescriptor } else { return inAppNotificationDescriptors.first { descriptor in - return descriptor.identifier == notificationProvider.identifier + descriptor.identifier == notificationProvider.identifier } } } } else { newNotificationDescriptors.removeAll { descriptor in - return descriptor.identifier == notificationProvider.identifier + descriptor.identifier == notificationProvider.identifier } } diff --git a/ios/MullvadVPN/Operations/ProductsRequestOperation.swift b/ios/MullvadVPN/Operations/ProductsRequestOperation.swift index 5138776fdb..faede2a70c 100644 --- a/ios/MullvadVPN/Operations/ProductsRequestOperation.swift +++ b/ios/MullvadVPN/Operations/ProductsRequestOperation.swift @@ -10,8 +10,7 @@ import Operations import StoreKit final class ProductsRequestOperation: ResultOperation<SKProductsResponse>, - SKProductsRequestDelegate -{ + SKProductsRequestDelegate { private let productIdentifiers: Set<String> private let maxRetryCount = 10 diff --git a/ios/MullvadVPN/Presentation controllers/FormsheetPresentationController.swift b/ios/MullvadVPN/Presentation controllers/FormsheetPresentationController.swift index d88202231d..b1a734932f 100644 --- a/ios/MullvadVPN/Presentation controllers/FormsheetPresentationController.swift +++ b/ios/MullvadVPN/Presentation controllers/FormsheetPresentationController.swift @@ -38,7 +38,7 @@ class FormSheetPresentationController: UIPresentationController { }() override var shouldRemovePresentersView: Bool { - return false + false } /** @@ -51,7 +51,7 @@ class FormSheetPresentationController: UIPresentationController { Returns `true` if presentation controller is in fullscreen presentation. */ var isInFullScreenPresentation: Bool { - return useFullScreenPresentationInCompactWidth && + useFullScreenPresentationInCompactWidth && traitCollection.horizontalSizeClass == .compact } @@ -185,13 +185,12 @@ class FormSheetTransitioningDelegate: NSObject, UIViewControllerTransitioningDel presenting: UIViewController, source: UIViewController ) -> UIViewControllerAnimatedTransitioning? { - return FormSheetPresentationAnimator() + FormSheetPresentationAnimator() } func animationController(forDismissed dismissed: UIViewController) - -> UIViewControllerAnimatedTransitioning? - { - return FormSheetPresentationAnimator() + -> UIViewControllerAnimatedTransitioning? { + FormSheetPresentationAnimator() } func presentationController( @@ -199,7 +198,7 @@ class FormSheetTransitioningDelegate: NSObject, UIViewControllerTransitioningDel presenting: UIViewController?, source: UIViewController ) -> UIPresentationController? { - return FormSheetPresentationController( + FormSheetPresentationController( presentedViewController: presented, presenting: source ) @@ -208,9 +207,8 @@ class FormSheetTransitioningDelegate: NSObject, UIViewControllerTransitioningDel class FormSheetPresentationAnimator: NSObject, UIViewControllerAnimatedTransitioning { func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) - -> TimeInterval - { - return (transitionContext?.isAnimated ?? true) ? UIMetrics.FormSheetTransition.duration : 0 + -> TimeInterval { + (transitionContext?.isAnimated ?? true) ? UIMetrics.FormSheetTransition.duration : 0 } func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { diff --git a/ios/MullvadVPN/Presentation controllers/SecondaryContextPresentationController.swift b/ios/MullvadVPN/Presentation controllers/SecondaryContextPresentationController.swift index b0a7686b4f..021e5ef76e 100644 --- a/ios/MullvadVPN/Presentation controllers/SecondaryContextPresentationController.swift +++ b/ios/MullvadVPN/Presentation controllers/SecondaryContextPresentationController.swift @@ -19,8 +19,7 @@ class SecondaryContextPresentationController: FormSheetPresentationController { updateHeaderBarHidden() if let containerView, - let rootContainer = presentingViewController as? RootContainerViewController - { + let rootContainer = presentingViewController as? RootContainerViewController { rootContainer.addTrailingButtonsToPresentationContainer(containerView) } } diff --git a/ios/MullvadVPN/RelayCacheTracker/RelayCacheTracker.swift b/ios/MullvadVPN/RelayCacheTracker/RelayCacheTracker.swift index 953645cd8d..34fb9a9e8f 100644 --- a/ios/MullvadVPN/RelayCacheTracker/RelayCacheTracker.swift +++ b/ios/MullvadVPN/RelayCacheTracker/RelayCacheTracker.swift @@ -94,8 +94,7 @@ final class RelayCacheTracker { } func updateRelays(completionHandler: ((Result<RelaysFetchResult, Error>) -> Void)? = nil) - -> Cancellable - { + -> Cancellable { let operation = ResultBlockOperation<RelaysFetchResult> { finish in let cachedRelays = try? self.getCachedRelays() @@ -168,9 +167,8 @@ final class RelayCacheTracker { } private func handleResponse(result: Result<REST.ServerRelaysCacheResponse, Error>) - -> Result<RelaysFetchResult, Error> - { - return result.tryMap { response -> RelaysFetchResult in + -> Result<RelaysFetchResult, Error> { + result.tryMap { response -> RelaysFetchResult in switch response { case let .newContent(etag, relays): try self.storeResponse(etag: etag, relays: relays) @@ -255,6 +253,6 @@ enum RelaysFetchResult: CustomStringConvertible { struct NoCachedRelaysError: LocalizedError { var errorDescription: String? { - return "Relay cache is empty." + "Relay cache is empty." } } diff --git a/ios/MullvadVPN/SceneDelegate.swift b/ios/MullvadVPN/SceneDelegate.swift index 290ead03a6..e625fc8200 100644 --- a/ios/MullvadVPN/SceneDelegate.swift +++ b/ios/MullvadVPN/SceneDelegate.swift @@ -27,11 +27,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, SettingsMigrationUIHand private var tunnelObserver: TunnelObserver? private var appDelegate: AppDelegate { - return UIApplication.shared.delegate as! AppDelegate + UIApplication.shared.delegate as! AppDelegate } private var tunnelManager: TunnelManager { - return appDelegate.tunnelManager + appDelegate.tunnelManager } // MARK: - Private @@ -220,8 +220,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, SettingsMigrationUIHand comment: "" ) } else if let error = error as? SettingsMigrationError, - error.underlyingError is REST.Error - { + error.underlyingError is REST.Error { return NSLocalizedString( "NETWORK_ERROR", tableName: "SettingsMigrationUI", diff --git a/ios/MullvadVPN/SettingsManager/DNSSettings.swift b/ios/MullvadVPN/SettingsManager/DNSSettings.swift index ce713d58ab..81e563f5de 100644 --- a/ios/MullvadVPN/SettingsManager/DNSSettings.swift +++ b/ios/MullvadVPN/SettingsManager/DNSSettings.swift @@ -64,7 +64,7 @@ struct DNSSettings: Codable, Equatable { /// Effective state of the custom DNS setting. var effectiveEnableCustomDNS: Bool { - return blockingOptions.isEmpty && enableCustomDNS && !customDNSDomains.isEmpty + blockingOptions.isEmpty && enableCustomDNS && !customDNSDomains.isEmpty } private enum CodingKeys: String, CodingKey { diff --git a/ios/MullvadVPN/SettingsManager/KeychainSettingsStore.swift b/ios/MullvadVPN/SettingsManager/KeychainSettingsStore.swift index eb662b8d11..00556b8ca5 100644 --- a/ios/MullvadVPN/SettingsManager/KeychainSettingsStore.swift +++ b/ios/MullvadVPN/SettingsManager/KeychainSettingsStore.swift @@ -34,7 +34,7 @@ class KeychainSettingsStore: SettingsStore { private func addItem(_ item: SettingsKey, data: Data) throws { var query = createDefaultAttributes(item: item) query.merge(createAccessAttributes()) { current, _ in - return current + current } query[kSecValueData] = data @@ -89,7 +89,7 @@ class KeychainSettingsStore: SettingsStore { } private func createDefaultAttributes(item: SettingsKey) -> [CFString: Any] { - return [ + [ kSecClass: kSecClassGenericPassword, kSecAttrService: serviceName, kSecAttrAccount: item.rawValue, @@ -97,7 +97,7 @@ class KeychainSettingsStore: SettingsStore { } private func createAccessAttributes() -> [CFString: Any] { - return [ + [ kSecAttrAccessGroup: accessGroup, kSecAttrAccessible: kSecAttrAccessibleAfterFirstUnlock, ] diff --git a/ios/MullvadVPN/SettingsManager/Migrations/MigrationFromV1ToV2.swift b/ios/MullvadVPN/SettingsManager/Migrations/MigrationFromV1ToV2.swift index 9404febc9a..1cb53a9229 100644 --- a/ios/MullvadVPN/SettingsManager/Migrations/MigrationFromV1ToV2.swift +++ b/ios/MullvadVPN/SettingsManager/Migrations/MigrationFromV1ToV2.swift @@ -104,7 +104,7 @@ final class MigrationFromV1ToV2: Migration { // Find device that matches the public key stored in legacy settings. let device = devices.first { device in - return device.pubkey == interfaceData.privateKey.publicKey || + device.pubkey == interfaceData.privateKey.publicKey || device.pubkey == interfaceData.nextPrivateKey?.publicKey } diff --git a/ios/MullvadVPN/SettingsManager/SettingsManager.swift b/ios/MullvadVPN/SettingsManager/SettingsManager.swift index 0256d6184c..90adf20d68 100644 --- a/ios/MullvadVPN/SettingsManager/SettingsManager.swift +++ b/ios/MullvadVPN/SettingsManager/SettingsManager.swift @@ -35,7 +35,7 @@ enum SettingsManager { ) private static func makeParser() -> SettingsParser { - return SettingsParser(decoder: JSONDecoder(), encoder: JSONEncoder()) + SettingsParser(decoder: JSONDecoder(), encoder: JSONEncoder()) } // MARK: - Last used account @@ -71,7 +71,7 @@ enum SettingsManager { // MARK: - Should wipe settings static func getShouldWipeSettings() -> Bool { - return (try? store.read(key: .shouldWipeSettings)) != nil + (try? store.read(key: .shouldWipeSettings)) != nil } static func setShouldWipeSettings() { @@ -300,7 +300,7 @@ enum SettingsManager { // Find settings matching the account number stored in user defaults. let matchingSettings = storedSettings.first { settings in - return settings.accountNumber == storedAccountNumber + settings.accountNumber == storedAccountNumber } guard let matchingSettings else { @@ -452,11 +452,11 @@ struct ReadSettingsVersionError: LocalizedError, WrappingError { private let inner: Error var underlyingError: Error? { - return inner + inner } var errorDescription: String? { - return "Failed to read settings version." + "Failed to read settings version." } init(underlyingError: Error) { @@ -470,7 +470,7 @@ struct UnsupportedSettingsVersionError: LocalizedError { let currentVersion: SchemaVersion var errorDescription: String? { - return """ + """ Stored settings version was not the same as current version, \ stored version: \(storedVersion), current version: \(currentVersion) """ @@ -483,11 +483,11 @@ struct SettingsMigrationError: LocalizedError, WrappingError { let sourceVersion, targetVersion: SchemaVersion var underlyingError: Error? { - return inner + inner } var errorDescription: String? { - return "Failed to migrate settings from \(sourceVersion) to \(targetVersion)." + "Failed to migrate settings from \(sourceVersion) to \(targetVersion)." } init(sourceVersion: SchemaVersion, targetVersion: SchemaVersion, underlyingError: Error) { @@ -501,7 +501,7 @@ struct StringDecodingError: LocalizedError { let data: Data var errorDescription: String? { - return "Failed to decode string from data." + "Failed to decode string from data." } } @@ -509,6 +509,6 @@ struct StringEncodingError: LocalizedError { let string: String var errorDescription: String? { - return "Failed to encode string into data." + "Failed to encode string into data." } } diff --git a/ios/MullvadVPN/SettingsManager/SettingsParser.swift b/ios/MullvadVPN/SettingsManager/SettingsParser.swift index 5b097958d6..60199afb51 100644 --- a/ios/MullvadVPN/SettingsManager/SettingsParser.swift +++ b/ios/MullvadVPN/SettingsManager/SettingsParser.swift @@ -35,12 +35,12 @@ struct SettingsParser { /// Produces versioned data encoded as the given type func producePayload(_ payload: some Codable, version: Int) throws -> Data { - return try encoder.encode(VersionedPayload(version: version, data: payload)) + try encoder.encode(VersionedPayload(version: version, data: payload)) } /// Produces unversioned data encoded as the given type func produceUnversionedPayload(_ payload: some Codable) throws -> Data { - return try encoder.encode(payload) + try encoder.encode(payload) } /// Returns settings version if found inside the stored data. @@ -55,7 +55,7 @@ struct SettingsParser { as type: T.Type, from data: Data ) throws -> T { - return try decoder.decode(T.self, from: data) + try decoder.decode(T.self, from: data) } /// Returns data from versioned payload parsed as the given type. @@ -63,6 +63,6 @@ struct SettingsParser { as type: T.Type, from data: Data ) throws -> T { - return try decoder.decode(Payload<T>.self, from: data).data + try decoder.decode(Payload<T>.self, from: data).data } } diff --git a/ios/MullvadVPN/SettingsManager/TunnelSettingsV1.swift b/ios/MullvadVPN/SettingsManager/TunnelSettingsV1.swift index f5c0ed8bc1..da93003268 100644 --- a/ios/MullvadVPN/SettingsManager/TunnelSettingsV1.swift +++ b/ios/MullvadVPN/SettingsManager/TunnelSettingsV1.swift @@ -84,7 +84,7 @@ struct PrivateKeyWithMetadata: Equatable, Codable { /// Public key var publicKey: PublicKey { - return privateKey.publicKey + privateKey.publicKey } /// Initialize the new private key diff --git a/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift b/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift index a86c1ee199..b7b94948b7 100644 --- a/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift +++ b/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift @@ -45,7 +45,7 @@ struct StoredAccountData: Codable, Equatable { /// Returns `true` if account has expired. var isExpired: Bool { - return expiry <= Date() + expiry <= Date() } } @@ -111,7 +111,7 @@ struct StoredDeviceData: Codable, Equatable { /// Returns capitalized device name. var capitalizedName: String { - return name.capitalized + name.capitalized } /// Fill in part of the structure that contains device related properties from `Device` struct. diff --git a/ios/MullvadVPN/SimulatorTunnelProvider/SimulatorTunnelProvider.swift b/ios/MullvadVPN/SimulatorTunnelProvider/SimulatorTunnelProvider.swift index cf0ee46968..79b5f03b0e 100644 --- a/ios/MullvadVPN/SimulatorTunnelProvider/SimulatorTunnelProvider.swift +++ b/ios/MullvadVPN/SimulatorTunnelProvider/SimulatorTunnelProvider.swift @@ -54,12 +54,12 @@ class SimulatorTunnelProviderDelegate { fileprivate(set) var connection: SimulatorVPNConnection? var protocolConfiguration: NEVPNProtocol { - return connection?.protocolConfiguration ?? NEVPNProtocol() + connection?.protocolConfiguration ?? NEVPNProtocol() } var reasserting: Bool { get { - return connection?.reasserting ?? false + connection?.reasserting ?? false } set { connection?.reasserting = newValue @@ -354,7 +354,7 @@ final class SimulatorTunnelProviderManager: NSObject, VPNTunnelProviderManagerPr ) -> Void) { Self.tunnelsLock.lock() let tunnelProviders = tunnels.map { tunnelInfo in - return SimulatorTunnelProviderManager(tunnelInfo: tunnelInfo) + SimulatorTunnelProviderManager(tunnelInfo: tunnelInfo) } Self.tunnelsLock.unlock() diff --git a/ios/MullvadVPN/StorePaymentManager/SendStoreReceiptOperation.swift b/ios/MullvadVPN/StorePaymentManager/SendStoreReceiptOperation.swift index e78c9993a8..f2822ec79e 100644 --- a/ios/MullvadVPN/StorePaymentManager/SendStoreReceiptOperation.swift +++ b/ios/MullvadVPN/StorePaymentManager/SendStoreReceiptOperation.swift @@ -122,8 +122,7 @@ class SendStoreReceiptOperation: ResultOperation<REST.CreateApplePaymentResponse do { return try Data(contentsOf: appStoreReceiptURL) } catch let error as CocoaError - where error.code == .fileReadNoSuchFile || error.code == .fileNoSuchFile - { + where error.code == .fileReadNoSuchFile || error.code == .fileNoSuchFile { throw StoreReceiptNotFound() } catch { throw error @@ -165,6 +164,6 @@ class SendStoreReceiptOperation: ResultOperation<REST.CreateApplePaymentResponse struct StoreReceiptNotFound: LocalizedError { var errorDescription: String? { - return "AppStore receipt file does not exist on disk." + "AppStore receipt file does not exist on disk." } } diff --git a/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift b/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift index 2ec6331fe8..1474559aff 100644 --- a/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift +++ b/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift @@ -40,7 +40,7 @@ final class StorePaymentManager: NSObject, SKPaymentTransactionObserver { return classDelegate } else { return DispatchQueue.main.sync { - return classDelegate + classDelegate } } } @@ -60,7 +60,7 @@ final class StorePaymentManager: NSObject, SKPaymentTransactionObserver { /// Returns true if the device is able to make payments. class var canMakePayments: Bool { - return SKPaymentQueue.canMakePayments() + SKPaymentQueue.canMakePayments() } init( @@ -151,7 +151,7 @@ final class StorePaymentManager: NSObject, SKPaymentTransactionObserver { for accountNumber: String, completionHandler: @escaping (Result<REST.CreateApplePaymentResponse, Error>) -> Void ) -> Cancellable { - return sendStoreReceipt( + sendStoreReceipt( accountNumber: accountNumber, forceRefresh: true, completionHandler: completionHandler @@ -182,7 +182,7 @@ final class StorePaymentManager: NSObject, SKPaymentTransactionObserver { completionHandler: @escaping (StorePaymentManagerError?) -> Void ) { let accountOperation = ResultBlockOperation<Account>(dispatchQueue: .main) { finish in - return self.accountsProxy.getAccountData( + self.accountsProxy.getAccountData( accountNumber: accountNumber, retryStrategy: .default, completion: finish diff --git a/ios/MullvadVPN/StorePaymentManager/StoreSubscription.swift b/ios/MullvadVPN/StorePaymentManager/StoreSubscription.swift index 9834e946f1..f20a2d4e2d 100644 --- a/ios/MullvadVPN/StorePaymentManager/StoreSubscription.swift +++ b/ios/MullvadVPN/StorePaymentManager/StoreSubscription.swift @@ -28,12 +28,12 @@ enum StoreSubscription: String { extension SKProduct { var customLocalizedTitle: String? { - return StoreSubscription(rawValue: productIdentifier)?.localizedTitle + StoreSubscription(rawValue: productIdentifier)?.localizedTitle } } extension Set<StoreSubscription> { var productIdentifiersSet: Set<String> { - return Set<String>(map { $0.rawValue }) + Set<String>(map { $0.rawValue }) } } diff --git a/ios/MullvadVPN/TransportMonitor/PacketTunnelTransport.swift b/ios/MullvadVPN/TransportMonitor/PacketTunnelTransport.swift index b1c3fea1e7..e9478d6502 100644 --- a/ios/MullvadVPN/TransportMonitor/PacketTunnelTransport.swift +++ b/ios/MullvadVPN/TransportMonitor/PacketTunnelTransport.swift @@ -15,7 +15,7 @@ import TunnelProviderMessaging struct PacketTunnelTransport: RESTTransport { var name: String { - return "packet-tunnel" + "packet-tunnel" } let tunnel: Tunnel diff --git a/ios/MullvadVPN/TransportMonitor/TransportMonitor.swift b/ios/MullvadVPN/TransportMonitor/TransportMonitor.swift index 395b4e1eaf..4abf5cf43b 100644 --- a/ios/MullvadVPN/TransportMonitor/TransportMonitor.swift +++ b/ios/MullvadVPN/TransportMonitor/TransportMonitor.swift @@ -51,7 +51,7 @@ final class TransportMonitor: RESTTransport { /// - Returns: A transport to use for sending an `URLRequest` private func selectTransport(_ transport: RESTTransport) -> RESTTransport { let tunnel = tunnelStore.getPersistentTunnels().first { tunnel in - return tunnel.status == .connecting || + tunnel.status == .connecting || tunnel.status == .reasserting || tunnel.status == .connected } diff --git a/ios/MullvadVPN/TunnelManager/LoadTunnelConfigurationOperation.swift b/ios/MullvadVPN/TunnelManager/LoadTunnelConfigurationOperation.swift index 2303f70350..89aa391965 100644 --- a/ios/MullvadVPN/TunnelManager/LoadTunnelConfigurationOperation.swift +++ b/ios/MullvadVPN/TunnelManager/LoadTunnelConfigurationOperation.swift @@ -58,7 +58,7 @@ class LoadTunnelConfigurationOperation: ResultOperation<Void> { } private func readSettings() -> Result<TunnelSettingsV2?, Error> { - return Result { try SettingsManager.readSettings() } + Result { try SettingsManager.readSettings() } .flatMapError { error in if let error = error as? KeychainError, error == .itemNotFound { logger.debug("Settings not found in keychain.") @@ -76,7 +76,7 @@ class LoadTunnelConfigurationOperation: ResultOperation<Void> { } private func readDeviceState() -> Result<DeviceState?, Error> { - return Result { try SettingsManager.readDeviceState() } + Result { try SettingsManager.readDeviceState() } .flatMapError { error in if let error = error as? KeychainError, error == .itemNotFound { logger.debug("Device state not found in keychain.") diff --git a/ios/MullvadVPN/TunnelManager/SendTunnelProviderMessageOperation.swift b/ios/MullvadVPN/TunnelManager/SendTunnelProviderMessageOperation.swift index 24c44f6e94..654274f78b 100644 --- a/ios/MullvadVPN/TunnelManager/SendTunnelProviderMessageOperation.swift +++ b/ios/MullvadVPN/TunnelManager/SendTunnelProviderMessageOperation.swift @@ -301,6 +301,6 @@ enum SendTunnelProviderMessageError: LocalizedError, WrappingError { struct EmptyTunnelProviderResponseError: LocalizedError { var errorDescription: String? { - return "Unexpected empty (nil) response from the tunnel." + "Unexpected empty (nil) response from the tunnel." } } diff --git a/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift b/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift index 349487014a..154734c279 100644 --- a/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift +++ b/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift @@ -384,8 +384,8 @@ class SetAccountOperation: ResultOperation<StoredAccountData?> { dispatchQueue.async { [self] in let result = result .flatMap { devices in - return .success(devices.first { device in - return device.pubkey == publicKey + .success(devices.first { device in + device.pubkey == publicKey }) } .inspectError { error in diff --git a/ios/MullvadVPN/TunnelManager/Tunnel.swift b/ios/MullvadVPN/TunnelManager/Tunnel.swift index c06e1f20f9..fa830f1298 100644 --- a/ios/MullvadVPN/TunnelManager/Tunnel.swift +++ b/ios/MullvadVPN/TunnelManager/Tunnel.swift @@ -58,13 +58,13 @@ final class Tunnel: Equatable { /// Tunnel connection status. var status: NEVPNStatus { - return tunnelProvider.connection.status + tunnelProvider.connection.status } /// Whether on-demand VPN is enabled. var isOnDemandEnabled: Bool { get { - return tunnelProvider.isOnDemandEnabled + tunnelProvider.isOnDemandEnabled } set { tunnelProvider.isOnDemandEnabled = newValue @@ -194,7 +194,7 @@ final class Tunnel: Equatable { } static func == (lhs: Tunnel, rhs: Tunnel) -> Bool { - return lhs.tunnelProvider == rhs.tunnelProvider + lhs.tunnelProvider == rhs.tunnelProvider } } diff --git a/ios/MullvadVPN/TunnelManager/TunnelManager.swift b/ios/MullvadVPN/TunnelManager/TunnelManager.swift index 49f1bc18e8..e71093bd70 100644 --- a/ios/MullvadVPN/TunnelManager/TunnelManager.swift +++ b/ios/MullvadVPN/TunnelManager/TunnelManager.swift @@ -37,7 +37,7 @@ final class TunnelManager: StorePaymentObserver { case tunnelStateUpdate var category: String { - return "TunnelManager.\(rawValue)" + "TunnelManager.\(rawValue)" } } @@ -1162,15 +1162,15 @@ private struct TunnelInteractorProxy: TunnelInteractor { } var tunnel: Tunnel? { - return tunnelManager.tunnel + tunnelManager.tunnel } func getPersistentTunnels() -> [Tunnel] { - return tunnelManager.tunnelStore.getPersistentTunnels() + tunnelManager.tunnelStore.getPersistentTunnels() } func createNewTunnel() -> Tunnel { - return tunnelManager.tunnelStore.createNewTunnel() + tunnelManager.tunnelStore.createNewTunnel() } func setTunnel(_ tunnel: Tunnel?, shouldRefreshTunnelState: Bool) { @@ -1178,23 +1178,23 @@ private struct TunnelInteractorProxy: TunnelInteractor { } var tunnelStatus: TunnelStatus { - return tunnelManager.tunnelStatus + tunnelManager.tunnelStatus } func updateTunnelStatus(_ block: (inout TunnelStatus) -> Void) -> TunnelStatus { - return tunnelManager.setTunnelStatus(block) + tunnelManager.setTunnelStatus(block) } var isConfigurationLoaded: Bool { - return tunnelManager.isConfigurationLoaded + tunnelManager.isConfigurationLoaded } var settings: TunnelSettingsV2 { - return tunnelManager.settings + tunnelManager.settings } var deviceState: DeviceState { - return tunnelManager.deviceState + tunnelManager.deviceState } func setConfigurationLoaded() { @@ -1218,7 +1218,7 @@ private struct TunnelInteractorProxy: TunnelInteractor { } func selectRelay() throws -> RelaySelectorResult { - return try tunnelManager.selectRelay() + try tunnelManager.selectRelay() } func handleRestError(_ error: Error) { diff --git a/ios/MullvadVPN/TunnelManager/TunnelManagerErrors.swift b/ios/MullvadVPN/TunnelManager/TunnelManagerErrors.swift index 8b5301c0ff..2073b6badd 100644 --- a/ios/MullvadVPN/TunnelManager/TunnelManagerErrors.swift +++ b/ios/MullvadVPN/TunnelManager/TunnelManagerErrors.swift @@ -11,7 +11,7 @@ import MullvadTypes struct UnsetTunnelError: LocalizedError { var errorDescription: String? { - return NSLocalizedString( + NSLocalizedString( "UNSET_TUNNEL_ERROR", tableName: "TunnelManager", value: "Tunnel is unset.", @@ -22,7 +22,7 @@ struct UnsetTunnelError: LocalizedError { struct InvalidDeviceStateError: LocalizedError { var errorDescription: String? { - return NSLocalizedString( + NSLocalizedString( "INVALID_DEVICE_STATE_ERROR", tableName: "TunnelManager", value: "Invalid device state.", @@ -35,7 +35,7 @@ struct StartTunnelError: LocalizedError, WrappingError { private let _underlyingError: Error var errorDescription: String? { - return NSLocalizedString( + NSLocalizedString( "START_TUNNEL_ERROR", tableName: "TunnelManager", value: "Failed to start the tunnel.", @@ -44,7 +44,7 @@ struct StartTunnelError: LocalizedError, WrappingError { } var underlyingError: Error? { - return _underlyingError + _underlyingError } init(underlyingError: Error) { @@ -56,7 +56,7 @@ struct StopTunnelError: LocalizedError, WrappingError { private let _underlyingError: Error var errorDescription: String? { - return NSLocalizedString( + NSLocalizedString( "STOP_TUNNEL_ERROR", tableName: "TunnelManager", value: "Failed to stop the tunnel.", @@ -65,7 +65,7 @@ struct StopTunnelError: LocalizedError, WrappingError { } var underlyingError: Error? { - return _underlyingError + _underlyingError } init(underlyingError: Error) { diff --git a/ios/MullvadVPN/TunnelManager/WgKeyRotation.swift b/ios/MullvadVPN/TunnelManager/WgKeyRotation.swift index e6191af64f..21356091ab 100644 --- a/ios/MullvadVPN/TunnelManager/WgKeyRotation.swift +++ b/ios/MullvadVPN/TunnelManager/WgKeyRotation.swift @@ -103,7 +103,7 @@ struct WgKeyRotation { /// Returns `true` if the app should rotate the private key. var shouldRotate: Bool { - return nextRotationDate <= Date() + nextRotationDate <= Date() } /** diff --git a/ios/MullvadVPN/View controllers/Account/AccountContentView.swift b/ios/MullvadVPN/View controllers/Account/AccountContentView.swift index b450e378b4..813fa51867 100644 --- a/ios/MullvadVPN/View controllers/Account/AccountContentView.swift +++ b/ios/MullvadVPN/View controllers/Account/AccountContentView.swift @@ -322,7 +322,7 @@ class AccountNumberRow: UIView { if isObscured { return String(formattedString.map { ch in - return ch == " " ? ch : "•" + ch == " " ? ch : "•" }) } else { return formattedString @@ -459,7 +459,7 @@ class AccountExpiryRow: UIView { valueLabel.textColor = .dangerColor } else { let formattedDate = expiry.map { date in - return DateFormatter.localizedString( + DateFormatter.localizedString( from: date, dateStyle: .medium, timeStyle: .short diff --git a/ios/MullvadVPN/View controllers/Account/AccountInteractor.swift b/ios/MullvadVPN/View controllers/Account/AccountInteractor.swift index 52060df828..3b14c62c02 100644 --- a/ios/MullvadVPN/View controllers/Account/AccountInteractor.swift +++ b/ios/MullvadVPN/View controllers/Account/AccountInteractor.swift @@ -43,7 +43,7 @@ final class AccountInteractor { } var deviceState: DeviceState { - return tunnelManager.deviceState + tunnelManager.deviceState } func logout(_ completion: @escaping () -> Void) { @@ -58,7 +58,7 @@ final class AccountInteractor { for accountNumber: String, completionHandler: @escaping (Result<REST.CreateApplePaymentResponse, Error>) -> Void ) -> Cancellable { - return storePaymentManager.restorePurchases( + storePaymentManager.restorePurchases( for: accountNumber, completionHandler: completionHandler ) @@ -68,7 +68,7 @@ final class AccountInteractor { with productIdentifiers: Set<StoreSubscription>, completionHandler: @escaping (Result<SKProductsResponse, Error>) -> Void ) -> Cancellable { - return storePaymentManager.requestProducts( + storePaymentManager.requestProducts( with: productIdentifiers, completionHandler: completionHandler ) diff --git a/ios/MullvadVPN/View controllers/Account/AccountViewController.swift b/ios/MullvadVPN/View controllers/Account/AccountViewController.swift index 7d6222a640..6d40d383ad 100644 --- a/ios/MullvadVPN/View controllers/Account/AccountViewController.swift +++ b/ios/MullvadVPN/View controllers/Account/AccountViewController.swift @@ -51,7 +51,7 @@ class AccountViewController: UIViewController { // MARK: - View lifecycle override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } override func viewDidLoad() { diff --git a/ios/MullvadVPN/View controllers/Account/PaymentAlertPresenter.swift b/ios/MullvadVPN/View controllers/Account/PaymentAlertPresenter.swift index 64908b723d..8d120a6a5b 100644 --- a/ios/MullvadVPN/View controllers/Account/PaymentAlertPresenter.swift +++ b/ios/MullvadVPN/View controllers/Account/PaymentAlertPresenter.swift @@ -66,7 +66,7 @@ class PaymentAlertPresenter { } private func okButtonTextForKey(_ key: String) -> String { - return NSLocalizedString( + NSLocalizedString( key, tableName: "Payment", value: "Got it!", diff --git a/ios/MullvadVPN/View controllers/ChangeLog/ChangeLogViewController.swift b/ios/MullvadVPN/View controllers/ChangeLog/ChangeLogViewController.swift index 2a1279e6fd..044e1cb851 100644 --- a/ios/MullvadVPN/View controllers/ChangeLog/ChangeLogViewController.swift +++ b/ios/MullvadVPN/View controllers/ChangeLog/ChangeLogViewController.swift @@ -12,11 +12,11 @@ class ChangeLogViewController: UIViewController, RootContainment { // MARK: - RootContainment var preferredHeaderBarPresentation: HeaderBarPresentation { - return HeaderBarPresentation(style: .default, showsDivider: false) + HeaderBarPresentation(style: .default, showsDivider: false) } var prefersHeaderBarHidden: Bool { - return false + false } // MARK: - Public @@ -36,7 +36,7 @@ class ChangeLogViewController: UIViewController, RootContainment { private let contentView = ChangeLogContentView() override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } override func loadView() { diff --git a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementContentView.swift b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementContentView.swift index 1305685ad8..da010ad687 100644 --- a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementContentView.swift +++ b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementContentView.swift @@ -187,7 +187,7 @@ class DeviceManagementContentView: UIView { func setDeviceViewModels(_ newModels: [DeviceViewModel], animated: Bool) { let difference = newModels.difference(from: currentDeviceModels) { newModel, model in - return newModel.id == model.id + newModel.id == model.id } currentDeviceModels = newModels diff --git a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementInteractor.swift b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementInteractor.swift index 501bc2bc6e..5f9065a006 100644 --- a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementInteractor.swift +++ b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementInteractor.swift @@ -22,7 +22,7 @@ class DeviceManagementInteractor { @discardableResult func getDevices(_ completionHandler: @escaping (Result<[Device], Error>) -> Void) -> Cancellable { - return devicesProxy.getDevices( + devicesProxy.getDevices( accountNumber: accountNumber, retryStrategy: .default, completion: completionHandler @@ -31,7 +31,7 @@ class DeviceManagementInteractor { @discardableResult func deleteDevice(_ identifier: String, completionHandler: @escaping (Result<Bool, Error>) -> Void) -> Cancellable { - return devicesProxy.deleteDevice( + devicesProxy.deleteDevice( accountNumber: accountNumber, identifier: identifier, retryStrategy: .default, diff --git a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift index f76e202874..fa8e1f0945 100644 --- a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift +++ b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementViewController.swift @@ -21,15 +21,15 @@ class DeviceManagementViewController: UIViewController, RootContainment { weak var delegate: DeviceManagementViewControllerDelegate? var preferredHeaderBarPresentation: HeaderBarPresentation { - return .default + .default } var prefersHeaderBarHidden: Bool { - return false + false } override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } private let alertPresenter = AlertPresenter() @@ -103,7 +103,7 @@ class DeviceManagementViewController: UIViewController, RootContainment { private func setDevices(_ devices: [Device], animated: Bool) { let viewModels = devices.map { restDevice -> DeviceViewModel in - return DeviceViewModel( + DeviceViewModel( id: restDevice.id, name: restDevice.name.capitalized, creationDate: DateFormatter.localizedString( diff --git a/ios/MullvadVPN/View controllers/Launch/LaunchViewController.swift b/ios/MullvadVPN/View controllers/Launch/LaunchViewController.swift index 02218244d5..30fe66c636 100644 --- a/ios/MullvadVPN/View controllers/Launch/LaunchViewController.swift +++ b/ios/MullvadVPN/View controllers/Launch/LaunchViewController.swift @@ -10,7 +10,7 @@ import UIKit class LaunchViewController: UIViewController { override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } init() { diff --git a/ios/MullvadVPN/View controllers/Login/AccountInputGroupView.swift b/ios/MullvadVPN/View controllers/Login/AccountInputGroupView.swift index ec298656ca..a16cd3c9d2 100644 --- a/ios/MullvadVPN/View controllers/Login/AccountInputGroupView.swift +++ b/ios/MullvadVPN/View controllers/Login/AccountInputGroupView.swift @@ -31,15 +31,15 @@ final class AccountInputGroupView: UIView { }() var textField: UITextField { - return privateTextField + privateTextField } var parsedToken: String { - return privateTextField.parsedToken + privateTextField.parsedToken } var satisfiesMinimumTokenLengthRequirement: Bool { - return privateTextField.parsedToken.count > minimumAccountTokenLength + privateTextField.parsedToken.count > minimumAccountTokenLength } var didRemoveLastUsedAccount: (() -> Void)? @@ -398,7 +398,7 @@ final class AccountInputGroupView: UIView { // MARK: - Private private static func accountNumberFont() -> UIFont { - return UIFont.monospacedSystemFont(ofSize: 20, weight: .regular) + UIFont.monospacedSystemFont(ofSize: 20, weight: .regular) } private func addTextFieldNotificationObservers() { @@ -492,8 +492,7 @@ final class AccountInputGroupView: UIView { bottomRowView.accessibilityElementsHidden = !shouldShow if lastUsedAccountButton.accessibilityElementIsFocused() || - removeLastUsedAccountButton.accessibilityElementIsFocused() - { + removeLastUsedAccountButton.accessibilityElementIsFocused() { UIAccessibility.post(notification: .layoutChanged, argument: textField) } } diff --git a/ios/MullvadVPN/View controllers/Login/AccountTextField.swift b/ios/MullvadVPN/View controllers/Login/AccountTextField.swift index cf3412ab6c..aa04abd8a8 100644 --- a/ios/MullvadVPN/View controllers/Login/AccountTextField.swift +++ b/ios/MullvadVPN/View controllers/Login/AccountTextField.swift @@ -50,7 +50,7 @@ class AccountTextField: CustomTextField, UITextFieldDelegate { } var parsedToken: String { - return inputFormatter.string + inputFormatter.string } var enableReturnKey = true { @@ -75,7 +75,7 @@ class AccountTextField: CustomTextField, UITextFieldDelegate { shouldChangeCharactersIn range: NSRange, replacementString string: String ) -> Bool { - return inputFormatter.textField( + inputFormatter.textField( textField, shouldChangeCharactersIn: range, replacementString: string @@ -83,7 +83,7 @@ class AccountTextField: CustomTextField, UITextFieldDelegate { } func textFieldShouldReturn(_ textField: UITextField) -> Bool { - return onReturnKey?(self) ?? true + onReturnKey?(self) ?? true } // MARK: - Notifications diff --git a/ios/MullvadVPN/View controllers/Login/LoginViewController.swift b/ios/MullvadVPN/View controllers/Login/LoginViewController.swift index ce66a3ab7f..1e30788921 100644 --- a/ios/MullvadVPN/View controllers/Login/LoginViewController.swift +++ b/ios/MullvadVPN/View controllers/Login/LoginViewController.swift @@ -84,7 +84,7 @@ class LoginViewController: UIViewController, RootContainment { } private var canBeginLogin: Bool { - return contentView.accountInputGroup.satisfiesMinimumTokenLengthRequirement + contentView.accountInputGroup.satisfiesMinimumTokenLengthRequirement } private let interactor: LoginInteractor @@ -92,15 +92,15 @@ class LoginViewController: UIViewController, RootContainment { var didFinishLogin: ((LoginAction, Error?) -> EndLoginAction)? override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } var preferredHeaderBarPresentation: HeaderBarPresentation { - return HeaderBarPresentation(style: .transparent, showsDivider: false) + HeaderBarPresentation(style: .transparent, showsDivider: false) } var prefersHeaderBarHidden: Bool { - return false + false } init(interactor: LoginInteractor) { @@ -168,7 +168,7 @@ class LoginViewController: UIViewController, RootContainment { override var disablesAutomaticKeyboardDismissal: Bool { // Allow dismissing the keyboard in .formSheet presentation style - return false + false } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { diff --git a/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeInteractor.swift b/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeInteractor.swift index 5a833fef22..1b050daa91 100644 --- a/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeInteractor.swift +++ b/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeInteractor.swift @@ -51,11 +51,11 @@ final class OutOfTimeInteractor { } var tunnelStatus: TunnelStatus { - return tunnelManager.tunnelStatus + tunnelManager.tunnelStatus } var deviceState: DeviceState { - return tunnelManager.deviceState + tunnelManager.deviceState } func stopTunnel() { @@ -73,7 +73,7 @@ final class OutOfTimeInteractor { Error >) -> Void ) -> Cancellable { - return storePaymentManager.restorePurchases( + storePaymentManager.restorePurchases( for: accountNumber, completionHandler: completionHandler ) @@ -83,7 +83,7 @@ final class OutOfTimeInteractor { with productIdentifiers: Set<StoreSubscription>, completionHandler: @escaping (Result<SKProductsResponse, Error>) -> Void ) -> Cancellable { - return storePaymentManager.requestProducts( + storePaymentManager.requestProducts( with: productIdentifiers, completionHandler: completionHandler ) diff --git a/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeViewController.swift b/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeViewController.swift index cb518c85d6..888c8e8a2c 100644 --- a/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeViewController.swift +++ b/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeViewController.swift @@ -39,7 +39,7 @@ class OutOfTimeViewController: UIViewController, RootContainment { private lazy var contentView = OutOfTimeContentView() override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } var preferredHeaderBarPresentation: HeaderBarPresentation { @@ -52,7 +52,7 @@ class OutOfTimeViewController: UIViewController, RootContainment { } var prefersHeaderBarHidden: Bool { - return false + false } init(interactor: OutOfTimeInteractor, errorPresenter: PaymentAlertPresenter) { diff --git a/ios/MullvadVPN/View controllers/Preferences/PreferencesCellFactory.swift b/ios/MullvadVPN/View controllers/Preferences/PreferencesCellFactory.swift index 6455a183e1..3fd3301a36 100644 --- a/ios/MullvadVPN/View controllers/Preferences/PreferencesCellFactory.swift +++ b/ios/MullvadVPN/View controllers/Preferences/PreferencesCellFactory.swift @@ -241,7 +241,7 @@ final class PreferencesCellFactory: CellFactoryProtocol { } private func dsnEntryIsValid(identifier: UUID, cell: SettingsDNSTextCell) -> Bool { - return delegate?.didChangeDNSEntry( + delegate?.didChangeDNSEntry( with: identifier, inputString: cell.textField.text ?? "" ) ?? false diff --git a/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift b/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift index 2be26b07a2..fb70c8ab0a 100644 --- a/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift +++ b/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift @@ -83,7 +83,7 @@ final class PreferencesDataSource: UITableViewDiffableDataSource< case dnsServer(_ uniqueID: UUID) static var contentBlockers: [Item] { - return [.blockAdvertising, .blockTracking, .blockMalware, .blockAdultContent, .blockGambling] + [.blockAdvertising, .blockTracking, .blockMalware, .blockAdultContent, .blockGambling] } static var wireGuardPorts: [Item] { @@ -464,11 +464,11 @@ final class PreferencesDataSource: UITableViewDiffableDataSource< let items = snapshot().itemIdentifiers(inSection: sectionIdentifier) let indexPathForFirstRow = items.first(where: Item.isDNSServerItem).flatMap { item in - return indexPath(for: item) + indexPath(for: item) } let indexPathForLastRow = items.last(where: Item.isDNSServerItem).flatMap { item in - return indexPath(for: item) + indexPath(for: item) } guard let indexPathForFirstRow, @@ -526,7 +526,7 @@ final class PreferencesDataSource: UITableViewDiffableDataSource< newSnapshot.appendItems([.useCustomDNS], toSection: .customDNS) let dnsServerItems = viewModel.customDNSDomains.map { entry in - return Item.dnsServer(entry.identifier) + Item.dnsServer(entry.identifier) } newSnapshot.appendItems(dnsServerItems, toSection: .customDNS) @@ -550,8 +550,7 @@ final class PreferencesDataSource: UITableViewDiffableDataSource< private func reload(item: Item) { if let indexPath = indexPath(for: item), - let cell = tableView?.cellForRow(at: indexPath) - { + let cell = tableView?.cellForRow(at: indexPath) { preferencesCellFactory.configureCell(cell, item: item, indexPath: indexPath) } } @@ -670,8 +669,7 @@ final class PreferencesDataSource: UITableViewDiffableDataSource< } if let lastDNSEntry, - let indexPath = self?.indexPath(for: lastDNSEntry) - { + let indexPath = self?.indexPath(for: lastDNSEntry) { let cell = self?.tableView?.cellForRow(at: indexPath) as? SettingsDNSTextCell self?.tableView?.scrollToRow(at: indexPath, at: .bottom, animated: true) @@ -684,7 +682,7 @@ final class PreferencesDataSource: UITableViewDiffableDataSource< let oldViewModel = viewModel let entryIndex = viewModel.customDNSDomains.firstIndex { entry in - return entry.identifier == entryIdentifier + entry.identifier == entryIdentifier } guard let entryIndex else { return } @@ -846,7 +844,7 @@ extension PreferencesDataSource: PreferencesCellEventHandler { with identifier: UUID, inputString: String ) -> Bool { - return handleDNSEntryChange(with: identifier, inputString: inputString) + handleDNSEntryChange(with: identifier, inputString: inputString) } func showInfo(for item: InfoButtonItem) { diff --git a/ios/MullvadVPN/View controllers/Preferences/PreferencesInteractor.swift b/ios/MullvadVPN/View controllers/Preferences/PreferencesInteractor.swift index 283154b00a..3c8371ad3f 100644 --- a/ios/MullvadVPN/View controllers/Preferences/PreferencesInteractor.swift +++ b/ios/MullvadVPN/View controllers/Preferences/PreferencesInteractor.swift @@ -18,11 +18,11 @@ final class PreferencesInteractor { var cachedRelaysDidChange: ((CachedRelays) -> Void)? var tunnelSettings: TunnelSettingsV2 { - return tunnelManager.settings + tunnelManager.settings } var cachedRelays: CachedRelays? { - return try? relayCacheTracker.getCachedRelays() + try? relayCacheTracker.getCachedRelays() } init(tunnelManager: TunnelManager, relayCacheTracker: RelayCacheTracker) { diff --git a/ios/MullvadVPN/View controllers/Preferences/PreferencesViewController.swift b/ios/MullvadVPN/View controllers/Preferences/PreferencesViewController.swift index d4f4e7691b..c6c3bfc218 100644 --- a/ios/MullvadVPN/View controllers/Preferences/PreferencesViewController.swift +++ b/ios/MullvadVPN/View controllers/Preferences/PreferencesViewController.swift @@ -14,7 +14,7 @@ class PreferencesViewController: UITableViewController, PreferencesDataSourceDel private let alertPresenter = AlertPresenter() override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } init(interactor: PreferencesInteractor) { @@ -94,7 +94,7 @@ class PreferencesViewController: UITableViewController, PreferencesDataSourceDel } private func humanReadablePortRepresentation(_ ranges: [[UInt16]]) -> String { - return ranges + ranges .compactMap { range in if let minPort = range.first, let maxPort = range.last { return minPort == maxPort ? String(minPort) : "\(minPort)-\(maxPort)" diff --git a/ios/MullvadVPN/View controllers/Preferences/PreferencesViewModel.swift b/ios/MullvadVPN/View controllers/Preferences/PreferencesViewModel.swift index 26fc169161..d8b8266ecc 100644 --- a/ios/MullvadVPN/View controllers/Preferences/PreferencesViewModel.swift +++ b/ios/MullvadVPN/View controllers/Preferences/PreferencesViewModel.swift @@ -21,7 +21,7 @@ enum CustomDNSPrecondition { /// Returns localized description explaining how to enable Custom DNS. func localizedDescription(isEditing: Bool) -> String? { - return attributedLocalizedDescription( + attributedLocalizedDescription( isEditing: isEditing, preferredFont: UIFont.systemFont(ofSize: UIFont.systemFontSize) )?.string @@ -132,7 +132,7 @@ struct PreferencesViewModel: Equatable { return .conflictsWithOtherSettings } else { let hasValidDNSDomains = customDNSDomains.contains { entry in - return AnyIPAddress(entry.address) != nil + AnyIPAddress(entry.address) != nil } if hasValidDNSDomains { @@ -145,11 +145,11 @@ struct PreferencesViewModel: Equatable { /// Effective state of the custom DNS setting. var effectiveEnableCustomDNS: Bool { - return customDNSPrecondition == .satisfied && enableCustomDNS + customDNSPrecondition == .satisfied && enableCustomDNS } var customWireGuardPort: UInt16? { - return wireGuardPort.flatMap { port in + wireGuardPort.flatMap { port in Self.defaultWireGuardPorts.contains(port) ? nil : port } } @@ -163,7 +163,7 @@ struct PreferencesViewModel: Equatable { blockGambling = dnsSettings.blockingOptions.contains(.blockGambling) enableCustomDNS = dnsSettings.enableCustomDNS customDNSDomains = dnsSettings.customDNSDomains.map { ipAddress in - return DNSServerEntry(identifier: UUID(), address: "\(ipAddress)") + DNSServerEntry(identifier: UUID(), address: "\(ipAddress)") } wireGuardPort = tunnelSettings.relayConstraints.port.value } @@ -196,15 +196,15 @@ struct PreferencesViewModel: Equatable { } func dnsEntry(entryIdentifier: UUID) -> DNSServerEntry? { - return customDNSDomains.first { entry in - return entry.identifier == entryIdentifier + customDNSDomains.first { entry in + entry.identifier == entryIdentifier } } /// Returns an index of entry in `customDNSDomains`, otherwise `nil`. func indexOfDNSEntry(entryIdentifier: UUID) -> Int? { - return customDNSDomains.firstIndex { entry in - return entry.identifier == entryIdentifier + customDNSDomains.firstIndex { entry in + entry.identifier == entryIdentifier } } @@ -244,19 +244,19 @@ struct PreferencesViewModel: Equatable { dnsSettings.blockingOptions = blockingOptions dnsSettings.enableCustomDNS = enableCustomDNS dnsSettings.customDNSDomains = customDNSDomains.compactMap { entry in - return AnyIPAddress(entry.address) + AnyIPAddress(entry.address) } return dnsSettings } /// Returns true if the given string is empty or a valid IP address. func isDNSDomainUserInputValid(_ string: String) -> Bool { - return string.isEmpty || AnyIPAddress(string) != nil + string.isEmpty || AnyIPAddress(string) != nil } /// Returns true if the given port is in within the supported ranges. func isPortWithinValidWireGuardRanges(_ port: UInt16) -> Bool { - return availableWireGuardPortRanges.contains { range in + availableWireGuardPortRanges.contains { range in if let minPort = range.first, let maxPort = range.last { return (minPort ... maxPort).contains(port) } @@ -271,7 +271,7 @@ struct PreferencesViewModel: Equatable { return newDomains.map { otherEntry in let sameEntryIndex = oldDomains.firstIndex { entry in - return entry.address == otherEntry.address + entry.address == otherEntry.address } if let sameEntryIndex { diff --git a/ios/MullvadVPN/View controllers/ProblemReport/ProblemReportInteractor.swift b/ios/MullvadVPN/View controllers/ProblemReport/ProblemReportInteractor.swift index 65ab298d66..28aed41d77 100644 --- a/ios/MullvadVPN/View controllers/ProblemReport/ProblemReportInteractor.swift +++ b/ios/MullvadVPN/View controllers/ProblemReport/ProblemReportInteractor.swift @@ -61,6 +61,6 @@ final class ProblemReportInteractor { } var reportString: String { - return consolidatedLog.string + consolidatedLog.string } } diff --git a/ios/MullvadVPN/View controllers/ProblemReport/ProblemReportViewController.swift b/ios/MullvadVPN/View controllers/ProblemReport/ProblemReportViewController.swift index 530dfa35d6..80de1e1ddb 100644 --- a/ios/MullvadVPN/View controllers/ProblemReport/ProblemReportViewController.swift +++ b/ios/MullvadVPN/View controllers/ProblemReport/ProblemReportViewController.swift @@ -179,12 +179,12 @@ final class ProblemReportViewController: UIViewController, UITextFieldDelegate { // MARK: - View lifecycle override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } override var disablesAutomaticKeyboardDismissal: Bool { // Allow dismissing the keyboard in .formSheet presentation style - return false + false } init(interactor: ProblemReportInteractor) { @@ -606,7 +606,7 @@ final class ProblemReportViewController: UIViewController, UITextFieldDelegate { } var isValid: Bool { - return !message.isEmpty + !message.isEmpty } } diff --git a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherCoordinator.swift b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherCoordinator.swift index d7b63107a5..da0a6c93f0 100644 --- a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherCoordinator.swift +++ b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherCoordinator.swift @@ -25,7 +25,7 @@ final class RedeemVoucherCoordinator: Coordinator, Presentable { } var presentedViewController: UIViewController { - return navigationController + navigationController } func start() { diff --git a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherSucceededViewController.swift b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherSucceededViewController.swift index 9ec894734e..6fa52cff0d 100644 --- a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherSucceededViewController.swift +++ b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherSucceededViewController.swift @@ -58,7 +58,7 @@ class RedeemVoucherSucceededViewController: UIViewController { }() override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } weak var delegate: RedeemVoucherSucceededViewControllerDelegate? diff --git a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift index 1bbab10643..de9f9c97ad 100644 --- a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift +++ b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherViewController.swift @@ -35,7 +35,7 @@ class RedeemVoucherViewController: UIViewController, UINavigationControllerDeleg } override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } // MARK: - Life Cycle diff --git a/ios/MullvadVPN/View controllers/RedeemVoucher/VoucherTextField.swift b/ios/MullvadVPN/View controllers/RedeemVoucher/VoucherTextField.swift index 01cf02477f..89d72228ac 100644 --- a/ios/MullvadVPN/View controllers/RedeemVoucher/VoucherTextField.swift +++ b/ios/MullvadVPN/View controllers/RedeemVoucher/VoucherTextField.swift @@ -51,7 +51,7 @@ class VoucherTextField: CustomTextField, UITextFieldDelegate { shouldChangeCharactersIn range: NSRange, replacementString string: String ) -> Bool { - return inputFormatter.textField( + inputFormatter.textField( textField, shouldChangeCharactersIn: range, replacementString: string diff --git a/ios/MullvadVPN/View controllers/RevokedDevice/RevokedDeviceInteractor.swift b/ios/MullvadVPN/View controllers/RevokedDevice/RevokedDeviceInteractor.swift index 7ceacb2676..b54108cca4 100644 --- a/ios/MullvadVPN/View controllers/RevokedDevice/RevokedDeviceInteractor.swift +++ b/ios/MullvadVPN/View controllers/RevokedDevice/RevokedDeviceInteractor.swift @@ -15,7 +15,7 @@ final class RevokedDeviceInteractor { var didUpdateTunnelStatus: ((TunnelStatus) -> Void)? var tunnelStatus: TunnelStatus { - return tunnelManager.tunnelStatus + tunnelManager.tunnelStatus } init(tunnelManager: TunnelManager) { diff --git a/ios/MullvadVPN/View controllers/RevokedDevice/RevokedDeviceViewController.swift b/ios/MullvadVPN/View controllers/RevokedDevice/RevokedDeviceViewController.swift index 1eee39123a..4f653b51ff 100644 --- a/ios/MullvadVPN/View controllers/RevokedDevice/RevokedDeviceViewController.swift +++ b/ios/MullvadVPN/View controllers/RevokedDevice/RevokedDeviceViewController.swift @@ -79,7 +79,7 @@ class RevokedDeviceViewController: UIViewController, RootContainment { var didFinish: (() -> Void)? override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } var preferredHeaderBarPresentation: HeaderBarPresentation { @@ -92,7 +92,7 @@ class RevokedDeviceViewController: UIViewController, RootContainment { } var prefersHeaderBarHidden: Bool { - return false + false } private let interactor: RevokedDeviceInteractor diff --git a/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift b/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift index 2693e75f64..dc3700786b 100644 --- a/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift +++ b/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift @@ -40,7 +40,7 @@ final class LocationDataSource: UITableViewDiffableDataSource<Int, RelayLocation private let locationCellFactory: LocationCellFactory private class func makeRootNode() -> Node { - return Node( + Node( type: .root, location: RelayLocation.country("#root"), displayName: "", @@ -144,7 +144,7 @@ final class LocationDataSource: UITableViewDiffableDataSource<Int, RelayLocation } func indexPathForSelectedRelay() -> IndexPath? { - return selectedRelayLocation.flatMap { indexPath(for: $0) } + selectedRelayLocation.flatMap { indexPath(for: $0) } } func filterRelays(by searchString: String) { @@ -292,8 +292,7 @@ final class LocationDataSource: UITableViewDiffableDataSource<Int, RelayLocation if let location = node.children.last?.location, let lastInsertedIndexPath = self?.indexPath(for: location), let lastVisibleIndexPath = visibleIndexPaths.last, - lastInsertedIndexPath >= lastVisibleIndexPath - { + lastInsertedIndexPath >= lastVisibleIndexPath { self?.tableView.scrollToRow( at: lastInsertedIndexPath, at: .bottom, @@ -322,7 +321,7 @@ final class LocationDataSource: UITableViewDiffableDataSource<Int, RelayLocation } private func item(for indexPath: IndexPath) -> LocationDataSourceItemProtocol? { - return itemIdentifier(for: indexPath).flatMap { nodeByLocation[$0] } + itemIdentifier(for: indexPath).flatMap { nodeByLocation[$0] } } private func scrollToTop(animated: Bool) { @@ -332,11 +331,11 @@ final class LocationDataSource: UITableViewDiffableDataSource<Int, RelayLocation extension LocationDataSource: UITableViewDelegate { func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool { - return item(for: indexPath)?.isActive ?? false + item(for: indexPath)?.isActive ?? false } func tableView(_ tableView: UITableView, indentationLevelForRowAt indexPath: IndexPath) -> Int { - return item(for: indexPath)?.indentationLevel ?? 0 + item(for: indexPath)?.indentationLevel ?? 0 } func tableView( @@ -345,8 +344,7 @@ extension LocationDataSource: UITableViewDelegate { forRowAt indexPath: IndexPath ) { if let item = item(for: indexPath), - item.location == selectedRelayLocation - { + item.location == selectedRelayLocation { cell.setSelected(true, animated: false) } } @@ -359,8 +357,7 @@ extension LocationDataSource: UITableViewDelegate { } if let indexPath = indexPathForSelectedRelay(), - let cell = tableView.cellForRow(at: indexPath) - { + let cell = tableView.cellForRow(at: indexPath) { cell.setSelected(false, animated: false) } @@ -457,7 +454,7 @@ extension LocationDataSource { fallthrough case .city: isActive = children.contains(where: { node -> Bool in - return node.isActive + node.isActive }) case .relay: break @@ -465,7 +462,7 @@ extension LocationDataSource { } func flatRelayLocationList(includeHiddenChildren: Bool = false) -> [RelayLocation] { - return children.reduce(into: []) { array, node in + children.reduce(into: []) { array, node in Self.flatten(node: node, into: &array, includeHiddenChildren: includeHiddenChildren) } } @@ -474,11 +471,11 @@ extension LocationDataSource { switch nodeType { case .root, .country: children.sort { a, b -> Bool in - return lexicalSortComparator(a.displayName, b.displayName) + lexicalSortComparator(a.displayName, b.displayName) } case .city: children.sort { a, b -> Bool in - return fileSortComparator( + fileSortComparator( a.location.stringRepresentation, b.location.stringRepresentation ) @@ -500,11 +497,11 @@ extension LocationDataSource { } private func lexicalSortComparator(_ a: String, _ b: String) -> Bool { - return a.localizedCaseInsensitiveCompare(b) == .orderedAscending + a.localizedCaseInsensitiveCompare(b) == .orderedAscending } private func fileSortComparator(_ a: String, _ b: String) -> Bool { - return a.localizedStandardCompare(b) == .orderedAscending + a.localizedStandardCompare(b) == .orderedAscending } private extension [RelayLocation] { diff --git a/ios/MullvadVPN/View controllers/SelectLocation/SelectLocationViewController.swift b/ios/MullvadVPN/View controllers/SelectLocation/SelectLocationViewController.swift index 69243e39c0..86163c96cd 100644 --- a/ios/MullvadVPN/View controllers/SelectLocation/SelectLocationViewController.swift +++ b/ios/MullvadVPN/View controllers/SelectLocation/SelectLocationViewController.swift @@ -19,7 +19,7 @@ final class SelectLocationViewController: UIViewController { var relayLocation: RelayLocation? override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } var didSelectRelay: ((RelayLocation) -> Void)? diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsDNSTextCell.swift b/ios/MullvadVPN/View controllers/Settings/SettingsDNSTextCell.swift index 6fe54759b1..b6a3fe6bb2 100644 --- a/ios/MullvadVPN/View controllers/Settings/SettingsDNSTextCell.swift +++ b/ios/MullvadVPN/View controllers/Settings/SettingsDNSTextCell.swift @@ -136,8 +136,8 @@ class SettingsDNSTextCell: SettingsCell, UITextFieldDelegate { let ipv6AddressCharset = CharacterSet.ipv6AddressCharset return [ipv4AddressCharset, ipv6AddressCharset].contains { charset in - return string.unicodeScalars.allSatisfy { scalar in - return charset.contains(scalar) + string.unicodeScalars.allSatisfy { scalar in + charset.contains(scalar) } } } diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift b/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift index 954361c463..17947ea4c9 100644 --- a/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift +++ b/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift @@ -16,7 +16,7 @@ final class SettingsDataSource: UITableViewDiffableDataSource< case basicCell var reusableViewClass: AnyClass { - return SettingsCell.self + SettingsCell.self } } @@ -24,7 +24,7 @@ final class SettingsDataSource: UITableViewDiffableDataSource< case spacer var reusableViewClass: AnyClass { - return EmptyTableViewHeaderFooterView.self + EmptyTableViewHeaderFooterView.self } } @@ -41,7 +41,7 @@ final class SettingsDataSource: UITableViewDiffableDataSource< case faq var reuseIdentifier: CellReuseIdentifiers { - return .basicCell + .basicCell } } @@ -90,21 +90,21 @@ final class SettingsDataSource: UITableViewDiffableDataSource< } func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - return tableView.dequeueReusableHeaderFooterView( + tableView.dequeueReusableHeaderFooterView( withIdentifier: HeaderFooterReuseIdentifier.spacer.rawValue ) } func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { - return nil + nil } func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - return UIMetrics.sectionSpacing + UIMetrics.sectionSpacing } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { - return 0 + 0 } // MARK: - Private diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsInteractor.swift b/ios/MullvadVPN/View controllers/Settings/SettingsInteractor.swift index c695772823..7b35c4f8a4 100644 --- a/ios/MullvadVPN/View controllers/Settings/SettingsInteractor.swift +++ b/ios/MullvadVPN/View controllers/Settings/SettingsInteractor.swift @@ -15,7 +15,7 @@ final class SettingsInteractor { var didUpdateDeviceState: ((DeviceState) -> Void)? var deviceState: DeviceState { - return tunnelManager.deviceState + tunnelManager.deviceState } init(tunnelManager: TunnelManager) { diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsInteractorFactory.swift b/ios/MullvadVPN/View controllers/Settings/SettingsInteractorFactory.swift index 0b9c719f37..eee79da6a7 100644 --- a/ios/MullvadVPN/View controllers/Settings/SettingsInteractorFactory.swift +++ b/ios/MullvadVPN/View controllers/Settings/SettingsInteractorFactory.swift @@ -29,21 +29,21 @@ final class SettingsInteractorFactory { } func makeAccountInteractor() -> AccountInteractor { - return AccountInteractor( + AccountInteractor( storePaymentManager: storePaymentManager, tunnelManager: tunnelManager ) } func makePreferencesInteractor() -> PreferencesInteractor { - return PreferencesInteractor(tunnelManager: tunnelManager, relayCacheTracker: relayCacheTracker) + PreferencesInteractor(tunnelManager: tunnelManager, relayCacheTracker: relayCacheTracker) } func makeProblemReportInteractor() -> ProblemReportInteractor { - return ProblemReportInteractor(apiProxy: apiProxy, tunnelManager: tunnelManager) + ProblemReportInteractor(apiProxy: apiProxy, tunnelManager: tunnelManager) } func makeSettingsInteractor() -> SettingsInteractor { - return SettingsInteractor(tunnelManager: tunnelManager) + SettingsInteractor(tunnelManager: tunnelManager) } } diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsSwitchCell.swift b/ios/MullvadVPN/View controllers/Settings/SettingsSwitchCell.swift index 5b81c186b4..476287146f 100644 --- a/ios/MullvadVPN/View controllers/Settings/SettingsSwitchCell.swift +++ b/ios/MullvadVPN/View controllers/Settings/SettingsSwitchCell.swift @@ -59,7 +59,7 @@ class SettingsSwitchCell: SettingsCell { } get { // Use UISwitch traits to make the entire cell behave as "Switch button" - return switchContainer.control.accessibilityTraits + switchContainer.control.accessibilityTraits } } @@ -68,7 +68,7 @@ class SettingsSwitchCell: SettingsCell { super.accessibilityLabel = newValue } get { - return titleLabel.text + titleLabel.text } } @@ -77,7 +77,7 @@ class SettingsSwitchCell: SettingsCell { super.accessibilityValue = newValue } get { - return self.switchContainer.control.accessibilityValue + self.switchContainer.control.accessibilityValue } } @@ -86,7 +86,7 @@ class SettingsSwitchCell: SettingsCell { super.accessibilityFrame = newValue } get { - return UIAccessibility.convertToScreenCoordinates(self.bounds, in: self) + UIAccessibility.convertToScreenCoordinates(self.bounds, in: self) } } @@ -95,7 +95,7 @@ class SettingsSwitchCell: SettingsCell { super.accessibilityPath = newValue } get { - return UIBezierPath(roundedRect: accessibilityFrame, cornerRadius: 4) + UIBezierPath(roundedRect: accessibilityFrame, cornerRadius: 4) } } diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsViewController.swift b/ios/MullvadVPN/View controllers/Settings/SettingsViewController.swift index 48ad6bef60..72369c16d4 100644 --- a/ios/MullvadVPN/View controllers/Settings/SettingsViewController.swift +++ b/ios/MullvadVPN/View controllers/Settings/SettingsViewController.swift @@ -23,7 +23,7 @@ class SettingsViewController: UITableViewController, SettingsDataSourceDelegate private let interactor: SettingsInteractor override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } init(interactor: SettingsInteractor) { diff --git a/ios/MullvadVPN/View controllers/TermsOfService/TermsOfServiceViewController.swift b/ios/MullvadVPN/View controllers/TermsOfService/TermsOfServiceViewController.swift index e9d7bfbc72..5e34843956 100644 --- a/ios/MullvadVPN/View controllers/TermsOfService/TermsOfServiceViewController.swift +++ b/ios/MullvadVPN/View controllers/TermsOfService/TermsOfServiceViewController.swift @@ -13,15 +13,15 @@ class TermsOfServiceViewController: UIViewController, RootContainment { var completionHandler: (() -> Void)? override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } var preferredHeaderBarPresentation: HeaderBarPresentation { - return HeaderBarPresentation(style: .default, showsDivider: false) + HeaderBarPresentation(style: .default, showsDivider: false) } var prefersHeaderBarHidden: Bool { - return false + false } // MARK: - View lifecycle diff --git a/ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift b/ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift index 1a491d1667..30a0b7170e 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift @@ -196,7 +196,7 @@ class ConnectionPanelAddressRow: UIView { var title: String? { get { - return textLabel.text + textLabel.text } set { textLabel.text = newValue @@ -206,7 +206,7 @@ class ConnectionPanelAddressRow: UIView { var value: String? { get { - return detailTextLabel.text + detailTextLabel.text } set { detailTextLabel.text = newValue diff --git a/ios/MullvadVPN/View controllers/Tunnel/MapViewController.swift b/ios/MullvadVPN/View controllers/Tunnel/MapViewController.swift index 61aa83c507..1b5f2be784 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/MapViewController.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/MapViewController.swift @@ -180,8 +180,7 @@ final class MapViewController: UIViewController, MKMapViewDelegate { for geometry in feature.geometry { if let polygon = geometry as? MKPolygon { if let interiorPolygons = polygon.interiorPolygons, - !interiorPolygons.isEmpty - { + !interiorPolygons.isEmpty { overlays .append(MKPolygon( points: polygon.points(), diff --git a/ios/MullvadVPN/View controllers/Tunnel/TranslucentButtonBlurView.swift b/ios/MullvadVPN/View controllers/Tunnel/TranslucentButtonBlurView.swift index 22d3b4ab4a..5f27e8be5a 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/TranslucentButtonBlurView.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/TranslucentButtonBlurView.swift @@ -48,8 +48,7 @@ private extension AppButton { private extension AppButton.Style { func cornerMask(_ userInterfaceLayoutDirection: UIUserInterfaceLayoutDirection) - -> CACornerMask - { + -> CACornerMask { switch (self, userInterfaceLayoutDirection) { case (.translucentDangerSplitLeft, .leftToRight), (.translucentDangerSplitRight, .rightToLeft): diff --git a/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift b/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift index fec49f8de2..9c1103325d 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift @@ -104,7 +104,7 @@ final class TunnelControlView: UIView { var actionHandler: ((TunnelControlAction) -> Void)? var mapCenterAlignmentView: UIView { - return activityIndicator + activityIndicator } override init(frame: CGRect) { @@ -134,8 +134,7 @@ final class TunnelControlView: UIView { } if previousTraitCollection?.userInterfaceIdiom != traitCollection.userInterfaceIdiom || - previousTraitCollection?.horizontalSizeClass != traitCollection.horizontalSizeClass - { + previousTraitCollection?.horizontalSizeClass != traitCollection.horizontalSizeClass { updateActionButtons() } } diff --git a/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift b/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift index ae18153c45..39782ac20e 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift @@ -24,7 +24,7 @@ class TunnelViewController: UIViewController, RootContainment { private let mapViewController = MapViewController() override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent + .lightContent } var preferredHeaderBarPresentation: HeaderBarPresentation { @@ -40,7 +40,7 @@ class TunnelViewController: UIViewController, RootContainment { } var prefersHeaderBarHidden: Bool { - return false + false } init(interactor: TunnelViewControllerInteractor) { diff --git a/ios/MullvadVPN/View controllers/Tunnel/TunnelViewControllerInteractor.swift b/ios/MullvadVPN/View controllers/Tunnel/TunnelViewControllerInteractor.swift index e0eb61c8fb..2fa9381480 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/TunnelViewControllerInteractor.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/TunnelViewControllerInteractor.swift @@ -16,11 +16,11 @@ final class TunnelViewControllerInteractor { var didUpdateTunnelStatus: ((TunnelStatus) -> Void)? var tunnelStatus: TunnelStatus { - return tunnelManager.tunnelStatus + tunnelManager.tunnelStatus } var deviceState: DeviceState { - return tunnelManager.deviceState + tunnelManager.deviceState } init(tunnelManager: TunnelManager) { diff --git a/ios/MullvadVPN/Views/AppButton.swift b/ios/MullvadVPN/Views/AppButton.swift index f8ab72f279..2fc3603e22 100644 --- a/ios/MullvadVPN/Views/AppButton.swift +++ b/ios/MullvadVPN/Views/AppButton.swift @@ -211,8 +211,7 @@ class AppButton: CustomButton { super.traitCollectionDidChange(previousTraitCollection) if traitCollection.userInterfaceIdiom != previousTraitCollection?.userInterfaceIdiom, - !overrideContentEdgeInsets - { + !overrideContentEdgeInsets { contentEdgeInsets = defaultContentInsets } } @@ -350,10 +349,10 @@ class CustomButton: UIButton { } override func imageRect(forContentRect contentRect: CGRect) -> CGRect { - return computeLayout(forContentRect: contentRect).1 + computeLayout(forContentRect: contentRect).1 } override func titleRect(forContentRect contentRect: CGRect) -> CGRect { - return computeLayout(forContentRect: contentRect).0 + computeLayout(forContentRect: contentRect).0 } } diff --git a/ios/MullvadVPN/Views/CustomSwitch.swift b/ios/MullvadVPN/Views/CustomSwitch.swift index 0172441489..4596cb56b6 100644 --- a/ios/MullvadVPN/Views/CustomSwitch.swift +++ b/ios/MullvadVPN/Views/CustomSwitch.swift @@ -13,12 +13,12 @@ class CustomSwitch: UISwitch { private var backgroundView: UIView? { // Go two levels deep only let subviewsToExamine = subviews.flatMap { view -> [UIView] in - return [view] + view.subviews + [view] + view.subviews } // Find the first subview that has background color set. let backgroundView = subviewsToExamine.first { subview in - return subview.backgroundColor != nil + subview.backgroundColor != nil } return backgroundView diff --git a/ios/MullvadVPN/Views/CustomSwitchContainer.swift b/ios/MullvadVPN/Views/CustomSwitchContainer.swift index 6fdf06a2a3..ae1a290f6e 100644 --- a/ios/MullvadVPN/Views/CustomSwitchContainer.swift +++ b/ios/MullvadVPN/Views/CustomSwitchContainer.swift @@ -23,7 +23,7 @@ class CustomSwitchContainer: UIView { var isEnabled: Bool { get { - return control.isEnabled + control.isEnabled } set { control.isEnabled = newValue @@ -32,11 +32,11 @@ class CustomSwitchContainer: UIView { } override var intrinsicContentSize: CGSize { - return controlSize() + controlSize() } override func sizeThatFits(_ size: CGSize) -> CGSize { - return controlSize() + controlSize() } override init(frame: CGRect) { diff --git a/ios/MullvadVPN/Views/CustomTextField.swift b/ios/MullvadVPN/Views/CustomTextField.swift index d6813bfcf2..0eb6be2e3a 100644 --- a/ios/MullvadVPN/Views/CustomTextField.swift +++ b/ios/MullvadVPN/Views/CustomTextField.swift @@ -57,11 +57,11 @@ class CustomTextField: UITextField { } override func textRect(forBounds bounds: CGRect) -> CGRect { - return bounds.inset(by: textMargins) + bounds.inset(by: textMargins) } override func editingRect(forBounds bounds: CGRect) -> CGRect { - return textRect(forBounds: bounds) + textRect(forBounds: bounds) } private func updatePlaceholderTextColor() { diff --git a/ios/MullvadVPN/Views/CustomTextView.swift b/ios/MullvadVPN/Views/CustomTextView.swift index 55bad0ac5c..2d90dcf29e 100644 --- a/ios/MullvadVPN/Views/CustomTextView.swift +++ b/ios/MullvadVPN/Views/CustomTextView.swift @@ -23,7 +23,7 @@ class CustomTextView: UITextView { placeholderTextLabel.text = newValue } get { - return placeholderTextLabel.text + placeholderTextLabel.text } } diff --git a/ios/MullvadVPN/Views/SpinnerActivityIndicatorView.swift b/ios/MullvadVPN/Views/SpinnerActivityIndicatorView.swift index 7ac376cd1a..2b0a5e07ac 100644 --- a/ios/MullvadVPN/Views/SpinnerActivityIndicatorView.swift +++ b/ios/MullvadVPN/Views/SpinnerActivityIndicatorView.swift @@ -37,7 +37,7 @@ class SpinnerActivityIndicatorView: UIView { private var sceneActivationObserver: Any? override var intrinsicContentSize: CGSize { - return style.intrinsicSize + style.intrinsicSize } init(style: Style) { diff --git a/ios/MullvadVPN/Views/StatusImageView.swift b/ios/MullvadVPN/Views/StatusImageView.swift index af0ef14ae7..7665daa580 100644 --- a/ios/MullvadVPN/Views/StatusImageView.swift +++ b/ios/MullvadVPN/Views/StatusImageView.swift @@ -30,7 +30,7 @@ class StatusImageView: UIImageView { } override var intrinsicContentSize: CGSize { - return CGSize(width: 60, height: 60) + CGSize(width: 60, height: 60) } override init(frame: CGRect) { diff --git a/ios/MullvadVPNTests/DeviceCheckOperationTests.swift b/ios/MullvadVPNTests/DeviceCheckOperationTests.swift index c744323662..c728697e72 100644 --- a/ios/MullvadVPNTests/DeviceCheckOperationTests.swift +++ b/ios/MullvadVPNTests/DeviceCheckOperationTests.swift @@ -23,7 +23,7 @@ class DeviceCheckOperationTests: XCTestCase { let remoteService = MockRemoteService( initialKey: currentKey.publicKey, getAccount: { accountNumber in - return Account.mock(expiry: .distantPast) + Account.mock(expiry: .distantPast) } ) let deviceStateAccessor = MockDeviceStateAccessor.mockLoggedIn( @@ -470,7 +470,7 @@ private enum LastKeyRotationState { extension MockDeviceStateAccessor { static func mockLoggedIn(currentKey: PrivateKey, rotationState: LastKeyRotationState) -> MockDeviceStateAccessor { - return MockDeviceStateAccessor(initialState: .loggedIn( + MockDeviceStateAccessor(initialState: .loggedIn( StoredAccountData.mock(), StoredDeviceData.mock(wgKeyData: StoredWgKeyData.mock(currentKey: currentKey, rotationState: rotationState)) )) @@ -502,7 +502,7 @@ private extension StoredWgKeyData { private extension StoredAccountData { static func mock() -> StoredAccountData { - return StoredAccountData( + StoredAccountData( identifier: "account-id", number: "account-number", expiry: .distantFuture @@ -512,7 +512,7 @@ private extension StoredAccountData { private extension StoredDeviceData { static func mock(wgKeyData: StoredWgKeyData) -> StoredDeviceData { - return StoredDeviceData( + StoredDeviceData( creationDate: Date(), identifier: "device-id", name: "device-name", @@ -526,7 +526,7 @@ private extension StoredDeviceData { private extension Device { static func mock(publicKey: PublicKey) -> Device { - return Device( + Device( id: "device-id", name: "device-name", pubkey: publicKey, @@ -541,7 +541,7 @@ private extension Device { private extension Account { static func mock(expiry: Date = .distantFuture) -> Account { - return Account( + Account( id: "account-id", expiry: expiry, maxPorts: 5, diff --git a/ios/MullvadVPNTests/RelayCacheTests.swift b/ios/MullvadVPNTests/RelayCacheTests.swift index 1a5d4804d4..7e37eefe22 100644 --- a/ios/MullvadVPNTests/RelayCacheTests.swift +++ b/ios/MullvadVPNTests/RelayCacheTests.swift @@ -43,7 +43,7 @@ final class RelayCacheTests: XCTestCase { private extension REST.ServerRelaysResponse { static func mock() -> Self { - return REST.ServerRelaysResponse( + REST.ServerRelaysResponse( locations: [:], wireguard: REST.ServerWireguardTunnels( ipv4Gateway: .loopback, diff --git a/ios/MullvadVPNTests/WgKeyRotationTests.swift b/ios/MullvadVPNTests/WgKeyRotationTests.swift index 0b18d2df0c..1d2e8efa5b 100644 --- a/ios/MullvadVPNTests/WgKeyRotationTests.swift +++ b/ios/MullvadVPNTests/WgKeyRotationTests.swift @@ -89,7 +89,7 @@ final class WgKeyRotationTests: XCTestCase { private extension StoredDeviceData { static func mock(keyData: StoredWgKeyData) -> StoredDeviceData { - return StoredDeviceData( + StoredDeviceData( creationDate: Date(), identifier: "device-id", name: "device-name", @@ -103,7 +103,7 @@ private extension StoredDeviceData { private extension Device { static func mock(privateKey: PrivateKey) -> Device { - return Device( + Device( id: "device-id", name: "device-name", pubkey: privateKey.publicKey, diff --git a/ios/Operations/AsyncOperation.swift b/ios/Operations/AsyncOperation.swift index ca11e86d7e..7ae6eea6d2 100644 --- a/ios/Operations/AsyncOperation.swift +++ b/ios/Operations/AsyncOperation.swift @@ -17,7 +17,7 @@ import Foundation case finished static func < (lhs: State, rhs: State) -> Bool { - return lhs.rawValue < rhs.rawValue + lhs.rawValue < rhs.rawValue } var description: String { @@ -114,7 +114,7 @@ open class AsyncOperation: Operation { } public var error: Error? { - return _error + _error } override public final var isReady: Bool { @@ -141,19 +141,19 @@ open class AsyncOperation: Operation { } override public final var isExecuting: Bool { - return state == .executing + state == .executing } override public final var isFinished: Bool { - return state == .finished + state == .finished } override public final var isCancelled: Bool { - return _isCancelled + _isCancelled } override public final var isAsynchronous: Bool { - return true + true } // MARK: - Observers @@ -278,15 +278,15 @@ open class AsyncOperation: Operation { } @objc class func keyPathsForValuesAffectingIsReady() -> Set<String> { - return [#keyPath(state)] + [#keyPath(state)] } @objc class func keyPathsForValuesAffectingIsExecuting() -> Set<String> { - return [#keyPath(state)] + [#keyPath(state)] } @objc class func keyPathsForValuesAffectingIsFinished() -> Set<String> { - return [#keyPath(state)] + [#keyPath(state)] } // MARK: - Lifecycle diff --git a/ios/Operations/AsyncOperationQueue.swift b/ios/Operations/AsyncOperationQueue.swift index d1269a8175..1944dccf25 100644 --- a/ios/Operations/AsyncOperationQueue.swift +++ b/ios/Operations/AsyncOperationQueue.swift @@ -13,10 +13,10 @@ public final class AsyncOperationQueue: OperationQueue { if let operation = operation as? AsyncOperation { let categories = operation.conditions .filter { condition in - return condition.isMutuallyExclusive + condition.isMutuallyExclusive } .map { condition in - return condition.name + condition.name } if !categories.isEmpty { diff --git a/ios/Operations/BlockCondition.swift b/ios/Operations/BlockCondition.swift index e6aafa1e2d..79cf14079f 100644 --- a/ios/Operations/BlockCondition.swift +++ b/ios/Operations/BlockCondition.swift @@ -12,11 +12,11 @@ public final class BlockCondition: OperationCondition { public typealias HandlerBlock = (Operation, @escaping (Bool) -> Void) -> Void public var name: String { - return "BlockCondition" + "BlockCondition" } public var isMutuallyExclusive: Bool { - return false + false } public let block: HandlerBlock diff --git a/ios/Operations/MutuallyExclusive.swift b/ios/Operations/MutuallyExclusive.swift index b9097d3420..8fe4595a92 100644 --- a/ios/Operations/MutuallyExclusive.swift +++ b/ios/Operations/MutuallyExclusive.swift @@ -12,7 +12,7 @@ public final class MutuallyExclusive: OperationCondition { public let name: String public var isMutuallyExclusive: Bool { - return true + true } public init(category: String) { diff --git a/ios/Operations/NoCancelledDependenciesCondition.swift b/ios/Operations/NoCancelledDependenciesCondition.swift index da562153ce..40175bd84a 100644 --- a/ios/Operations/NoCancelledDependenciesCondition.swift +++ b/ios/Operations/NoCancelledDependenciesCondition.swift @@ -10,18 +10,18 @@ import Foundation public final class NoCancelledDependenciesCondition: OperationCondition { public var name: String { - return "NoCancelledDependenciesCondition" + "NoCancelledDependenciesCondition" } public var isMutuallyExclusive: Bool { - return false + false } public init() {} public func evaluate(for operation: Operation, completion: @escaping (Bool) -> Void) { let satisfy = operation.dependencies.allSatisfy { operation in - return !operation.isCancelled + !operation.isCancelled } completion(satisfy) diff --git a/ios/Operations/NoFailedDependenciesCondition.swift b/ios/Operations/NoFailedDependenciesCondition.swift index 81523e511d..1ca5500ed0 100644 --- a/ios/Operations/NoFailedDependenciesCondition.swift +++ b/ios/Operations/NoFailedDependenciesCondition.swift @@ -10,11 +10,11 @@ import Foundation public final class NoFailedDependenciesCondition: OperationCondition { public var name: String { - return "NoFailedDependenciesCondition" + "NoFailedDependenciesCondition" } public var isMutuallyExclusive: Bool { - return false + false } public let ignoreCancellations: Bool diff --git a/ios/Operations/OperationError.swift b/ios/Operations/OperationError.swift index 3b96cf6c82..665f1e801c 100644 --- a/ios/Operations/OperationError.swift +++ b/ios/Operations/OperationError.swift @@ -27,6 +27,6 @@ public enum OperationError: LocalizedError, Equatable { extension Error { public var isOperationCancellationError: Bool { - return (self as? OperationError) == .cancelled + (self as? OperationError) == .cancelled } } diff --git a/ios/OperationsTests/AsyncResultBlockOperationTests.swift b/ios/OperationsTests/AsyncResultBlockOperationTests.swift index 5bae7f7d9c..6c157725c4 100644 --- a/ios/OperationsTests/AsyncResultBlockOperationTests.swift +++ b/ios/OperationsTests/AsyncResultBlockOperationTests.swift @@ -53,7 +53,7 @@ final class AsyncResultBlockOperationTests: XCTestCase { let expectation = expectation(description: "Should finish") let operation = ResultBlockOperation<Bool> { finish -> Cancellable in - return AnyCancellable { + AnyCancellable { finish(.failure(URLError(.cancelled))) } } diff --git a/ios/PacketTunnel/DeviceCheck/DeviceCheckOperation.swift b/ios/PacketTunnel/DeviceCheck/DeviceCheckOperation.swift index 3e30b80f6f..f04e7666f5 100644 --- a/ios/PacketTunnel/DeviceCheck/DeviceCheckOperation.swift +++ b/ios/PacketTunnel/DeviceCheck/DeviceCheckOperation.swift @@ -99,7 +99,7 @@ final class DeviceCheckOperation: ResultOperation<DeviceCheck> { if accountVerdict != .invalid, deviceVerdict == .keyMismatch { rotateKeyIfNeeded { rotationResult in completion(rotationResult.map { rotationStatus in - return DeviceCheck( + DeviceCheck( accountVerdict: accountVerdict, deviceVerdict: rotationStatus.isSucceeded ? .active : .keyMismatch, keyRotationStatus: rotationStatus diff --git a/ios/PacketTunnel/DeviceCheck/DeviceStateAccessor.swift b/ios/PacketTunnel/DeviceCheck/DeviceStateAccessor.swift index cbca39a278..7c3d3fdb54 100644 --- a/ios/PacketTunnel/DeviceCheck/DeviceStateAccessor.swift +++ b/ios/PacketTunnel/DeviceCheck/DeviceStateAccessor.swift @@ -12,7 +12,7 @@ import MullvadTypes /// An object that provides access to `DeviceState` used by `DeviceCheckOperation`. struct DeviceStateAccessor: DeviceStateAccessorProtocol { func read() throws -> DeviceState { - return try SettingsManager.readDeviceState() + try SettingsManager.readDeviceState() } func write(_ deviceState: DeviceState) throws { diff --git a/ios/PacketTunnel/MullvadEndpoint+WgEndpoint.swift b/ios/PacketTunnel/MullvadEndpoint+WgEndpoint.swift index d6434a4977..5609958b9e 100644 --- a/ios/PacketTunnel/MullvadEndpoint+WgEndpoint.swift +++ b/ios/PacketTunnel/MullvadEndpoint+WgEndpoint.swift @@ -12,7 +12,7 @@ import WireGuardKit extension MullvadEndpoint { var ipv4RelayEndpoint: Endpoint { - return Endpoint(host: .ipv4(ipv4Relay.ip), port: .init(integerLiteral: ipv4Relay.port)) + Endpoint(host: .ipv4(ipv4Relay.ip), port: .init(integerLiteral: ipv4Relay.port)) } var ipv6RelayEndpoint: Endpoint? { diff --git a/ios/PacketTunnel/PacketTunnelProvider.swift b/ios/PacketTunnel/PacketTunnelProvider.swift index e3bb561067..ecd7770d23 100644 --- a/ios/PacketTunnel/PacketTunnelProvider.swift +++ b/ios/PacketTunnel/PacketTunnelProvider.swift @@ -549,8 +549,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider, TunnelMonitorDelegate { } private func makeConfiguration(_ nextRelay: NextRelay) - throws -> PacketTunnelConfiguration - { + throws -> PacketTunnelConfiguration { let tunnelSettings = try SettingsManager.readSettings() let selectorResult: RelaySelectorResult @@ -668,8 +667,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider, TunnelMonitorDelegate { /// Load relay cache with potential networking to refresh the cache and pick the relay for the /// given relay constraints. private func selectRelayEndpoint(relayConstraints: RelayConstraints) throws - -> RelaySelectorResult - { + -> RelaySelectorResult { let cachedRelayList = try relayCache.read() return try RelaySelector.evaluate( diff --git a/ios/PacketTunnel/TunnelMonitor/Pinger.swift b/ios/PacketTunnel/TunnelMonitor/Pinger.swift index 37cb503a5b..f5872bb590 100644 --- a/ios/PacketTunnel/TunnelMonitor/Pinger.swift +++ b/ios/PacketTunnel/TunnelMonitor/Pinger.swift @@ -142,7 +142,7 @@ final class Pinger { sa.sin_len = UInt8(MemoryLayout.size(ofValue: sa)) sa.sin_family = sa_family_t(AF_INET) sa.sin_addr = address.rawValue.withUnsafeBytes { buffer in - return buffer.bindMemory(to: in_addr.self).baseAddress!.pointee + buffer.bindMemory(to: in_addr.self).baseAddress!.pointee } let sequenceNumber = nextSequenceNumber() @@ -152,7 +152,7 @@ final class Pinger { ) let bytesSent = packetData.withUnsafeBytes { dataBuffer -> Int in - return withUnsafeBytes(of: &sa) { bufferPointer in + withUnsafeBytes(of: &sa) { bufferPointer in let sockaddrPointer = bufferPointer.bindMemory(to: sockaddr.self).baseAddress! return sendto( @@ -218,7 +218,7 @@ final class Pinger { } private func parseICMPResponse(buffer: inout [UInt8], length: Int) throws -> ICMPHeader { - return try buffer.withUnsafeMutableBytes { bufferPointer in + try buffer.withUnsafeMutableBytes { bufferPointer in // Check IP packet size. guard length >= MemoryLayout<IPv4Header>.size else { throw Error.malformedResponse(.ipv4PacketTooSmall) @@ -322,7 +322,7 @@ final class Pinger { if sa.sa_family == AF_INET6 { return withUnsafeBytes(of: sa) { buffer in - return buffer.bindMemory(to: sockaddr_in6.self).baseAddress + buffer.bindMemory(to: sockaddr_in6.self).baseAddress .flatMap { boundPointer in var saddr6 = boundPointer.pointee let data = Data( @@ -425,11 +425,11 @@ private func in_chksum(_ data: some Sequence<UInt8>) -> UInt16 { private extension IPv4Header { /// Returns IPv4 header length. var headerLength: Int { - return Int(versionAndHeaderLength & 0x0F) * MemoryLayout<UInt32>.size + Int(versionAndHeaderLength & 0x0F) * MemoryLayout<UInt32>.size } /// Returns `true` if version header indicates IPv4. var isIPv4Version: Bool { - return (versionAndHeaderLength & 0xF0) == 0x40 + (versionAndHeaderLength & 0xF0) == 0x40 } } diff --git a/ios/PacketTunnel/TunnelMonitor/TunnelMonitor.swift b/ios/PacketTunnel/TunnelMonitor/TunnelMonitor.swift index 87ed609d79..d0e576f435 100644 --- a/ios/PacketTunnel/TunnelMonitor/TunnelMonitor.swift +++ b/ios/PacketTunnel/TunnelMonitor/TunnelMonitor.swift @@ -125,8 +125,7 @@ final class TunnelMonitor: PingerDelegate { let timeSinceLastPing = now.timeIntervalSince(lastRequestDate) if let lastReplyDate = pingStats.lastReplyDate, lastRequestDate.timeIntervalSince(lastReplyDate) >= heartbeatReplyTimeout, - timeSinceLastPing >= pingDelay, !isHeartbeatSuspended - { + timeSinceLastPing >= pingDelay, !isHeartbeatSuspended { return .retryHeartbeatPing } diff --git a/ios/RelaySelector/RelaySelector.swift b/ios/RelaySelector/RelaySelector.swift index 8c9c7a6915..53c2cc8995 100644 --- a/ios/RelaySelector/RelaySelector.swift +++ b/ios/RelaySelector/RelaySelector.swift @@ -17,7 +17,7 @@ public enum RelaySelector { Returns random shadowsocks TCP bridge, otherwise `nil` if there are no shadowdsocks bridges. */ public static func getShadowsocksTCPBridge(relays: REST.ServerRelaysResponse) -> REST.ServerShadowsocks? { - return relays.bridge.shadowsocks.filter { $0.protocol == "tcp" }.randomElement() + relays.bridge.shadowsocks.filter { $0.protocol == "tcp" }.randomElement() } /// Return a random Shadowsocks bridge relay, or `nil` if no relay were found. @@ -72,7 +72,7 @@ public enum RelaySelector { _ constraints: RelayConstraints, relays: [RelayWithLocation] ) -> [RelayWithLocation] { - return relays.filter { relayWithLocation -> Bool in + relays.filter { relayWithLocation -> Bool in switch constraints.location { case .any: return true @@ -93,7 +93,7 @@ public enum RelaySelector { } } }.filter { relayWithLocation -> Bool in - return relayWithLocation.relay.active + relayWithLocation.relay.active } } @@ -119,7 +119,7 @@ public enum RelaySelector { private static func pickRandomRelay(relays: [RelayWithLocation]) -> RelayWithLocation? { let totalWeight = relays.reduce(0) { accummulatedWeight, relayWithLocation in - return accummulatedWeight + relayWithLocation.relay.weight + accummulatedWeight + relayWithLocation.relay.weight } // Return random relay when all relays within the list have zero weight. @@ -148,7 +148,7 @@ public enum RelaySelector { private static func pickRandomPort(rawPortRanges: [[UInt16]]) -> UInt16? { let portRanges = parseRawPortRanges(rawPortRanges) let portAmount = portRanges.reduce(0) { partialResult, closedRange in - return partialResult + closedRange.count + partialResult + closedRange.count } guard var portIndex = (0 ..< portAmount).randomElement() else { @@ -169,7 +169,7 @@ public enum RelaySelector { } private static func parseRawPortRanges(_ rawPortRanges: [[UInt16]]) -> [ClosedRange<UInt16>] { - return rawPortRanges.compactMap { inputRange -> ClosedRange<UInt16>? in + rawPortRanges.compactMap { inputRange -> ClosedRange<UInt16>? in guard inputRange.count == 2 else { return nil } let startPort = inputRange[0] @@ -184,7 +184,7 @@ public enum RelaySelector { } private static func parseRelaysResponse(_ response: REST.ServerRelaysResponse) -> [RelayWithLocation] { - return response.wireguard.relays.compactMap { serverRelay -> RelayWithLocation? in + response.wireguard.relays.compactMap { serverRelay -> RelayWithLocation? in guard let serverLocation = response.locations[serverRelay.location] else { return nil } let locationComponents = serverRelay.location.split(separator: "-") @@ -206,7 +206,7 @@ public enum RelaySelector { public struct NoRelaysSatisfyingConstraintsError: LocalizedError { public var errorDescription: String? { - return "No relays satisfying constraints." + "No relays satisfying constraints." } } @@ -216,7 +216,7 @@ public struct RelaySelectorResult: Codable { public var location: Location public var packetTunnelRelay: PacketTunnelRelay { - return PacketTunnelRelay( + PacketTunnelRelay( ipv4Relay: endpoint.ipv4Relay, ipv6Relay: endpoint.ipv6Relay, hostname: relay.hostname, diff --git a/ios/Shared/ApplicationConfiguration.swift b/ios/Shared/ApplicationConfiguration.swift index 07e48aa02e..f841a9c49b 100644 --- a/ios/Shared/ApplicationConfiguration.swift +++ b/ios/Shared/ApplicationConfiguration.swift @@ -12,17 +12,17 @@ import struct Network.IPv4Address enum ApplicationConfiguration { /// Shared container security group identifier. static var securityGroupIdentifier: String { - return Bundle.main.object(forInfoDictionaryKey: "ApplicationSecurityGroupIdentifier") as! String + Bundle.main.object(forInfoDictionaryKey: "ApplicationSecurityGroupIdentifier") as! String } /// Container URL for security group. static var containerURL: URL { - return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: securityGroupIdentifier)! + FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: securityGroupIdentifier)! } /// Returns URL for log file associated with application target and located within shared container. static func logFileURL(for target: ApplicationTarget) -> URL { - return containerURL.appendingPathComponent("\(target.bundleIdentifier).log", isDirectory: false) + containerURL.appendingPathComponent("\(target.bundleIdentifier).log", isDirectory: false) } /// Privacy policy URL. diff --git a/ios/TunnelProviderMessaging/PacketTunnelOptions.swift b/ios/TunnelProviderMessaging/PacketTunnelOptions.swift index 623b67631a..9f81dd89ea 100644 --- a/ios/TunnelProviderMessaging/PacketTunnelOptions.swift +++ b/ios/TunnelProviderMessaging/PacketTunnelOptions.swift @@ -26,7 +26,7 @@ public struct PacketTunnelOptions { private var _rawOptions: [String: NSObject] public func rawOptions() -> [String: NSObject] { - return _rawOptions + _rawOptions } public init() { @@ -48,16 +48,16 @@ public struct PacketTunnelOptions { } public func isOnDemand() -> Bool { - return _rawOptions[Keys.isOnDemand.rawValue] as? Int == 1 + _rawOptions[Keys.isOnDemand.rawValue] as? Int == 1 } /// Encode custom parameter value private static func encode(_ value: some Codable) throws -> Data { - return try JSONEncoder().encode(value) + try JSONEncoder().encode(value) } /// Decode custom parameter value private static func decode<T: Codable>(_ type: T.Type, _ data: Data) throws -> T { - return try JSONDecoder().decode(T.self, from: data) + try JSONDecoder().decode(T.self, from: data) } } diff --git a/ios/TunnelProviderMessaging/TunnelProviderMessage.swift b/ios/TunnelProviderMessaging/TunnelProviderMessage.swift index 877d7c5047..e42448061c 100644 --- a/ios/TunnelProviderMessaging/TunnelProviderMessage.swift +++ b/ios/TunnelProviderMessaging/TunnelProviderMessage.swift @@ -47,6 +47,6 @@ public enum TunnelProviderMessage: Codable, CustomStringConvertible { } public func encode() throws -> Data { - return try JSONEncoder().encode(self) + try JSONEncoder().encode(self) } } diff --git a/ios/TunnelProviderMessaging/TunnelProviderReply.swift b/ios/TunnelProviderMessaging/TunnelProviderReply.swift index 4e0b188185..ddda2e733f 100644 --- a/ios/TunnelProviderMessaging/TunnelProviderReply.swift +++ b/ios/TunnelProviderMessaging/TunnelProviderReply.swift @@ -21,6 +21,6 @@ public struct TunnelProviderReply<T: Codable>: Codable { } public func encode() throws -> Data { - return try JSONEncoder().encode(self) + try JSONEncoder().encode(self) } } |
