Drop return in one-line functions

This commit is contained in:
Davide De Rosa 2022-09-04 20:09:31 +02:00
parent ca2c2b9d9c
commit 092d4f5de2
62 changed files with 140 additions and 147 deletions

View File

@ -204,11 +204,11 @@ extension Constants {
private static let githubRawRoot = URL(string: "https://\(Domain.name)/")!
private static func github(repo: String) -> URL {
return githubRoot.appendingPathComponent(repo)
githubRoot.appendingPathComponent(repo)
}
private static func githubRaw(repo: String) -> URL {
return githubRawRoot.appendingPathComponent(repo)
githubRawRoot.appendingPathComponent(repo)
}
static let apple = github(repo: "passepartout-apple")

View File

@ -28,10 +28,10 @@ import PassepartoutLibrary
extension DebugLog {
func decoratedString() -> String {
return decoratedString(Constants.Global.appName, Constants.Global.appVersionString)
decoratedString(Constants.Global.appName, Constants.Global.appVersionString)
}
func decoratedData() -> Data {
return decoratedData(Constants.Global.appName, Constants.Global.appVersionString)
decoratedData(Constants.Global.appName, Constants.Global.appVersionString)
}
}

View File

@ -28,18 +28,18 @@ import TunnelKitCore
extension Endpoint: Identifiable {
public var id: String {
return "\(address):\(proto.port):\(proto.socketType.rawValue)"
"\(address):\(proto.port):\(proto.socketType.rawValue)"
}
}
extension IPv4Settings.Route: Identifiable {
public var id: String {
return "\(destination):\(mask):\(gateway)"
"\(destination):\(mask):\(gateway)"
}
}
extension IPv6Settings.Route: Identifiable {
public var id: String {
return "\(destination):\(prefixLength):\(gateway)"
"\(destination):\(prefixLength):\(gateway)"
}
}

View File

@ -98,19 +98,19 @@ struct LocalProduct: RawRepresentable, Equatable, Hashable {
// MARK: All
static var all: [LocalProduct] {
return allDonations + allFeatures// + allProviders
allDonations + allFeatures// + allProviders
}
var isDonation: Bool {
return rawValue.hasPrefix(LocalProduct.donationsBundle)
rawValue.hasPrefix(LocalProduct.donationsBundle)
}
var isFeature: Bool {
return rawValue.hasPrefix(LocalProduct.featuresBundle)
rawValue.hasPrefix(LocalProduct.featuresBundle)
}
var isProvider: Bool {
return rawValue.hasPrefix(LocalProduct.providersBundle)
rawValue.hasPrefix(LocalProduct.providersBundle)
}
// MARK: RawRepresentable
@ -124,7 +124,7 @@ struct LocalProduct: RawRepresentable, Equatable, Hashable {
extension LocalProduct {
func matchesStoreKitProduct(_ skProduct: SKProduct) -> Bool {
return skProduct.productIdentifier == rawValue
skProduct.productIdentifier == rawValue
}
}

View File

@ -114,11 +114,11 @@ class ProductManager: NSObject, ObservableObject {
}
func product(withIdentifier identifier: LocalProduct) -> SKProduct? {
return inApp.product(withIdentifier: identifier)
inApp.product(withIdentifier: identifier)
}
func featureProducts(including: [LocalProduct]) -> [SKProduct] {
return inApp.products.filter {
inApp.products.filter {
guard let p = LocalProduct(rawValue: $0.productIdentifier) else {
return false
}
@ -133,7 +133,7 @@ class ProductManager: NSObject, ObservableObject {
}
func featureProducts(excluding: [LocalProduct]) -> [SKProduct] {
return inApp.products.filter {
inApp.products.filter {
guard let p = LocalProduct(rawValue: $0.productIdentifier) else {
return false
}
@ -203,19 +203,19 @@ class ProductManager: NSObject, ObservableObject {
}
func isEligibleForFeedback() -> Bool {
return appType == .beta || !purchasedFeatures.isEmpty
appType == .beta || !purchasedFeatures.isEmpty
}
func hasPurchased(_ product: LocalProduct) -> Bool {
return purchasedFeatures.contains(product)
purchasedFeatures.contains(product)
}
func isCancelledPurchase(_ product: LocalProduct) -> Bool {
return cancelledPurchases.contains(product)
cancelledPurchases.contains(product)
}
func purchaseDate(forProduct product: LocalProduct) -> Date? {
return purchaseDates[product]
purchaseDates[product]
}
func reloadReceipt(andNotify: Bool = true) {

View File

@ -53,27 +53,27 @@ class IntentDispatcher {
}
static func intentEnable() -> EnableVPNIntent {
return EnableVPNIntent()
EnableVPNIntent()
}
static func intentDisable() -> DisableVPNIntent {
return DisableVPNIntent()
DisableVPNIntent()
}
static func intentTrustWiFi() -> TrustCurrentNetworkIntent {
return TrustCurrentNetworkIntent()
TrustCurrentNetworkIntent()
}
static func intentUntrustWiFi() -> UntrustCurrentNetworkIntent {
return UntrustCurrentNetworkIntent()
UntrustCurrentNetworkIntent()
}
static func intentTrustCellular() -> TrustCellularNetworkIntent {
return TrustCellularNetworkIntent()
TrustCellularNetworkIntent()
}
static func intentUntrustCellular() -> UntrustCellularNetworkIntent {
return UntrustCellularNetworkIntent()
UntrustCellularNetworkIntent()
}
// MARK: Donations

View File

@ -32,7 +32,7 @@ struct ActivityView: UIViewControllerRepresentable {
let applicationActivities: [UIActivity]? = nil
func makeUIViewController(context: UIViewControllerRepresentableContext<ActivityView>) -> UIActivityViewController {
return UIActivityViewController(activityItems: activityItems, applicationActivities: applicationActivities)
UIActivityViewController(activityItems: activityItems, applicationActivities: applicationActivities)
}
func updateUIViewController(_ uiViewController: UIActivityViewController, context: UIViewControllerRepresentableContext<ActivityView>) {

View File

@ -158,7 +158,7 @@ extension EditableTextList {
private func binding(toEditedElement element: IdentifiableString) -> Binding<String> {
// print(">>> <-> \(element)")
return .init {
.init {
editedTextStrings[element.id] ?? element.string
} set: {
editedTextStrings[element.id] = $0

View File

@ -59,19 +59,19 @@ struct GenericCreditsView: View {
}
private var sortedLicenses: [License] {
return licenses.sorted {
licenses.sorted {
$0.0.lowercased() < $1.0.lowercased()
}
}
private var sortedNotices: [Notice] {
return notices.sorted {
notices.sorted {
$0.0.lowercased() < $1.0.lowercased()
}
}
private var sortedLanguages: [String] {
return translations.keys.sorted {
translations.keys.sorted {
$0.localizedAsCountryCode < $1.localizedAsCountryCode
}
}
@ -174,6 +174,6 @@ extension GenericCreditsView {
private extension String {
var localizedAsCountryCode: String {
return Locale.current.localizedString(forLanguageCode: self)?.capitalized ?? self
Locale.current.localizedString(forLanguageCode: self)?.capitalized ?? self
}
}

View File

@ -33,7 +33,7 @@ public struct IntentActivity<UserObject> {
extension View {
public func onIntentActivity<UserObject>(_ activity: IntentActivity<UserObject>, object: UserObject) -> some View {
return onContinueUserActivity(activity.name) {
onContinueUserActivity(activity.name) {
activity.handler($0, object)
}
}

View File

@ -43,7 +43,7 @@ public class Reviewer: ObservableObject {
@discardableResult
public func reportEvent() -> Bool {
return reportEvents(1)
reportEvents(1)
}
@discardableResult
@ -88,6 +88,6 @@ public class Reviewer: ObservableObject {
}
public static func urlForReview(withAppId appId: String) -> URL {
return URL(string: "https://apps.apple.com/app/id\(appId)?action=write-review")!
URL(string: "https://apps.apple.com/app/id\(appId)?action=write-review")!
}
}

View File

@ -34,15 +34,15 @@ struct Shortcut: Identifiable, Hashable, Comparable {
}
var id: UUID {
return native.identifier
native.identifier
}
static func ==(lhs: Self, rhs: Self) -> Bool {
return lhs.phrase == rhs.phrase
lhs.phrase == rhs.phrase
}
static func <(lhs: Self, rhs: Self) -> Bool {
return lhs.phrase < rhs.phrase
lhs.phrase < rhs.phrase
}
func hash(into hasher: inout Hasher) {
@ -50,6 +50,6 @@ struct Shortcut: Identifiable, Hashable, Comparable {
}
private var phrase: String {
return native.invocationPhrase.lowercased()
native.invocationPhrase.lowercased()
}
}

View File

@ -159,7 +159,7 @@ extension AddHostView {
}
private func alertOverwriteExistingProfile() -> Alert {
return Alert(
Alert(
title: Text(L10n.AddProfile.Shared.title),
message: Text(L10n.AddProfile.Shared.Alerts.Overwrite.message),
primaryButton: .destructive(Text(L10n.Global.Strings.ok)) {

View File

@ -158,6 +158,6 @@ extension AddProviderView {
private extension ProviderMetadata {
var navigationId: String {
return "navigation.\(name)"
"navigation.\(name)"
}
}

View File

@ -162,7 +162,7 @@ extension DiagnosticsView.OpenVPNView {
}
private var debugLogURL: URL? {
return vpnManager.debugLogURL(forProtocol: vpnProtocol)
vpnManager.debugLogURL(forProtocol: vpnProtocol)
}
}

View File

@ -57,7 +57,7 @@ extension DiagnosticsView {
}
private var debugLogURL: URL? {
return vpnManager.debugLogURL(forProtocol: .wireGuard)
vpnManager.debugLogURL(forProtocol: .wireGuard)
}
}
}

View File

@ -148,7 +148,7 @@ extension DonateView {
private extension ProductManager {
var donations: [SKProduct] {
return products.filter { product in
products.filter { product in
LocalProduct.allDonations.contains {
$0.matchesStoreKitProduct(product)
}

View File

@ -267,7 +267,7 @@ extension EndpointView.OpenVPNView {
}
private var filteredRemotes: [Endpoint]? {
return builder.remotes?.filter {
builder.remotes?.filter {
$0.proto.socketType == selectedSocketType && $0.proto.port == selectedPort
}
}

View File

@ -194,9 +194,9 @@ extension PaywallView.PurchaseView {
private var skPlatformVersion: SKProduct? {
#if targetEnvironment(macCatalyst)
return productManager.product(withIdentifier: .fullVersion_macOS)
productManager.product(withIdentifier: .fullVersion_macOS)
#else
return productManager.product(withIdentifier: .fullVersion_iOS)
productManager.product(withIdentifier: .fullVersion_iOS)
#endif
}
@ -215,7 +215,7 @@ extension PaywallView.PurchaseView {
}
private var platformVersionExtra: [String] {
return productManager.featureProducts(excluding: [
productManager.featureProducts(excluding: [
.fullVersion,
.fullVersion_iOS,
.fullVersion_macOS
@ -227,7 +227,7 @@ extension PaywallView.PurchaseView {
}
private var fullVersionExtra: [String] {
return productManager.featureProducts(including: [
productManager.featureProducts(including: [
.fullVersion_iOS,
.fullVersion_macOS
]).map {

View File

@ -107,7 +107,7 @@ extension ProfileView {
}
private var currentProviderServerDescription: String? {
return profile.providerServer(providerManager)?.localizedLongDescription
profile.providerServer(providerManager)?.localizedLongDescription
}
private var currentProviderCountryImage: Image? {
@ -118,11 +118,11 @@ extension ProfileView {
}
private var currentProviderPreset: String? {
return providerManager.localizedPreset(forProfile: profile)
providerManager.localizedPreset(forProfile: profile)
}
private var lastInfrastructureUpdate: String? {
return providerManager.localizedInfrastructureUpdate(forProfile: profile)
providerManager.localizedInfrastructureUpdate(forProfile: profile)
}
private func refreshInfrastructure() {

View File

@ -63,7 +63,7 @@ extension ProfileView {
}
private func alertOverwriteExistingProfile() -> Alert {
return Alert(
Alert(
title: Text(L10n.Profile.Alerts.Rename.title),
message: Text(L10n.AddProfile.Shared.Alerts.Overwrite.message),
primaryButton: .destructive(Text(L10n.Global.Strings.ok)) {

View File

@ -39,7 +39,7 @@ struct ProfileView: View {
case paywallTrustedNetworks
var id: Int {
return rawValue
rawValue
}
}

View File

@ -225,7 +225,7 @@ extension ProviderLocationView {
}
private func isFavoriteLocation(_ location: ProviderLocation) -> Bool {
return favoriteLocationIds?.contains(location.id) ?? false
favoriteLocationIds?.contains(location.id) ?? false
}
private func toggleFavoriteLocation(_ location: ProviderLocation) {
@ -295,7 +295,7 @@ extension ProviderLocationView {
}
private var servers: [ProviderServer] {
return providerManager.servers(forLocation: location).sorted()
providerManager.servers(forLocation: location).sorted()
}
}
}

View File

@ -99,6 +99,6 @@ struct ProviderPresetView: View {
// some providers (e.g. NordVPN) have specific presets based on selected server
private var availablePresets: [ProviderServer.Preset] {
return server?.presets?.sorted() ?? []
server?.presets?.sorted() ?? []
}
}

View File

@ -41,7 +41,7 @@ struct VPNStatusText: View {
}
private var statusText: String {
return currentVPNState.localizedStatusDescription(
currentVPNState.localizedStatusDescription(
isActiveProfile: isActiveProfile,
withErrors: true,
dataCountIfAvailable: true

View File

@ -76,19 +76,19 @@ extension ObservableVPNState {
extension Profile.Header: Comparable {
public static func <(lhs: Self, rhs: Self) -> Bool {
return lhs.name.lowercased() < rhs.name.lowercased()
lhs.name.lowercased() < rhs.name.lowercased()
}
}
extension Profile.OpenVPNSettings {
var endpointDescription: String? {
return customEndpoint?.address ?? configuration.remotes?.first?.address
customEndpoint?.address ?? configuration.remotes?.first?.address
}
}
extension Profile.WireGuardSettings {
var endpointDescription: String? {
return configuration.tunnelConfiguration.peers.first?.endpoint?.stringRepresentation
configuration.tunnelConfiguration.peers.first?.endpoint?.stringRepresentation
}
}

View File

@ -57,7 +57,7 @@ enum Unlocalized {
enum Keychain {
static func passwordLabel(_ profileName: String, vpnProtocol: VPNProtocolType) -> String {
return "\(Constants.Global.appName): \(profileName) (\(vpnProtocol.description))"
"\(Constants.Global.appName): \(profileName) (\(vpnProtocol.description))"
}
}
@ -67,7 +67,7 @@ enum Unlocalized {
static let subject = "\(appName) - Report issue"
static func body(_ description: String, _ metadata: String) -> String {
return "Hi,\n\n\(description)\n\n\(metadata)\n\nRegards"
"Hi,\n\n\(description)\n\n\(metadata)\n\nRegards"
}
static let template = "description of the issue: "
@ -123,7 +123,7 @@ enum Unlocalized {
static let subject = "\(appName) - Translations"
static func body(_ description: String) -> String {
return "Hi,\n\n\(description)\n\nRegards"
"Hi,\n\n\(description)\n\nRegards"
}
static let template = "I offer to translate to: "

View File

@ -41,11 +41,7 @@ struct ProfileItemGroup: ItemGroup {
func asMenuItems(withParent parent: NSMenu) -> [NSMenuItem] {
profileManager.profiles.map {
if $0.isProvider {
return providerItem(withProfile: $0, parent: parent)
} else {
return hostItem(withProfile: $0, parent: parent)
}
$0.isProvider ? providerItem(withProfile: $0, parent: parent) : hostItem(withProfile: $0, parent: parent)
}
}

View File

@ -40,7 +40,7 @@ extension ProviderLocationItem {
}
var isActiveLocation: Bool {
return location.id == profile.providerServer?.locationId
location.id == profile.providerServer?.locationId
}
var isOnlyServer: Bool {

View File

@ -58,7 +58,7 @@ extension Profile {
public var hostWireGuardSettings: WireGuardSettings? {
get {
return host?.wgSettings
host?.wgSettings
}
set {
host?.wgSettings = newValue

View File

@ -27,7 +27,7 @@ import Foundation
extension Profile {
public var isProvider: Bool {
return provider != nil
provider != nil
}
public var vpnProtocols: [VPNProtocolType] {

View File

@ -46,7 +46,7 @@ extension Profile {
}
public func providerServerId() -> String? {
return provider?.vpnSettings[currentVPNProtocol]?.serverId
provider?.vpnSettings[currentVPNProtocol]?.serverId
}
public mutating func setProviderServer(_ server: ProviderServer) {
@ -72,7 +72,7 @@ extension Profile {
}
public func providerFavoriteLocationIds() -> Set<String>? {
return provider?.vpnSettings[currentVPNProtocol]?.favoriteLocationIds
provider?.vpnSettings[currentVPNProtocol]?.favoriteLocationIds
}
public mutating func setProviderFavoriteLocationIds(_ ids: Set<String>?) {
@ -80,7 +80,7 @@ extension Profile {
}
public func providerCustomEndpoint() -> Endpoint? {
return provider?.vpnSettings[currentVPNProtocol]?.customEndpoint
provider?.vpnSettings[currentVPNProtocol]?.customEndpoint
}
public mutating func setProviderCustomEndpoint(_ endpoint: Endpoint?) {
@ -88,7 +88,7 @@ extension Profile {
}
public func providerAccount() -> Profile.Account? {
return provider?.vpnSettings[currentVPNProtocol]?.account
provider?.vpnSettings[currentVPNProtocol]?.account
}
public mutating func setProviderAccount(_ account: Profile.Account?) {

View File

@ -33,6 +33,6 @@ public struct DebugLog {
}
public var contentData: Data? {
return content.data(using: .utf8)
content.data(using: .utf8)
}
}

View File

@ -64,7 +64,7 @@ extension Profile {
// MARK: Identifiable
public var id: UUID {
return uuid
uuid
}
}
}

View File

@ -29,7 +29,7 @@ import TunnelKitOpenVPN
extension Profile {
public struct OpenVPNSettings: Codable, Equatable, VPNProtocolProviding {
public var vpnProtocol: VPNProtocolType {
return .openVPN
.openVPN
}
public var configuration: OpenVPN.Configuration

View File

@ -29,7 +29,7 @@ import TunnelKitWireGuard
extension Profile {
public struct WireGuardSettings: Codable, Equatable, VPNProtocolProviding {
public var vpnProtocol: VPNProtocolType {
return .wireGuard
.wireGuard
}
public var configuration: WireGuard.Configuration

View File

@ -111,7 +111,7 @@ public struct Profile: Identifiable, Codable, Equatable {
// MARK: Identifiable
public var id: UUID {
return header.id
header.id
}
}

View File

@ -89,7 +89,7 @@ public struct ProviderServer: Identifiable {
}
public func preset(withId presetId: String) -> Preset? {
return presets?.first {
presets?.first {
$0.id == presetId
}
}

View File

@ -104,7 +104,7 @@ extension UpgradeManager {
}
private var appGroup: String {
return "group.com.algoritmico.Passepartout"
"group.com.algoritmico.Passepartout"
}
func doMigrateToV2() -> [Profile] {
@ -368,7 +368,7 @@ extension UpgradeManager {
}
private func migratedV1Choice(_ map: Map, key: String) -> Network.Choice {
return (map[key] as? String) == "manual" ? .manual : .automatic
(map[key] as? String) == "manual" ? .manual : .automatic
}
}

View File

@ -32,12 +32,12 @@ extension Profile.OpenVPNSettings: GatewaySettingsProviding {
// route-gateway
public var isDefaultIPv4: Bool {
return configuration.routingPolicies?.contains(.IPv4) ?? false
configuration.routingPolicies?.contains(.IPv4) ?? false
}
// ifconfig-ipv6
public var isDefaultIPv6: Bool {
return configuration.routingPolicies?.contains(.IPv6) ?? false
configuration.routingPolicies?.contains(.IPv6) ?? false
}
}
@ -45,27 +45,27 @@ extension Profile.OpenVPNSettings: DNSSettingsProviding {
// not a dhcp-option
public var dnsProtocol: DNSProtocol? {
return (configuration.isDNSEnabled ?? true) ? .plain : nil
(configuration.isDNSEnabled ?? true) ? .plain : nil
}
// dhcp-option DNS
public var dnsServers: [String]? {
return configuration.dnsServers
configuration.dnsServers
}
// dhcp-option DOMAIN/DOMAIN-SEARCH
public var dnsSearchDomains: [String]? {
return configuration.searchDomains
configuration.searchDomains
}
// not a dhcp-option
public var dnsHTTPSURL: URL? {
return nil
nil
}
// not a dhcp-option
public var dnsTLSServerName: String? {
return nil
nil
}
}
@ -73,17 +73,17 @@ extension Profile.OpenVPNSettings: ProxySettingsProviding {
// dhcp-option PROXY_HTTP[S]
public var proxyServer: Proxy? {
return configuration.httpsProxy ?? configuration.httpProxy
configuration.httpsProxy ?? configuration.httpProxy
}
// dhcp-option PROXY_BYPASS
public var proxyBypassDomains: [String]? {
return configuration.proxyBypassDomains
configuration.proxyBypassDomains
}
// dhcp-option PROXY_AUTO_CONFIG_URL
public var proxyAutoConfigurationURL: URL? {
return configuration.proxyAutoConfigurationURL
configuration.proxyAutoConfigurationURL
}
}
@ -91,6 +91,6 @@ extension Profile.OpenVPNSettings: MTUSettingsProviding {
public var mtuBytes: Int {
// tun-mtu
return configuration.mtu ?? 0
configuration.mtu ?? 0
}
}

View File

@ -28,12 +28,12 @@ import PassepartoutCore
extension Profile.Header {
public var logDescription: String {
return "{\(id), '\(name)'}"
"{\(id), '\(name)'}"
}
}
extension Profile {
public var logDescription: String {
return header.logDescription
header.logDescription
}
}

View File

@ -30,28 +30,28 @@ import PassepartoutCore
extension Profile.WireGuardSettings: DNSSettingsProviding {
public var dnsProtocol: DNSProtocol? {
return .plain
.plain
}
public var dnsServers: [String]? {
return configuration.dnsServers
configuration.dnsServers
}
public var dnsSearchDomains: [String]? {
return configuration.dnsSearchDomains
configuration.dnsSearchDomains
}
public var dnsHTTPSURL: URL? {
return nil
nil
}
public var dnsTLSServerName: String? {
return nil
nil
}
}
extension Profile.WireGuardSettings: MTUSettingsProviding {
public var mtuBytes: Int {
return Int(configuration.mtu ?? 0)
Int(configuration.mtu ?? 0)
}
}

View File

@ -82,7 +82,7 @@ extension ProfileManager {
private extension Profile {
var keychainEntry: String? {
return "\(id.uuidString):\(currentVPNProtocol.description):\(account.username)"
"\(id.uuidString):\(currentVPNProtocol.description):\(account.username)"
}
}

View File

@ -130,11 +130,11 @@ struct ServerMapper: DTOMapper, ModelMapper {
private extension WSProviderServer {
var encodedExtraCountryCodes: String? {
return extraCountryCodes?.joined(separator: ",")
extraCountryCodes?.joined(separator: ",")
}
var encodedTags: String? {
return tags?.joined(separator: ",")
tags?.joined(separator: ",")
}
var encodedIPAddresses: String? {
@ -149,18 +149,15 @@ private extension WSProviderServer {
private extension CDInfrastructureServer {
var decodedExtraCountryCodes: [String]? {
return extraCountryCodes?
.components(separatedBy: ",")
extraCountryCodes?.components(separatedBy: ",")
}
var decodedTags: [String]? {
return tags?
.components(separatedBy: ",")
tags?.components(separatedBy: ",")
}
var decodedIPAddresses: [String] {
return ipAddresses?
.components(separatedBy: ",") ?? []
ipAddresses?.components(separatedBy: ",") ?? []
}
}

View File

@ -50,7 +50,7 @@ public struct WSProvidersIndex: Codable {
// MARK: CustomStringConvertible
public var description: String {
return fullName
fullName
}
}

View File

@ -48,13 +48,13 @@ public class DefaultWebServices: WebServices {
}
private var fileType: String {
return "json"
"json"
}
// MARK: GenericWebEndpoint
var path: String {
return "\(pathName).\(fileType)"
"\(pathName).\(fileType)"
}
}

View File

@ -35,7 +35,7 @@ public enum WebError: GenericWebServicesError, LocalizedError {
case unknown
public static func httpStatus(_ status: Int) -> WebError {
return .http(status)
.http(status)
}
public var errorDescription: String? {

View File

@ -35,11 +35,11 @@ public class GenericWebParser {
}()
public static func lastModifiedDate(string: String) -> Date? {
return lmFormatter.date(from: string)
lmFormatter.date(from: string)
}
public static func lastModifiedString(date: Date) -> String {
return lmFormatter.string(from: date)
lmFormatter.string(from: date)
}
public static func lastModifiedString(ofFileURL url: URL) -> String? {

View File

@ -40,6 +40,6 @@ public struct GenericWebResponse<T> {
public let isCached: Bool
public static func empty() -> GenericWebResponse {
return GenericWebResponse(value: nil, lastModifiedString: nil, isCached: false)
GenericWebResponse(value: nil, lastModifiedString: nil, isCached: false)
}
}

View File

@ -51,7 +51,7 @@ public class InApp<PID: Hashable & RawRepresentable>: NSObject,
private var productsMap: [PID: SKProduct]
public var products: [SKProduct] {
return [SKProduct](productsMap.values)
[SKProduct](productsMap.values)
}
private var productObservers: [ProductObserver]
@ -110,7 +110,7 @@ public class InApp<PID: Hashable & RawRepresentable>: NSObject,
}
public func product(withIdentifier productIdentifier: PID) -> SKProduct? {
return productsMap[productIdentifier]
productsMap[productIdentifier]
}
// MARK: SKProductsRequestDelegate
@ -218,6 +218,6 @@ extension SKProduct {
}
public var localizedPrice: String? {
return localizedCurrencyFormatter.string(from: price)
localizedCurrencyFormatter.string(from: price)
}
}

View File

@ -31,11 +31,11 @@ public class KeyedCache<K: Hashable, V> {
private var store: [K: V] = [:]
public var isEmpty: Bool {
return store.isEmpty
store.isEmpty
}
public var storeValues: [V] {
return Array(store.values)
Array(store.values)
}
public init(_ query: String) {

View File

@ -33,6 +33,6 @@ extension JSON {
}
public func encoded() throws -> Data {
return try JSONEncoder().encode(self)
try JSONEncoder().encode(self)
}
}

View File

@ -40,7 +40,7 @@ private let componentsFormatter: DateComponentsFormatter = {
extension Date {
public var timestamp: String {
return timestampFormatter.string(from: self)
timestampFormatter.string(from: self)
}
}

View File

@ -33,7 +33,7 @@ import CoreWLAN
extension Utils {
#if targetEnvironment(simulator)
public static func hasCellularData() -> Bool {
return true
true
}
#else
public static func hasCellularData() -> Bool {

View File

@ -45,7 +45,7 @@ extension Utils {
extension String: StrippableContent {
public var stripped: String {
return trimmingCharacters(in: .whitespacesAndNewlines)
trimmingCharacters(in: .whitespacesAndNewlines)
}
public var strippedNotEmpty: String? {
@ -59,13 +59,13 @@ extension String: StrippableContent {
extension StringProtocol where Index == String.Index {
public func nsRange(from range: Range<Index>) -> NSRange {
return NSRange(range, in: self)
NSRange(range, in: self)
}
}
extension String {
public var localizedAsCountryCode: String {
return Locale.current.localizedString(forRegionCode: self) ?? self
Locale.current.localizedString(forRegionCode: self) ?? self
}
}

View File

@ -31,7 +31,7 @@ import Foundation
extension Bundle {
public var isTestFlight: Bool {
#if targetEnvironment(simulator)
return true
true
#elseif targetEnvironment(macCatalyst) || os(macOS)
var status = noErr
@ -64,9 +64,9 @@ extension Bundle {
)
return status == errSecSuccess
#elseif os(iOS)
return appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
#else
return false
false
#endif
}
}

View File

@ -48,7 +48,7 @@ extension URL {
UIApplication.shared.open(url)
return true
#else
return NSWorkspace.shared.open(url)
NSWorkspace.shared.open(url)
#endif
}

View File

@ -83,6 +83,6 @@ extension Profile.OnDemand {
}
private var policyRule: NEOnDemandRule {
return disconnectsIfNotMatching ? NEOnDemandRuleDisconnect() : NEOnDemandRuleIgnore()
disconnectsIfNotMatching ? NEOnDemandRuleDisconnect() : NEOnDemandRuleIgnore()
}
}

View File

@ -30,36 +30,36 @@ import PassepartoutCore
extension VPNProtocolType: Comparable {
public static func <(lhs: Self, rhs: Self) -> Bool {
return lhs.description < rhs.description
lhs.description < rhs.description
}
}
extension OpenVPN.ProviderConfiguration: VPNProtocolProviding {
public var vpnProtocol: VPNProtocolType {
return .openVPN
.openVPN
}
}
extension WireGuard.ProviderConfiguration: VPNProtocolProviding {
public var vpnProtocol: VPNProtocolType {
return .wireGuard
.wireGuard
}
}
extension VPNProtocolType {
public var supportsGateway: Bool {
return true
true
}
public var supportsDNS: Bool {
return true
true
}
public var supportsProxy: Bool {
return self == .openVPN
self == .openVPN
}
public var supportsMTU: Bool {
return true
true
}
}

View File

@ -117,10 +117,10 @@ public class MockVPNManagerStrategy: VPNManagerStrategy {
}
public func serverConfiguration(forProtocol vpnProtocol: VPNProtocolType) -> Any? {
return nil
nil
}
public func debugLogURL(forProtocol vpnProtocol: VPNProtocolType) -> URL? {
return nil
nil
}
}

View File

@ -122,11 +122,11 @@ public final class VPNManager: ObservableObject {
}
public func serverConfiguration(forProtocol vpnProtocol: VPNProtocolType) -> Any? {
return strategy.serverConfiguration(forProtocol: vpnProtocol)
strategy.serverConfiguration(forProtocol: vpnProtocol)
}
public func debugLogURL(forProtocol vpnProtocol: VPNProtocolType) -> URL? {
return strategy.debugLogURL(forProtocol: vpnProtocol)
strategy.debugLogURL(forProtocol: vpnProtocol)
}
private func clearLastError() {

View File

@ -62,8 +62,8 @@ class UtilsTests: XCTestCase {
}
private func privateSortedLanguages(_ languages: [String], with locale: Locale) -> [String] {
return languages.sorted {
return locale.localizedString(forLanguageCode: $0)! < locale.localizedString(forLanguageCode: $1)!
languages.sorted {
locale.localizedString(forLanguageCode: $0)! < locale.localizedString(forLanguageCode: $1)!
}
}
}