Fine-tune SwiftLint (#265)
This commit is contained in:
parent
1dda8dce98
commit
fbd32d8b26
|
@ -0,0 +1,10 @@
|
||||||
|
included:
|
||||||
|
- Passepartout
|
||||||
|
disabled_rules:
|
||||||
|
- cyclomatic_complexity
|
||||||
|
- file_length
|
||||||
|
- force_cast
|
||||||
|
- identifier_name
|
||||||
|
- line_length
|
||||||
|
- nesting
|
||||||
|
- todo
|
|
@ -32,8 +32,9 @@ CFG_MAC_ID = com.algoritmico.ios.PassepartoutMac
|
||||||
CFG_LAUNCHER_ID = com.algoritmico.ios.PassepartoutLauncher
|
CFG_LAUNCHER_ID = com.algoritmico.ios.PassepartoutLauncher
|
||||||
CFG_GROUP_ID = com.algoritmico.Passepartout
|
CFG_GROUP_ID = com.algoritmico.Passepartout
|
||||||
CFG_APPSTORE_ID = 1433648537
|
CFG_APPSTORE_ID = 1433648537
|
||||||
CFG_COPYRIGHT = Copyright © 2022 Davide De Rosa. All rights reserved.
|
CFG_COPYRIGHT = Copyright © 2023 Davide De Rosa. All rights reserved.
|
||||||
|
|
||||||
PATH = $(PATH):/opt/homebrew/bin:/usr/local/bin:/usr/local/go/bin
|
PATH = $(PATH):/opt/homebrew/bin:/usr/local/bin:/usr/local/go/bin
|
||||||
|
CUSTOM_SCRIPT_PATH = $(PATH)
|
||||||
|
|
||||||
#include? "Secret.xcconfig"
|
#include? "Secret.xcconfig"
|
||||||
|
|
|
@ -1314,7 +1314,7 @@
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
|
shellScript = "PATH=$CUSTOM_SCRIPT_PATH\nif which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
|
||||||
};
|
};
|
||||||
0EADDC7227F0677F0093E303 /* Copy Core Data codegen */ = {
|
0EADDC7227F0677F0093E303 /* Copy Core Data codegen */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
|
|
@ -418,15 +418,9 @@ extension View {
|
||||||
}
|
}
|
||||||
|
|
||||||
func themeSaveButtonLabel() -> some View {
|
func themeSaveButtonLabel() -> some View {
|
||||||
// themeCheckmarkImage.asSystemImage
|
|
||||||
Text(L10n.Global.Strings.save)
|
Text(L10n.Global.Strings.save)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func themeDoneButtonLabel() -> some View {
|
|
||||||
//// themeCheckmarkImage.asSystemImage
|
|
||||||
// Text(L10n.Global.Strings.ok)
|
|
||||||
// }
|
|
||||||
|
|
||||||
func themeTextPicker<T: Hashable>(_ title: String, selection: Binding<T>, values: [T], description: @escaping (T) -> String) -> some View {
|
func themeTextPicker<T: Hashable>(_ title: String, selection: Binding<T>, values: [T], description: @escaping (T) -> String) -> some View {
|
||||||
StyledPicker(title: title, selection: selection, values: values) {
|
StyledPicker(title: title, selection: selection, values: values) {
|
||||||
Text(description($0))
|
Text(description($0))
|
||||||
|
|
|
@ -31,11 +31,11 @@ extension ProviderMetadata: Identifiable, Comparable, Hashable {
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func ==(lhs: Self, rhs: Self) -> Bool {
|
public static func == (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.name == rhs.name
|
lhs.name == rhs.name
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func <(lhs: Self, rhs: Self) -> Bool {
|
public static func < (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.fullName.lowercased() < rhs.fullName.lowercased()
|
lhs.fullName.lowercased() < rhs.fullName.lowercased()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,32 +45,32 @@ extension ProviderMetadata: Identifiable, Comparable, Hashable {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ProviderCategory: Comparable {
|
extension ProviderCategory: Comparable {
|
||||||
public static func ==(lhs: Self, rhs: Self) -> Bool {
|
public static func == (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.name.lowercased() == rhs.name.lowercased()
|
lhs.name.lowercased() == rhs.name.lowercased()
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func <(lhs: Self, rhs: Self) -> Bool {
|
public static func < (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.name.lowercased() < rhs.name.lowercased()
|
lhs.name.lowercased() < rhs.name.lowercased()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ProviderLocation: Comparable {
|
extension ProviderLocation: Comparable {
|
||||||
public static func ==(lhs: Self, rhs: Self) -> Bool {
|
public static func == (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.countryCode == rhs.countryCode
|
lhs.countryCode == rhs.countryCode
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func <(lhs: Self, rhs: Self) -> Bool {
|
public static func < (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.localizedCountry < rhs.localizedCountry
|
lhs.localizedCountry < rhs.localizedCountry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ProviderServer: Comparable {
|
extension ProviderServer: Comparable {
|
||||||
public static func ==(lhs: Self, rhs: Self) -> Bool {
|
public static func == (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.id == rhs.id
|
lhs.id == rhs.id
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Default" comes first (nil localizedName)
|
// "Default" comes first (nil localizedName)
|
||||||
public static func <(lhs: Self, rhs: Self) -> Bool {
|
public static func < (lhs: Self, rhs: Self) -> Bool {
|
||||||
guard lhs.localizedName != rhs.localizedName else {
|
guard lhs.localizedName != rhs.localizedName else {
|
||||||
guard let li = lhs.serverIndex else {
|
guard let li = lhs.serverIndex else {
|
||||||
return true
|
return true
|
||||||
|
@ -97,11 +97,11 @@ extension ProviderServer: Comparable {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ProviderServer.Preset: Comparable {
|
extension ProviderServer.Preset: Comparable {
|
||||||
public static func ==(lhs: Self, rhs: Self) -> Bool {
|
public static func == (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.name == rhs.name
|
lhs.name == rhs.name
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func <(lhs: Self, rhs: Self) -> Bool {
|
public static func < (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.name < rhs.name
|
lhs.name < rhs.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
func ??<T>(lhs: Binding<T?>, rhs: T) -> Binding<T> {
|
func ?? <T>(lhs: Binding<T?>, rhs: T) -> Binding<T> {
|
||||||
Binding {
|
Binding {
|
||||||
lhs.wrappedValue ?? rhs
|
lhs.wrappedValue ?? rhs
|
||||||
} set: {
|
} set: {
|
||||||
|
|
|
@ -192,9 +192,9 @@ extension EditableTextList {
|
||||||
commit()
|
commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func onMove(indexSet: IndexSet, to: Int) {
|
private func onMove(indexSet: IndexSet, to offset: Int) {
|
||||||
var mapped = mapping(identifiableElements)
|
var mapped = mapping(identifiableElements)
|
||||||
mapped.move(fromOffsets: indexSet, toOffset: to)
|
mapped.move(fromOffsets: indexSet, toOffset: offset)
|
||||||
identifiableElements = mapped
|
identifiableElements = mapped
|
||||||
commit()
|
commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,11 @@ struct Shortcut: Identifiable, Hashable, Comparable {
|
||||||
native.identifier
|
native.identifier
|
||||||
}
|
}
|
||||||
|
|
||||||
static func ==(lhs: Self, rhs: Self) -> Bool {
|
static func == (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.phrase == rhs.phrase
|
lhs.phrase == rhs.phrase
|
||||||
}
|
}
|
||||||
|
|
||||||
static func <(lhs: Self, rhs: Self) -> Bool {
|
static func < (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.phrase < rhs.phrase
|
lhs.phrase < rhs.phrase
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ struct Validators {
|
||||||
}
|
}
|
||||||
|
|
||||||
static func notNil(_ string: String?) throws {
|
static func notNil(_ string: String?) throws {
|
||||||
guard let _ = string else {
|
guard string != nil else {
|
||||||
throw ValidationError.notSet
|
throw ValidationError.notSet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ struct Validators {
|
||||||
}
|
}
|
||||||
|
|
||||||
static func url(_ string: String) throws {
|
static func url(_ string: String) throws {
|
||||||
guard let _ = URL(string: string) else {
|
guard URL(string: string) != nil else {
|
||||||
throw ValidationError.url
|
throw ValidationError.url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ struct AddProviderView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func onErrorMessage(_ message: String?, _ scrollProxy: ScrollViewProxy) {
|
private func onErrorMessage(_ message: String?, _ scrollProxy: ScrollViewProxy) {
|
||||||
guard let _ = message else {
|
guard message != nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
scrollToErrorMessage(scrollProxy)
|
scrollToErrorMessage(scrollProxy)
|
||||||
|
|
|
@ -320,40 +320,89 @@ extension EndpointAdvancedView.OpenVPNView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension OpenVPN.Configuration {
|
private extension OpenVPN.Configuration {
|
||||||
var communicationSettings: (cipher: OpenVPN.Cipher?, digest: OpenVPN.Digest?, xor: OpenVPN.XORMethod?)? {
|
struct CommunicationOptions {
|
||||||
|
let cipher: OpenVPN.Cipher?
|
||||||
|
|
||||||
|
let digest: OpenVPN.Digest?
|
||||||
|
|
||||||
|
let xor: OpenVPN.XORMethod?
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CompressionOptions {
|
||||||
|
let framing: OpenVPN.CompressionFraming?
|
||||||
|
|
||||||
|
let algorithm: OpenVPN.CompressionAlgorithm?
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DNSOptions {
|
||||||
|
let servers: [String]
|
||||||
|
|
||||||
|
let domains: [String]
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ProxyOptions {
|
||||||
|
let proxy: Proxy?
|
||||||
|
|
||||||
|
let pac: URL?
|
||||||
|
|
||||||
|
let bypass: [String]
|
||||||
|
}
|
||||||
|
|
||||||
|
struct OtherOptions {
|
||||||
|
let keepAlive: TimeInterval?
|
||||||
|
|
||||||
|
let reneg: TimeInterval?
|
||||||
|
|
||||||
|
let randomizeEndpoint: Bool?
|
||||||
|
|
||||||
|
let randomizeHostnames: Bool?
|
||||||
|
}
|
||||||
|
|
||||||
|
var communicationSettings: CommunicationOptions? {
|
||||||
guard cipher != nil || digest != nil || xorMethod != nil else {
|
guard cipher != nil || digest != nil || xorMethod != nil else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return (cipher, digest, xorMethod)
|
return .init(cipher: cipher, digest: digest, xor: xorMethod)
|
||||||
}
|
}
|
||||||
|
|
||||||
var compressionSettings: (framing: OpenVPN.CompressionFraming?, algorithm: OpenVPN.CompressionAlgorithm?)? {
|
var compressionSettings: CompressionOptions? {
|
||||||
guard compressionFraming != nil || compressionAlgorithm != nil else {
|
guard compressionFraming != nil || compressionAlgorithm != nil else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return (compressionFraming, compressionAlgorithm)
|
return .init(framing: compressionFraming, algorithm: compressionAlgorithm)
|
||||||
}
|
}
|
||||||
|
|
||||||
var dnsSettings: (servers: [String], domains: [String])? {
|
var dnsSettings: DNSOptions? {
|
||||||
guard !(dnsServers?.isEmpty ?? true) || !(searchDomains?.isEmpty ?? true) else {
|
guard !(dnsServers?.isEmpty ?? true) || !(searchDomains?.isEmpty ?? true) else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return (dnsServers ?? [], searchDomains ?? [])
|
return .init(servers: dnsServers ?? [], domains: searchDomains ?? [])
|
||||||
}
|
}
|
||||||
|
|
||||||
var proxySettings: (proxy: Proxy?, pac: URL?, bypass: [String])? {
|
var proxySettings: ProxyOptions? {
|
||||||
guard httpsProxy != nil || httpProxy != nil || proxyAutoConfigurationURL != nil || !(proxyBypassDomains?.isEmpty ?? true) else {
|
guard httpsProxy != nil || httpProxy != nil ||
|
||||||
|
proxyAutoConfigurationURL != nil || !(proxyBypassDomains?.isEmpty ?? true) else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return (httpsProxy ?? httpProxy, proxyAutoConfigurationURL, proxyBypassDomains ?? [])
|
return .init(
|
||||||
|
proxy: httpsProxy ?? httpProxy,
|
||||||
|
pac: proxyAutoConfigurationURL,
|
||||||
|
bypass: proxyBypassDomains ?? []
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var otherSettings: (keepAlive: TimeInterval?, reneg: TimeInterval?, randomizeEndpoint: Bool?, randomizeHostnames: Bool?)? {
|
var otherSettings: OtherOptions? {
|
||||||
guard keepAliveInterval != nil || renegotiatesAfter != nil || randomizeEndpoint != nil || randomizeHostnames != nil else {
|
guard keepAliveInterval != nil || renegotiatesAfter != nil ||
|
||||||
|
randomizeEndpoint != nil || randomizeHostnames != nil else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return (keepAliveInterval, renegotiatesAfter, randomizeEndpoint, randomizeHostnames)
|
return .init(
|
||||||
|
keepAlive: keepAliveInterval,
|
||||||
|
reneg: renegotiatesAfter,
|
||||||
|
randomizeEndpoint: randomizeEndpoint,
|
||||||
|
randomizeHostnames: randomizeHostnames
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,11 +89,17 @@ extension EndpointAdvancedView.WireGuardView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension WireGuard.Configuration {
|
private extension WireGuard.Configuration {
|
||||||
var dnsSettings: (servers: [String], domains: [String])? {
|
struct DNSOptions {
|
||||||
|
let servers: [String]
|
||||||
|
|
||||||
|
let domains: [String]
|
||||||
|
}
|
||||||
|
|
||||||
|
var dnsSettings: DNSOptions? {
|
||||||
guard !dnsServers.isEmpty || !dnsSearchDomains.isEmpty else {
|
guard !dnsServers.isEmpty || !dnsSearchDomains.isEmpty else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return (dnsServers, dnsSearchDomains)
|
return .init(servers: dnsServers, domains: dnsSearchDomains)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ extension OnDemandView.SSIDList {
|
||||||
} set: { newValue in
|
} set: { newValue in
|
||||||
withSSIDs.forEach {
|
withSSIDs.forEach {
|
||||||
guard newValue.contains($0.key) else {
|
guard newValue.contains($0.key) else {
|
||||||
if let _ = withSSIDs[$0.key] {
|
if withSSIDs[$0.key] != nil {
|
||||||
withSSIDs[$0.key] = false
|
withSSIDs[$0.key] = false
|
||||||
} else {
|
} else {
|
||||||
withSSIDs.removeValue(forKey: $0.key)
|
withSSIDs.removeValue(forKey: $0.key)
|
||||||
|
|
|
@ -255,7 +255,7 @@ extension ProviderLocationView {
|
||||||
HStack {
|
HStack {
|
||||||
themeAssetsCountryImage(location.countryCode).asAssetImage
|
themeAssetsCountryImage(location.countryCode).asAssetImage
|
||||||
VStack {
|
VStack {
|
||||||
if let singleServer = location.onlyServer, let _ = singleServer.localizedShortDescription {
|
if let singleServer = location.onlyServer, singleServer.localizedShortDescription != nil {
|
||||||
Text(location.localizedCountry)
|
Text(location.localizedCountry)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
Text(singleServer.localizedShortDescription ?? "")
|
Text(singleServer.localizedShortDescription ?? "")
|
||||||
|
|
|
@ -75,13 +75,13 @@ extension ObservableVPNState {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Profile: Comparable {
|
extension Profile: Comparable {
|
||||||
public static func <(lhs: Self, rhs: Self) -> Bool {
|
public static func < (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.header < rhs.header
|
lhs.header < rhs.header
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Profile.Header: Comparable {
|
extension Profile.Header: Comparable {
|
||||||
public static func <(lhs: Self, rhs: Self) -> Bool {
|
public static func < (lhs: Self, rhs: Self) -> Bool {
|
||||||
lhs.name.lowercased() < rhs.name.lowercased()
|
lhs.name.lowercased() < rhs.name.lowercased()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ class PassepartoutMenu {
|
||||||
] as [ItemGroup])
|
] as [ItemGroup])
|
||||||
}
|
}
|
||||||
|
|
||||||
if let _ = profileManager.activeProfileId {
|
if profileManager.activeProfileId != nil {
|
||||||
children.append(contentsOf: [
|
children.append(contentsOf: [
|
||||||
SeparatorItem(),
|
SeparatorItem(),
|
||||||
VPNItemGroup(
|
VPNItemGroup(
|
||||||
|
|
Loading…
Reference in New Issue