Enabled more swiftlint rules

Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
This commit is contained in:
Eric Kuck 2018-12-20 11:22:37 -06:00
parent 5618c465a2
commit a89ad95901
11 changed files with 22 additions and 13 deletions

View File

@ -3,7 +3,17 @@ disabled_rules:
- trailing_whitespace - trailing_whitespace
- todo - todo
opt_in_rules: 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 - unneeded_parentheses_in_closure_argument
- unused_import
# - trailing_closure # - trailing_closure
file_length: file_length:
warning: 500 warning: 500

View File

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

View File

@ -42,7 +42,7 @@ class WgQuickConfigFileParser {
trimmedLine = trimmedLine.trimmingCharacters(in: .whitespaces) trimmedLine = trimmedLine.trimmingCharacters(in: .whitespaces)
guard trimmedLine.count > 0 else { continue } guard !trimmedLine.isEmpty else { continue }
let lowercasedLine = line.lowercased() let lowercasedLine = line.lowercased()
if let equalsIndex = line.firstIndex(of: "=") { if let equalsIndex = line.firstIndex(of: "=") {

View File

@ -52,6 +52,7 @@ enum TunnelsManagerActivationAttemptError: WireGuardAppError {
enum TunnelsManagerActivationError: WireGuardAppError { enum TunnelsManagerActivationError: WireGuardAppError {
case activationFailed case activationFailed
case activationFailedWithExtensionError(title: String, message: String) case activationFailedWithExtensionError(title: String, message: String)
var alertText: AlertText { var alertText: AlertText {
switch self { switch self {
case .activationFailed: case .activationFailed:

View File

@ -361,7 +361,7 @@ class TunnelViewModel {
var peersData: [PeerData] var peersData: [PeerData]
init(tunnelConfiguration: TunnelConfiguration?) { init(tunnelConfiguration: TunnelConfiguration?) {
let interfaceData: InterfaceData = InterfaceData() let interfaceData = InterfaceData()
var peersData = [PeerData]() var peersData = [PeerData]()
if let tunnelConfiguration = tunnelConfiguration { if let tunnelConfiguration = tunnelConfiguration {
interfaceData.validatedConfiguration = tunnelConfiguration.interface interfaceData.validatedConfiguration = tunnelConfiguration.interface

View File

@ -33,7 +33,7 @@ class ButtonCell: UITableViewCell {
button.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor), button.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
contentView.layoutMarginsGuide.bottomAnchor.constraint(equalTo: button.bottomAnchor), contentView.layoutMarginsGuide.bottomAnchor.constraint(equalTo: button.bottomAnchor),
button.centerXAnchor.constraint(equalTo: contentView.centerXAnchor) button.centerXAnchor.constraint(equalTo: contentView.centerXAnchor)
]) ])
button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside) button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
} }

View File

@ -76,15 +76,11 @@ class QRScanViewController: UIViewController {
super.viewDidLayoutSubviews() super.viewDidLayoutSubviews()
if let connection = previewLayer?.connection { if let connection = previewLayer?.connection {
let currentDevice = UIDevice.current
let currentDevice: UIDevice = UIDevice.current let orientation = currentDevice.orientation
let previewLayerConnection = connection
let orientation: UIDeviceOrientation = currentDevice.orientation
let previewLayerConnection: AVCaptureConnection = connection
if previewLayerConnection.isVideoOrientationSupported { if previewLayerConnection.isVideoOrientationSupported {
switch orientation { switch orientation {
case .portrait: case .portrait:
previewLayerConnection.videoOrientation = .portrait previewLayerConnection.videoOrientation = .portrait

View File

@ -127,7 +127,7 @@ class TunnelsListTableViewController: UIViewController {
present(alert, animated: true, completion: nil) present(alert, animated: true, completion: nil)
} }
@objc func settingsButtonTapped(sender: UIBarButtonItem!) { @objc func settingsButtonTapped(sender: UIBarButtonItem) {
guard tunnelsManager != nil else { return } guard tunnelsManager != nil else { return }
let settingsVC = SettingsTableViewController(tunnelsManager: tunnelsManager) let settingsVC = SettingsTableViewController(tunnelsManager: tunnelsManager)

View File

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

View File

@ -21,7 +21,7 @@ class DNSResolver {
} }
static func resolveSync(endpoints: [Endpoint?]) throws -> [Endpoint?] { static func resolveSync(endpoints: [Endpoint?]) throws -> [Endpoint?] {
let dispatchGroup: DispatchGroup = DispatchGroup() let dispatchGroup = DispatchGroup()
if isAllEndpointsAlreadyResolved(endpoints: endpoints) { if isAllEndpointsAlreadyResolved(endpoints: endpoints) {
return endpoints return endpoints

View File

@ -36,7 +36,7 @@ class PacketTunnelSettingsGenerator {
if let listenPort = tunnelConfiguration.interface.listenPort { if let listenPort = tunnelConfiguration.interface.listenPort {
wgSettings.append("listen_port=\(listenPort)\n") wgSettings.append("listen_port=\(listenPort)\n")
} }
if tunnelConfiguration.peers.count > 0 { if !tunnelConfiguration.peers.isEmpty {
wgSettings.append("replace_peers=true\n") wgSettings.append("replace_peers=true\n")
} }
assert(tunnelConfiguration.peers.count == resolvedEndpoints.count) assert(tunnelConfiguration.peers.count == resolvedEndpoints.count)