Update SwiftLint and SwiftFormat (#613)

* Update Swift version used by SwiftFormat

* Update SwiftLint version

* Rely on new virtual 'all' rule in SwiftLint

* Enable SwiftLint rule 'direct_return' rule and fix all violations

* Enable SwiftLint rule 'shorthand_optional_binding' rule and fix all violations

* Enable SwiftLint rule 'blanket_disable_command' rule and fix all violations
This commit is contained in:
Danny Mösch 2023-04-23 22:01:37 +02:00 committed by GitHub
parent a22e872a8c
commit d9bd0f3014
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 90 additions and 272 deletions

View file

@ -20,10 +20,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
lazy var passcodeLockPresenter: PasscodeLockPresenter = {
let presenter = PasscodeLockPresenter(mainWindow: self.window)
return presenter
}()
lazy var passcodeLockPresenter: PasscodeLockPresenter = .init(mainWindow: self.window)
func application(_: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

View file

@ -13,10 +13,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
private static let VALUE_NOT_AVAILABLE = "ValueNotAvailable".localize()
private var needRefresh = false
private var indicator: UIActivityIndicatorView = {
let indicator = UIActivityIndicatorView(style: .medium)
return indicator
}()
private var indicator: UIActivityIndicatorView = .init(style: .medium)
private let passwordStore = PasswordStore.shared

View file

@ -80,7 +80,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
present(alert, animated: true, completion: nil)
} else if tableView.cellForRow(at: indexPath) == clearSuggestionsTableViewCell {
ASCredentialIdentityStore.shared.removeAllCredentialIdentities { _, error in
if let error = error {
if let error {
SVProgressHUD.showError(withStatus: "FailedToClearQuickTypeSuggestions".localize(error))
SVProgressHUD.dismiss(withDelay: 1)
} else {

View file

@ -83,10 +83,10 @@ extension PGPKeyFileImportTableViewController: PGPKeyImporter {
}
func importKeys() throws {
if let publicKey = publicKey {
if let publicKey {
try KeyFileManager.PublicPGP.importKey(from: publicKey)
}
if let privateKey = privateKey {
if let privateKey {
try KeyFileManager.PrivatePGP.importKey(from: privateKey)
}
}

View file

@ -43,12 +43,12 @@ extension PGPKeyURLImportTableViewController: PGPKeyImporter {
}
func importKeys() throws {
if let pgpPrivateKeyURL = pgpPrivateKeyURL {
if let pgpPrivateKeyURL {
Defaults.pgpPrivateKeyURL = pgpPrivateKeyURL
try KeyFileManager.PrivatePGP.importKey(from: pgpPrivateKeyURL)
}
if let pgpPublicKeyURL = pgpPublicKeyURL {
if let pgpPublicKeyURL {
Defaults.pgpPublicKeyURL = pgpPublicKeyURL
try KeyFileManager.PublicPGP.importKey(from: pgpPublicKeyURL)
}

View file

@ -30,10 +30,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
// preserve path so it can be reloaded even if the passwordEntity is deleted during the update process
private var passwordPath: String?
private lazy var editUIBarButtonItem: UIBarButtonItem = {
let uiBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit, target: self, action: #selector(pressEdit))
return uiBarButtonItem
}()
private lazy var editUIBarButtonItem: UIBarButtonItem = .init(barButtonSystemItem: .edit, target: self, action: #selector(pressEdit))
private struct TableSection {
var type: PasswordDetailTableViewControllerSectionType
@ -112,7 +109,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
}
private func decryptThenShowPasswordLocalKey(keyID: String? = nil) {
guard let passwordEntity = passwordEntity else {
guard let passwordEntity else {
Utils.alert(title: "CannotShowPassword".localize(), message: "PasswordDoesNotExist".localize(), controller: self, completion: {
self.navigationController!.popViewController(animated: true)
})
@ -259,7 +256,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
// main section
section = TableSection(type: .main)
let password = self.password!
let password = password!
if let username = password.username {
section.item.append(Constants.USERNAME_KEYWORD => username)
}
@ -607,7 +604,7 @@ extension PasswordDetailTableViewController {
}
private func decryptThenShowPasswordYubiKey() {
guard let passwordEntity = passwordEntity else {
guard let passwordEntity else {
handleError(error: AppError.other(message: "PasswordDoesNotExist"))
return
}

View file

@ -254,7 +254,7 @@ class PasswordNavigationViewController: UIViewController {
if gesture.state == UIGestureRecognizer.State.began {
let touchPoint = gesture.location(in: tableView)
if let indexPath = tableView.indexPathForRow(at: touchPoint) {
guard let dataSource = dataSource else {
guard let dataSource else {
return
}
let passwordTableEntry = dataSource.getPasswordTableEntry(at: indexPath)
@ -283,7 +283,7 @@ class PasswordNavigationViewController: UIViewController {
extension PasswordNavigationViewController: UITableViewDelegate {
func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
guard let dataSource = dataSource else {
guard let dataSource else {
return
}
let entry = dataSource.getPasswordTableEntry(at: indexPath)

View file

@ -75,7 +75,7 @@ class QRScannerController: UIViewController, AVCaptureMetadataOutputObjectsDeleg
// Initialize QR Code Frame to highlight the QR code
qrCodeFrameView = UIView()
if let qrCodeFrameView = qrCodeFrameView {
if let qrCodeFrameView {
qrCodeFrameView.layer.borderColor = UIColor.green.cgColor
qrCodeFrameView.layer.borderWidth = 2
view.addSubview(qrCodeFrameView)

View file

@ -70,7 +70,7 @@ extension SSHKeyFileImportTableViewController: KeyImporter {
}
func importKeys() throws {
guard let privateKey = privateKey else {
guard let privateKey else {
return
}
try KeyFileManager.PrivateSSH.importKey(from: privateKey)

View file

@ -241,7 +241,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
@objc
func alertTextFieldDidChange(_ sender: UITextField) {
// check whether we should enable the Save button in setPasscodeLockAlert
if let setPasscodeLockAlert = setPasscodeLockAlert,
if let setPasscodeLockAlert,
let setPasscodeLockAlertTextFields0 = setPasscodeLockAlert.textFields?[0],
let setPasscodeLockAlertTextFields1 = setPasscodeLockAlert.textFields?[1] {
if sender == setPasscodeLockAlertTextFields0 || sender == setPasscodeLockAlertTextFields1 {

View file

@ -15,7 +15,7 @@ class UICodeHighlightingLabel: UILocalizedLabel {
override func awakeFromNib() {
super.awakeFromNib()
guard let text = text else {
guard let text else {
return
}
attributedText = formatCode(in: text)