]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Enabled more swiftlint rules
authorEric Kuck <eric@bluelinelabs.com>
Thu, 20 Dec 2018 17:22:37 +0000 (11:22 -0600)
committerEric Kuck <eric@bluelinelabs.com>
Thu, 20 Dec 2018 17:22:37 +0000 (11:22 -0600)
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
WireGuard/.swiftlint.yml
WireGuard/Shared/Logging/Logger.swift
WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift
WireGuard/WireGuard/Tunnel/TunnelErrors.swift
WireGuard/WireGuard/UI/TunnelViewModel.swift
WireGuard/WireGuard/UI/iOS/View/ButtonCell.swift
WireGuard/WireGuard/UI/iOS/ViewController/QRScanViewController.swift
WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift
WireGuard/WireGuard/WireGuardAppError.swift
WireGuard/WireGuardNetworkExtension/DNSResolver.swift
WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift

index f0a450f1a400fa5b9289ae5e20bea95063e036da..93c7ab37f96ba2dc3db12bbb455786aa057fb115 100644 (file)
@@ -3,7 +3,17 @@ disabled_rules:
  - trailing_whitespace
  - todo
 opt_in_rules:
+ - empty_count
+ - empty_string
+ - implicitly_unwrapped_optional
+ - legacy_random
+ - let_var_whitespace
+ - literal_expression_end_indentation
+ - override_in_extension
+ - redundant_type_annotation
+ - toggle_bool
  - unneeded_parentheses_in_closure_argument
+ - unused_import
 # - trailing_closure
 file_length:
   warning: 500
index 10b90d8034a8370e14418876566480a090e88a88..026ec09d6dcc2ccdfef066857a18d94c2c908268 100644 (file)
@@ -8,6 +8,7 @@ public class Logger {
     enum LoggerError: Error {
         case openFailure
     }
+    
     static var global: Logger?
 
     var log: OpaquePointer
index b3c0acdf869fdf70f15476cfd28505370eb1a47d..f4c52c290166acde528d81edf61e968c1a418e2c 100644 (file)
@@ -42,7 +42,7 @@ class WgQuickConfigFileParser {
 
             trimmedLine = trimmedLine.trimmingCharacters(in: .whitespaces)
 
-            guard trimmedLine.count > 0 else { continue }
+            guard !trimmedLine.isEmpty else { continue }
             let lowercasedLine = line.lowercased()
 
             if let equalsIndex = line.firstIndex(of: "=") {
index 16c8072d15e13e686a64a02eee31a95af12f4ad6..45c20f6eea1972c9e1565d5bcb3d74af5cbc8ba8 100644 (file)
@@ -52,6 +52,7 @@ enum TunnelsManagerActivationAttemptError: WireGuardAppError {
 enum TunnelsManagerActivationError: WireGuardAppError {
     case activationFailed
     case activationFailedWithExtensionError(title: String, message: String)
+    
     var alertText: AlertText {
         switch self {
         case .activationFailed:
index 1a88da237ba620e4df0caafbde8628e52a8c3d7b..71cb18e287470cd1142fd2777b559b21a79b0ab6 100644 (file)
@@ -361,7 +361,7 @@ class TunnelViewModel {
     var peersData: [PeerData]
 
     init(tunnelConfiguration: TunnelConfiguration?) {
-        let interfaceData: InterfaceData = InterfaceData()
+        let interfaceData = InterfaceData()
         var peersData = [PeerData]()
         if let tunnelConfiguration = tunnelConfiguration {
             interfaceData.validatedConfiguration = tunnelConfiguration.interface
index 470299339158965de7b60ed96036e9a93607d475..aff17ee7666743f1e6f04c6cc9f95bb85069288d 100644 (file)
@@ -33,7 +33,7 @@ class ButtonCell: UITableViewCell {
             button.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
             contentView.layoutMarginsGuide.bottomAnchor.constraint(equalTo: button.bottomAnchor),
             button.centerXAnchor.constraint(equalTo: contentView.centerXAnchor)
-            ])
+        ])
         
         button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
     }
index 1e231ec9b9111b89e1dfb3217332778fd10229ca..e4b62879f70e126a94dd00ec67fd3fcaed93dd01 100644 (file)
@@ -76,15 +76,11 @@ class QRScanViewController: UIViewController {
         super.viewDidLayoutSubviews()
 
         if let connection = previewLayer?.connection {
-
-            let currentDevice: UIDevice = UIDevice.current
-
-            let orientation: UIDeviceOrientation = currentDevice.orientation
-
-            let previewLayerConnection: AVCaptureConnection = connection
+            let currentDevice = UIDevice.current
+            let orientation = currentDevice.orientation
+            let previewLayerConnection = connection
 
             if previewLayerConnection.isVideoOrientationSupported {
-
                 switch orientation {
                 case .portrait:
                     previewLayerConnection.videoOrientation = .portrait
index c07657fb6f6916f8ccb3f9017c96bb0092df1a75..9dea8b0d4cc1cad607d54fe0df9e0f1de7e82824 100644 (file)
@@ -127,7 +127,7 @@ class TunnelsListTableViewController: UIViewController {
         present(alert, animated: true, completion: nil)
     }
 
-    @objc func settingsButtonTapped(sender: UIBarButtonItem!) {
+    @objc func settingsButtonTapped(sender: UIBarButtonItem) {
         guard tunnelsManager != nil else { return }
         
         let settingsVC = SettingsTableViewController(tunnelsManager: tunnelsManager)
index aa2f9098fe3e7b53cc2b836906f160f6187e09a7..8b725d76f6bc16c7effb7091fccb5bd4b860e7fd 100644 (file)
@@ -3,5 +3,6 @@
 
 protocol WireGuardAppError: Error {
     typealias AlertText = (title: String, message: String)
+    
     var alertText: AlertText { get }
 }
index a30b512daf2f1bfad89473268ad0a4578337652d..32cbf787a74e7950a141d756e7faf8d6f3fdef96 100644 (file)
@@ -21,7 +21,7 @@ class DNSResolver {
     }
 
     static func resolveSync(endpoints: [Endpoint?]) throws -> [Endpoint?] {
-        let dispatchGroup: DispatchGroup = DispatchGroup()
+        let dispatchGroup = DispatchGroup()
 
         if isAllEndpointsAlreadyResolved(endpoints: endpoints) {
             return endpoints
index 3aab8a49eb2f4c381b8b8304f5df49323952fcd4..7ee0acc49f20b52a77ec3fabd153626721c50533 100644 (file)
@@ -36,7 +36,7 @@ class PacketTunnelSettingsGenerator {
         if let listenPort = tunnelConfiguration.interface.listenPort {
             wgSettings.append("listen_port=\(listenPort)\n")
         }
-        if tunnelConfiguration.peers.count > 0 {
+        if !tunnelConfiguration.peers.isEmpty {
             wgSettings.append("replace_peers=true\n")
         }
         assert(tunnelConfiguration.peers.count == resolvedEndpoints.count)