Enabled more swiftlint rules

This commit is contained in:
Eric Kuck 2018-12-20 11:22:37 -06:00
parent cba41de73a
commit 9c7f27f19f
11 changed files with 22 additions and 13 deletions

View 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

View File

@ -8,6 +8,7 @@ public class Logger {
enum LoggerError: Error {
case openFailure
}
static var global: Logger?
var log: OpaquePointer

View 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: "=") {

View 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:

View 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

View 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)
}

View 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

View 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)

View File

@ -3,5 +3,6 @@
protocol WireGuardAppError: Error {
typealias AlertText = (title: String, message: String)
var alertText: AlertText { get }
}

View 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

View 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)