Enable SwiftLint rule 'multiline_arguments_brackets' and fix all violations
This commit is contained in:
parent
b4c25726a5
commit
c87f4e9792
18 changed files with 286 additions and 220 deletions
|
|
@ -95,32 +95,34 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate {
|
|||
appIconView.layer.masksToBounds = true
|
||||
view?.addSubview(appIconView)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
passcodeTextField.widthAnchor.constraint(equalToConstant: 250),
|
||||
passcodeTextField.heightAnchor.constraint(equalToConstant: 40),
|
||||
passcodeTextField.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
passcodeTextField.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: -20),
|
||||
// above passocde
|
||||
appIconView.widthAnchor.constraint(equalToConstant: appIconSize),
|
||||
appIconView.heightAnchor.constraint(equalToConstant: appIconSize),
|
||||
appIconView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
appIconView.bottomAnchor.constraint(equalTo: passcodeTextField.topAnchor, constant: -appIconSize),
|
||||
// below passcode
|
||||
biometryAuthButton.widthAnchor.constraint(equalToConstant: 250),
|
||||
biometryAuthButton.heightAnchor.constraint(equalToConstant: 40),
|
||||
biometryAuthButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
biometryAuthButton.topAnchor.constraint(equalTo: passcodeTextField.bottomAnchor),
|
||||
// cancel (top-left of the screen)
|
||||
cancelButton.widthAnchor.constraint(equalToConstant: 150),
|
||||
cancelButton.heightAnchor.constraint(equalToConstant: 40),
|
||||
cancelButton.topAnchor.constraint(equalTo: view.safeTopAnchor),
|
||||
cancelButton.leftAnchor.constraint(equalTo: view.safeLeftAnchor, constant: 20),
|
||||
// bottom of the screen
|
||||
forgotPasscodeButton.widthAnchor.constraint(equalToConstant: 250),
|
||||
forgotPasscodeButton.heightAnchor.constraint(equalToConstant: 40),
|
||||
forgotPasscodeButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
forgotPasscodeButton.bottomAnchor.constraint(equalTo: view.safeBottomAnchor, constant: -40),
|
||||
])
|
||||
NSLayoutConstraint.activate(
|
||||
[
|
||||
passcodeTextField.widthAnchor.constraint(equalToConstant: 250),
|
||||
passcodeTextField.heightAnchor.constraint(equalToConstant: 40),
|
||||
passcodeTextField.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
passcodeTextField.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: -20),
|
||||
// above passocde
|
||||
appIconView.widthAnchor.constraint(equalToConstant: appIconSize),
|
||||
appIconView.heightAnchor.constraint(equalToConstant: appIconSize),
|
||||
appIconView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
appIconView.bottomAnchor.constraint(equalTo: passcodeTextField.topAnchor, constant: -appIconSize),
|
||||
// below passcode
|
||||
biometryAuthButton.widthAnchor.constraint(equalToConstant: 250),
|
||||
biometryAuthButton.heightAnchor.constraint(equalToConstant: 40),
|
||||
biometryAuthButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
biometryAuthButton.topAnchor.constraint(equalTo: passcodeTextField.bottomAnchor),
|
||||
// cancel (top-left of the screen)
|
||||
cancelButton.widthAnchor.constraint(equalToConstant: 150),
|
||||
cancelButton.heightAnchor.constraint(equalToConstant: 40),
|
||||
cancelButton.topAnchor.constraint(equalTo: view.safeTopAnchor),
|
||||
cancelButton.leftAnchor.constraint(equalTo: view.safeLeftAnchor, constant: 20),
|
||||
// bottom of the screen
|
||||
forgotPasscodeButton.widthAnchor.constraint(equalToConstant: 250),
|
||||
forgotPasscodeButton.heightAnchor.constraint(equalToConstant: 40),
|
||||
forgotPasscodeButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
forgotPasscodeButton.bottomAnchor.constraint(equalTo: view.safeBottomAnchor, constant: -40),
|
||||
]
|
||||
)
|
||||
|
||||
// dismiss keyboard when tapping anywhere
|
||||
let tap = UITapGestureRecognizer(target: view, action: #selector(UIView.endEditing))
|
||||
|
|
@ -147,10 +149,10 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate {
|
|||
// pop
|
||||
if presentingViewController?.presentedViewController == self {
|
||||
// if presented as modal
|
||||
dismiss(animated: true, completion: { [weak self] in
|
||||
dismiss(animated: true) { [weak self] in
|
||||
self?.dismissCompletionCallback?()
|
||||
completionHandler?()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// if pushed in a navigation controller
|
||||
_ = navigationController?.popViewController(animated: true)
|
||||
|
|
@ -190,30 +192,32 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate {
|
|||
@objc
|
||||
func forgotPasscodeButtonPressedAction(_: UIButton) {
|
||||
let alert = UIAlertController(title: "ResetPass".localize(), message: "ResetPassExplanation.".localize(), preferredStyle: UIAlertController.Style.alert)
|
||||
alert.addAction(UIAlertAction(title: "ErasePasswordStoreData".localize(), style: UIAlertAction.Style.destructive, handler: { [unowned self] (_) -> Void in
|
||||
let myContext = LAContext()
|
||||
var error: NSError?
|
||||
// If the device passcode is not set, reset the app.
|
||||
guard myContext.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) else {
|
||||
self.passwordStore.erase()
|
||||
self.passcodeLockDidSucceed()
|
||||
return
|
||||
}
|
||||
// If the device passcode is set, authentication is required.
|
||||
myContext.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "ErasePasswordStoreData".localize()) { success, error in
|
||||
if success {
|
||||
DispatchQueue.main.async {
|
||||
// User authenticated successfully, take appropriate action
|
||||
self.passwordStore.erase()
|
||||
self.passcodeLockDidSucceed()
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
Utils.alert(title: "Error".localize(), message: error?.localizedDescription ?? "", controller: self, completion: nil)
|
||||
alert.addAction(
|
||||
UIAlertAction(title: "ErasePasswordStoreData".localize(), style: UIAlertAction.Style.destructive) { [unowned self] (_) -> Void in
|
||||
let myContext = LAContext()
|
||||
var error: NSError?
|
||||
// If the device passcode is not set, reset the app.
|
||||
guard myContext.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) else {
|
||||
self.passwordStore.erase()
|
||||
self.passcodeLockDidSucceed()
|
||||
return
|
||||
}
|
||||
// If the device passcode is set, authentication is required.
|
||||
myContext.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "ErasePasswordStoreData".localize()) { success, error in
|
||||
if success {
|
||||
DispatchQueue.main.async {
|
||||
// User authenticated successfully, take appropriate action
|
||||
self.passwordStore.erase()
|
||||
self.passcodeLockDidSucceed()
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
Utils.alert(title: "Error".localize(), message: error?.localizedDescription ?? "", controller: self, completion: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
)
|
||||
alert.addAction(UIAlertAction.dismiss())
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,10 +37,12 @@ public extension FileManager {
|
|||
}
|
||||
|
||||
// We have to enumerate all directory contents, including subdirectories.
|
||||
let enumerator = self.enumerator(at: directoryURL,
|
||||
includingPropertiesForKeys: prefetchedProperties,
|
||||
options: FileManager.DirectoryEnumerationOptions(),
|
||||
errorHandler: errorHandler)
|
||||
let enumerator = self.enumerator(
|
||||
at: directoryURL,
|
||||
includingPropertiesForKeys: prefetchedProperties,
|
||||
options: FileManager.DirectoryEnumerationOptions(),
|
||||
errorHandler: errorHandler
|
||||
)
|
||||
precondition(enumerator != nil)
|
||||
|
||||
// Start the traversal:
|
||||
|
|
|
|||
|
|
@ -46,10 +46,12 @@ public enum Utils {
|
|||
let title = "Passphrase".localize() + " (\(keyID.suffix(8)))"
|
||||
let message = "FillInPgpPassphrase.".localize()
|
||||
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction.ok { _ in
|
||||
passphrase = alert.textFields?.first?.text ?? ""
|
||||
sem.signal()
|
||||
})
|
||||
alert.addAction(
|
||||
UIAlertAction.ok { _ in
|
||||
passphrase = alert.textFields?.first?.text ?? ""
|
||||
sem.signal()
|
||||
}
|
||||
)
|
||||
alert.addTextField { textField in
|
||||
textField.text = AppKeychain.shared.get(for: AppKeychain.getPGPKeyPassphraseKey(keyID: keyID)) ?? ""
|
||||
textField.isSecureTextEntry = true
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class PasswordStore {
|
|||
try! FileManager.default.createDirectory(atPath: Globals.documentPath, withIntermediateDirectories: true, attributes: nil)
|
||||
}
|
||||
container.persistentStoreDescriptions = [NSPersistentStoreDescription(url: URL(fileURLWithPath: Globals.dbPath))]
|
||||
container.loadPersistentStores(completionHandler: { _, error in
|
||||
container.loadPersistentStores { _, error in
|
||||
if let error = error as NSError? {
|
||||
// Replace this implementation with code to handle the error appropriately.
|
||||
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
|
||||
|
|
@ -77,7 +77,7 @@ public class PasswordStore {
|
|||
*/
|
||||
fatalError("UnresolvedError".localize("\(error.localizedDescription), \(error.userInfo)"))
|
||||
}
|
||||
})
|
||||
}
|
||||
return container.viewContext
|
||||
}()
|
||||
|
||||
|
|
@ -198,10 +198,12 @@ public class PasswordStore {
|
|||
gitPassword = nil
|
||||
gitSSHPrivateKeyPassphrase = nil
|
||||
do {
|
||||
storeRepository = try GTRepository.clone(from: remoteRepoURL,
|
||||
toWorkingDirectory: tempStoreURL,
|
||||
options: options,
|
||||
transferProgressBlock: transferProgressBlock)
|
||||
storeRepository = try GTRepository.clone(
|
||||
from: remoteRepoURL,
|
||||
toWorkingDirectory: tempStoreURL,
|
||||
options: options,
|
||||
transferProgressBlock: transferProgressBlock
|
||||
)
|
||||
try fm.moveItem(at: tempStoreURL, to: storeURL)
|
||||
storeRepository = try GTRepository(url: storeURL)
|
||||
if (try storeRepository?.currentBranch().name) != branchName {
|
||||
|
|
@ -375,10 +377,10 @@ public class PasswordStore {
|
|||
guard let storeRepository = storeRepository else {
|
||||
return "Unknown".localize()
|
||||
}
|
||||
guard let blameHunks = try? storeRepository.blame(withFile: filename, options: nil).hunks,
|
||||
let latestCommitTime = blameHunks.map({
|
||||
$0.finalSignature?.time?.timeIntervalSince1970 ?? 0
|
||||
}).max() else {
|
||||
guard let blameHunks = try? storeRepository.blame(withFile: filename, options: nil).hunks else {
|
||||
return "Unknown".localize()
|
||||
}
|
||||
guard let latestCommitTime = blameHunks.map({ $0.finalSignature?.time?.timeIntervalSince1970 ?? 0 }).max() else {
|
||||
return "Unknown".localize()
|
||||
}
|
||||
let lastCommitDate = Date(timeIntervalSince1970: latestCommitTime)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue