Add SwiftLint phase (#262)

This commit is contained in:
Davide De Rosa 2023-03-17 21:55:47 +01:00 committed by GitHub
parent cecf64d871
commit f06f097f27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
227 changed files with 1399 additions and 1389 deletions

View File

@ -1047,6 +1047,7 @@
0E41BDA828671339006346B4 /* Embed Launcher */, 0E41BDA828671339006346B4 /* Embed Launcher */,
0E3152B7223F9EF500F61841 /* Embed Plugins */, 0E3152B7223F9EF500F61841 /* Embed Plugins */,
0EB2B14B2733FB6F007705AB /* Embed Foundation Extensions */, 0EB2B14B2733FB6F007705AB /* Embed Foundation Extensions */,
0E1B5F5D29C5082700FE7D18 /* SwiftLint */,
); );
buildRules = ( buildRules = (
); );
@ -1297,6 +1298,24 @@
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */
0E1B5F5D29C5082700FE7D18 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = SwiftLint;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
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";
};
0EADDC7227F0677F0093E303 /* Copy Core Data codegen */ = { 0EADDC7227F0677F0093E303 /* Copy Core Data codegen */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1; alwaysOutOfDate = 1;

View File

@ -29,7 +29,7 @@ import UIKit
class AppDelegate: NSObject, UIApplicationDelegate, ObservableObject { class AppDelegate: NSObject, UIApplicationDelegate, ObservableObject {
private let mac = MacBundle.shared private let mac = MacBundle.shared
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
#if targetEnvironment(macCatalyst) #if targetEnvironment(macCatalyst)
mac.configure() mac.configure()
mac.menu.install() mac.menu.install()

View File

@ -39,7 +39,7 @@ extension IntentDispatcher {
typealias VPNIntentActivity = IntentActivity<VPNManager> typealias VPNIntentActivity = IntentActivity<VPNManager>
static let enableVPN = VPNIntentActivity(name: Constants.Activities.enableVPN) { activity, vpnManager in static let enableVPN = VPNIntentActivity(name: Constants.Activities.enableVPN) { _, vpnManager in
pp_log.info("Enabling VPN...") pp_log.info("Enabling VPN...")
Task { Task {
@ -51,7 +51,7 @@ extension IntentDispatcher {
} }
} }
static let disableVPN = VPNIntentActivity(name: Constants.Activities.disableVPN) { activity, vpnManager in static let disableVPN = VPNIntentActivity(name: Constants.Activities.disableVPN) { _, vpnManager in
pp_log.info("Disabling VPN...") pp_log.info("Disabling VPN...")
Task { Task {
@ -111,22 +111,22 @@ extension IntentDispatcher {
} }
} }
static let trustCellularNetwork = VPNIntentActivity(name: Constants.Activities.trustCellularNetwork) { activity, vpnManager in static let trustCellularNetwork = VPNIntentActivity(name: Constants.Activities.trustCellularNetwork) { _, vpnManager in
pp_log.info("Trusting mobile network...") pp_log.info("Trusting mobile network...")
handleCellularNetwork(true, vpnManager) handleCellularNetwork(true, vpnManager)
} }
static let trustCurrentNetwork = VPNIntentActivity(name: Constants.Activities.trustCurrentNetwork) { activity, vpnManager in static let trustCurrentNetwork = VPNIntentActivity(name: Constants.Activities.trustCurrentNetwork) { _, vpnManager in
pp_log.info("Trusting current Wi-Fi...") pp_log.info("Trusting current Wi-Fi...")
handleCurrentNetwork(true, vpnManager) handleCurrentNetwork(true, vpnManager)
} }
static let untrustCellularNetwork = VPNIntentActivity(name: Constants.Activities.untrustCellularNetwork) { activity, vpnManager in static let untrustCellularNetwork = VPNIntentActivity(name: Constants.Activities.untrustCellularNetwork) { _, vpnManager in
pp_log.info("Untrusting mobile network...") pp_log.info("Untrusting mobile network...")
handleCellularNetwork(false, vpnManager) handleCellularNetwork(false, vpnManager)
} }
static let untrustCurrentNetwork = VPNIntentActivity(name: Constants.Activities.untrustCurrentNetwork) { activity, vpnManager in static let untrustCurrentNetwork = VPNIntentActivity(name: Constants.Activities.untrustCurrentNetwork) { _, vpnManager in
pp_log.info("Untrusting current Wi-Fi...") pp_log.info("Untrusting current Wi-Fi...")
handleCurrentNetwork(false, vpnManager) handleCurrentNetwork(false, vpnManager)
} }

View File

@ -39,7 +39,7 @@ class DefaultLightUtils: LightUtils {
guard app.connectedScenes.isEmpty else { guard app.connectedScenes.isEmpty else {
return return
} }
app.requestSceneSessionActivation(nil, userActivity: nil, options: nil) { error in app.requestSceneSessionActivation(nil, userActivity: nil, options: nil) { _ in
// //
} }
} }

View File

@ -25,7 +25,7 @@
import SwiftUI import SwiftUI
func ??<T>(lhs: Binding<Optional<T>>, rhs: T) -> Binding<T> { func ??<T>(lhs: Binding<T?>, rhs: T) -> Binding<T> {
Binding { Binding {
lhs.wrappedValue ?? rhs lhs.wrappedValue ?? rhs
} set: { } set: {
@ -34,7 +34,7 @@ func ??<T>(lhs: Binding<Optional<T>>, rhs: T) -> Binding<T> {
} }
extension Binding { extension Binding {
func toString() -> Binding<String> where Value == Optional<URL> { func toString() -> Binding<String> where Value == URL? {
.init { .init {
wrappedValue?.absoluteString ?? "" wrappedValue?.absoluteString ?? ""
} set: { } set: {
@ -42,7 +42,7 @@ extension Binding {
} }
} }
func toString<T>() -> Binding<String> where Value == Optional<T>, T: FixedWidthInteger { func toString<T>() -> Binding<String> where Value == T?, T: FixedWidthInteger {
.init { .init {
guard let v = wrappedValue else { guard let v = wrappedValue else {
return "" return ""

View File

@ -77,7 +77,7 @@ struct GenericCreditsView: View {
} }
private var licensesSection: some View { private var licensesSection: some View {
Section ( Section(
header: licensesHeader.map(Text.init) header: licensesHeader.map(Text.init)
) { ) {
ForEach(sortedLicenses, id: \.0) { license in ForEach(sortedLicenses, id: \.0) { license in
@ -98,7 +98,7 @@ struct GenericCreditsView: View {
} }
private var noticesSection: some View { private var noticesSection: some View {
Section ( Section(
header: noticesHeader.map(Text.init) header: noticesHeader.map(Text.init)
) { ) {
ForEach(sortedNotices, id: \.0) { notice in ForEach(sortedNotices, id: \.0) { notice in
@ -108,7 +108,7 @@ struct GenericCreditsView: View {
} }
private var translationsSection: some View { private var translationsSection: some View {
Section ( Section(
header: translationsHeader.map(Text.init) header: translationsHeader.map(Text.init)
) { ) {
ForEach(sortedLanguages, id: \.self) { code in ForEach(sortedLanguages, id: \.self) { code in

View File

@ -28,8 +28,8 @@ import SwiftUI
struct CreditsView: View { struct CreditsView: View {
var body: some View { var body: some View {
GenericCreditsView( GenericCreditsView(
licensesHeader: nil,//L10n.Credits.Sections.Licenses.header, licensesHeader: nil,// L10n.Credits.Sections.Licenses.header,
noticesHeader: nil,//L10n.Credits.Sections.Notices.header, noticesHeader: nil,// L10n.Credits.Sections.Notices.header,
translationsHeader: L10n.Global.Strings.translations, translationsHeader: L10n.Global.Strings.translations,
licenses: Unlocalized.Credits.licenses, licenses: Unlocalized.Credits.licenses,
notices: Unlocalized.Credits.notices, notices: Unlocalized.Credits.notices,

View File

@ -96,7 +96,7 @@ struct DebugLogView: View {
Text(logLines[$0]) Text(logLines[$0])
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
} }
}//.padding() }// .padding()
// TODO: layout, a slight padding would be nice, but it glitches on first touch // TODO: layout, a slight padding would be nice, but it glitches on first touch
} }

View File

@ -145,7 +145,7 @@ private extension View {
} }
private struct HostingWindowFinder: UIViewRepresentable { private struct HostingWindowFinder: UIViewRepresentable {
var callback: (UIWindow?) -> () var callback: (UIWindow?) -> Void
func makeUIView(context: Context) -> UIView { func makeUIView(context: Context) -> UIView {
let view = UIView() let view = UIView()

View File

@ -45,7 +45,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
cfg.hides = true cfg.hides = true
cfg.activates = false cfg.activates = false
cfg.addsToRecentItems = false cfg.addsToRecentItems = false
NSWorkspace.shared.openApplication(at: appURL, configuration: cfg) { app, error in NSWorkspace.shared.openApplication(at: appURL, configuration: cfg) { _, error in
if let error = error { if let error = error {
NSLog("Unable to launch main app: \(error)") NSLog("Unable to launch main app: \(error)")
return return

View File

@ -65,7 +65,7 @@ class PassepartoutMenu {
LaunchOnLoginItem( LaunchOnLoginItem(
L10n.Preferences.Items.LaunchesOnLogin.caption, L10n.Preferences.Items.LaunchesOnLogin.caption,
utils: macMenuDelegate.utils utils: macMenuDelegate.utils
), )
] as [ItemGroup]) ] as [ItemGroup])
if profileManager.hasProfiles { if profileManager.hasProfiles {
@ -88,7 +88,7 @@ class PassepartoutMenu {
$0 ? L10n.Profile.Items.Vpn.TurnOff.caption : L10n.Profile.Items.Vpn.TurnOn.caption $0 ? L10n.Profile.Items.Vpn.TurnOff.caption : L10n.Profile.Items.Vpn.TurnOn.caption
} reconnectTitleBlock: { } reconnectTitleBlock: {
L10n.Global.Strings.reconnect L10n.Global.Strings.reconnect
}, }
] as [ItemGroup]) ] as [ItemGroup])
} }

View File

@ -27,7 +27,7 @@ import Foundation
import OpenVPNAppExtension import OpenVPNAppExtension
class PacketTunnelProvider: OpenVPNTunnelProvider { class PacketTunnelProvider: OpenVPNTunnelProvider {
override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) { override func startTunnel(options: [String: NSObject]?, completionHandler: @escaping (Error?) -> Void) {
appVersion = "\(Constants.Global.appName) \(Constants.Global.appVersionString)" appVersion = "\(Constants.Global.appName) \(Constants.Global.appVersionString)"
dnsTimeout = Constants.OpenVPNTunnel.dnsTimeout dnsTimeout = Constants.OpenVPNTunnel.dnsTimeout
logSeparator = Constants.OpenVPNTunnel.sessionMarker logSeparator = Constants.OpenVPNTunnel.sessionMarker

View File

@ -66,7 +66,7 @@ let package = Package(
.target( .target(
name: "PassepartoutServices", name: "PassepartoutServices",
dependencies: [ dependencies: [
"PassepartoutUtils", "PassepartoutUtils"
], ],
resources: [ resources: [
.copy("API") .copy("API")

View File

@ -10,7 +10,6 @@
import Foundation import Foundation
import CoreData import CoreData
extension CDProfile { extension CDProfile {
@nonobjc public class func fetchRequest() -> NSFetchRequest<CDProfile> { @nonobjc public class func fetchRequest() -> NSFetchRequest<CDProfile> {
@ -25,6 +24,6 @@ extension CDProfile {
} }
extension CDProfile : Identifiable { extension CDProfile: Identifiable {
} }

View File

@ -26,7 +26,6 @@
import Foundation import Foundation
import PassepartoutCore import PassepartoutCore
import PassepartoutProviders import PassepartoutProviders
import PassepartoutCore
extension Profile { extension Profile {
public var requiresCredentials: Bool { public var requiresCredentials: Bool {

View File

@ -62,7 +62,7 @@ public class CoreDataProfileManagerStrategy: ProfileManagerStrategy {
profileRepository.removeProfiles(withIds: ids) profileRepository.removeProfiles(withIds: ids)
} }
public func willUpdateProfiles() -> AnyPublisher<[UUID : Profile], Never> { public func willUpdateProfiles() -> AnyPublisher<[UUID: Profile], Never> {
fetchedProfiles.$value fetchedProfiles.$value
.eraseToAnyPublisher() .eraseToAnyPublisher()
} }

View File

@ -10,7 +10,6 @@
import Foundation import Foundation
import CoreData import CoreData
extension CDInfrastructure { extension CDInfrastructure {
@nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructure> { @nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructure> {
@ -42,6 +41,6 @@ extension CDInfrastructure {
} }
extension CDInfrastructure : Identifiable { extension CDInfrastructure: Identifiable {
} }

View File

@ -10,7 +10,6 @@
import Foundation import Foundation
import CoreData import CoreData
extension CDInfrastructureCategory { extension CDInfrastructureCategory {
@nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructureCategory> { @nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructureCategory> {
@ -76,6 +75,6 @@ extension CDInfrastructureCategory {
} }
extension CDInfrastructureCategory : Identifiable { extension CDInfrastructureCategory: Identifiable {
} }

View File

@ -10,7 +10,6 @@
import Foundation import Foundation
import CoreData import CoreData
extension CDInfrastructureDefaultSettings { extension CDInfrastructureDefaultSettings {
@nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructureDefaultSettings> { @nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructureDefaultSettings> {
@ -23,6 +22,6 @@ extension CDInfrastructureDefaultSettings {
} }
extension CDInfrastructureDefaultSettings : Identifiable { extension CDInfrastructureDefaultSettings: Identifiable {
} }

View File

@ -10,7 +10,6 @@
import Foundation import Foundation
import CoreData import CoreData
extension CDInfrastructureLocation { extension CDInfrastructureLocation {
@nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructureLocation> { @nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructureLocation> {
@ -40,6 +39,6 @@ extension CDInfrastructureLocation {
} }
extension CDInfrastructureLocation : Identifiable { extension CDInfrastructureLocation: Identifiable {
} }

View File

@ -10,7 +10,6 @@
import Foundation import Foundation
import CoreData import CoreData
extension CDInfrastructurePreset { extension CDInfrastructurePreset {
@nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructurePreset> { @nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructurePreset> {
@ -43,6 +42,6 @@ extension CDInfrastructurePreset {
} }
extension CDInfrastructurePreset : Identifiable { extension CDInfrastructurePreset: Identifiable {
} }

View File

@ -10,7 +10,6 @@
import Foundation import Foundation
import CoreData import CoreData
extension CDInfrastructureServer { extension CDInfrastructureServer {
@nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructureServer> { @nonobjc public class func fetchRequest() -> NSFetchRequest<CDInfrastructureServer> {
@ -31,6 +30,6 @@ extension CDInfrastructureServer {
} }
extension CDInfrastructureServer : Identifiable { extension CDInfrastructureServer: Identifiable {
} }

View File

@ -10,7 +10,6 @@
import Foundation import Foundation
import CoreData import CoreData
extension CDProvider { extension CDProvider {
@nonobjc public class func fetchRequest() -> NSFetchRequest<CDProvider> { @nonobjc public class func fetchRequest() -> NSFetchRequest<CDProvider> {
@ -41,6 +40,6 @@ extension CDProvider {
} }
extension CDProvider : Identifiable { extension CDProvider: Identifiable {
} }

View File

@ -108,7 +108,7 @@ extension Utils {
} }
} }
//extension Utils { // extension Utils {
// public static func checkConnectivityURL(_ url: URL, timeout: TimeInterval, completionHandler: @escaping (Bool) -> Void) { // public static func checkConnectivityURL(_ url: URL, timeout: TimeInterval, completionHandler: @escaping (Bool) -> Void) {
// let session = URLSession(configuration: .ephemeral) // let session = URLSession(configuration: .ephemeral)
// let request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData, timeoutInterval: timeout) // let request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData, timeoutInterval: timeout)
@ -128,4 +128,4 @@ extension Utils {
// } // }
// }.resume() // }.resume()
// } // }
//} // }