Format code with SwiftFormat

This commit is contained in:
Danny Moesch 2021-01-31 13:17:37 +01:00 committed by Mingshen Sun
parent 4d6c77371d
commit ad4ed9419e
16 changed files with 49 additions and 49 deletions

View file

@ -156,9 +156,9 @@
--ifdef indent
### "testable-top", "testable-bottom" or "alphabetized" (default)
### "testable-first", "testable-last", "alpha" (default) or "length"
--importgrouping testable-bottom
--importgrouping testable-last
### Number of spaces to indent, or "tab" to use tabs

View file

@ -36,7 +36,7 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {
}
@IBAction
private func cancel(_ sender: Any) {
private func cancel(_: Any) {
navigationController?.popViewController(animated: true)
}

View file

@ -79,11 +79,11 @@ class AdvancedSettingsTableViewController: UITableViewController {
}
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
override func tableView(_: UITableView, heightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
override func tableView(_: UITableView, estimatedHeightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension
}

View file

@ -115,11 +115,11 @@ class BasicStaticTableViewController: UITableViewController, MFMailComposeViewCo
}
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
override func tableView(_: UITableView, heightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
override func tableView(_: UITableView, estimatedHeightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension
}

View file

@ -105,11 +105,11 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
tableView.deselectRow(at: indexPath, animated: true)
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
override func tableView(_: UITableView, heightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
override func tableView(_: UITableView, estimatedHeightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension
}

View file

@ -86,7 +86,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
}
@objc
private func decryptThenShowPasswordSelector(_ sender: Any) {
private func decryptThenShowPasswordSelector(_: Any) {
decryptThenShowPassword()
}

View file

@ -1,6 +1,6 @@
import UIKit
import passKit
import SVProgressHUD
import UIKit
extension UIStoryboard {
static var passwordNavigationViewController: PasswordNavigationViewController {
@ -258,11 +258,11 @@ extension PasswordNavigationViewController: UITableViewDelegate {
}
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
func tableView(_: UITableView, estimatedHeightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
func tableView(_: UITableView, heightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension
}
}
@ -282,7 +282,7 @@ extension PasswordNavigationViewController {
}
}
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
override func shouldPerformSegue(withIdentifier identifier: String, sender _: Any?) -> Bool {
if identifier == "showPasswordDetail" {
guard PGPAgent.shared.isPrepared else {
Utils.alert(title: "CannotShowPassword".localize(), message: "PgpKeyNotSet.".localize(), controller: self)
@ -369,7 +369,7 @@ extension PasswordNavigationViewController: UISearchBarDelegate {
cancelSearch()
}
func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
func searchBarTextDidEndEditing(_: UISearchBar) {
cancelSearch()
}

View file

@ -140,11 +140,11 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
tableView.deselectRow(at: indexPath, animated: true)
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
override func tableView(_: UITableView, heightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
override func tableView(_: UITableView, estimatedHeightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension
}

View file

@ -1,6 +1,6 @@
import UIKit
import passKit
import SVProgressHUD
import UIKit
class PasswordManager {
weak var viewController: UIViewController?

View file

@ -6,8 +6,8 @@
// Copyright © 2021 Bob Sun. All rights reserved.
//
import UIKit
import passKit
import UIKit
struct Section {
var title: String
@ -22,19 +22,19 @@ class PasswordNavigationDataSource: NSObject, UITableViewDataSource {
let hideSectionHeaderThreshold = 6
init(entries: [PasswordTableEntry] = []) {
sections = buildSections(from: entries)
filteredSections = sections
self.sections = buildSections(from: entries)
self.filteredSections = sections
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_: UITableView, numberOfRowsInSection section: Int) -> Int {
filteredSections[section].entries.count
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
func tableView(_: UITableView, titleForHeaderInSection section: Int) -> String? {
showSectionTitles() ? filteredSections[section].title : nil
}
func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {
func tableView(_: UITableView, sectionForSectionIndexTitle _: String, at index: Int) -> Int {
index
}
@ -45,7 +45,7 @@ class PasswordNavigationDataSource: NSObject, UITableViewDataSource {
return cell
}
func numberOfSections(in tableView: UITableView) -> Int {
func numberOfSections(in _: UITableView) -> Int {
filteredSections.count
}

View file

@ -11,7 +11,7 @@ import passKit
class CredentialProviderViewController: ASCredentialProviderViewController {
var passcodelock: PasscodeExtensionDisplay {
PasscodeExtensionDisplay(extensionContext: self.extensionContext)
PasscodeExtensionDisplay(extensionContext: extensionContext)
}
var embeddedNavigationController: UINavigationController {
@ -62,7 +62,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController {
@objc
private func cancel(_: AnyObject?) {
self.extensionContext.cancelRequest(withError: NSError(domain: "PassExtension", code: 0))
extensionContext.cancelRequest(withError: NSError(domain: "PassExtension", code: 0))
}
}

View file

@ -6,9 +6,9 @@
// Copyright © 2020 Bob Sun. All rights reserved.
//
import UIKit
import AuthenticationServices
import passKit
import UIKit
class PasswordsViewController: UIViewController {
@IBOutlet var tableView: UITableView!
@ -70,6 +70,6 @@ extension PasswordsViewController: UITableViewDelegate {
tableView.deselectRow(at: indexPath, animated: true)
let entry = dataSource.tableEntry(at: indexPath)
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
self.selectionDelegate?.selected(password: entry)
selectionDelegate?.selected(password: entry)
}
}

View file

@ -6,8 +6,8 @@
// Copyright © 2020 Bob Sun. All rights reserved.
//
import UIKit
import passKit
import UIKit
class PasswordsTableDataSource: NSObject, UITableViewDataSource {
var passwordTableEntries: [PasswordTableEntry]
@ -18,13 +18,13 @@ class PasswordsTableDataSource: NSObject, UITableViewDataSource {
var showSuggestion: Bool = false
init(entries: [PasswordTableEntry] = []) {
passwordTableEntries = entries
filteredPasswordsTableEntries = passwordTableEntries
suggestedPasswordsTableEntries = []
otherPasswordsTableEntries = []
self.passwordTableEntries = entries
self.filteredPasswordsTableEntries = passwordTableEntries
self.suggestedPasswordsTableEntries = []
self.otherPasswordsTableEntries = []
}
func numberOfSections(in tableView: UITableView) -> Int {
func numberOfSections(in _: UITableView) -> Int {
if !showSuggestion {
return 1
} else {
@ -32,11 +32,11 @@ class PasswordsTableDataSource: NSObject, UITableViewDataSource {
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_: UITableView, numberOfRowsInSection section: Int) -> Int {
tableEntries(at: section).count
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
func tableView(_: UITableView, titleForHeaderInSection section: Int) -> String? {
if suggestedPasswordsTableEntries.isEmpty {
return nil
}

View file

@ -12,7 +12,7 @@ import passKit
class ExtensionViewController: UIViewController {
var passcodelock: PasscodeExtensionDisplay {
PasscodeExtensionDisplay(extensionContext: self.extensionContext!)
PasscodeExtensionDisplay(extensionContext: extensionContext!)
}
var embeddedNavigationController: UINavigationController {
@ -49,11 +49,11 @@ class ExtensionViewController: UIViewController {
@objc
private func cancel(_: AnyObject?) {
self.extensionContext?.completeRequest(returningItems: nil)
extensionContext?.completeRequest(returningItems: nil)
}
func prepareCredentialList() {
guard let attachments = self.extensionContext?.attachments else {
guard let attachments = extensionContext?.attachments else {
return
}
@ -90,7 +90,7 @@ extension ExtensionViewController: PasswordSelectionDelegate {
case .fillBrowser:
credentialProvider.provideCredentialsBrowser(with: password.passwordEntity.getPath())
default:
self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
}
}
}
@ -141,7 +141,7 @@ extension NSExtensionContext {
extension NSItemProvider {
/// Extracts the URL from the item provider
func extractSearchText(completion: @escaping (String?) -> Void) {
self.loadItem(forTypeIdentifier: kUTTypeURL as String) { item, _ in
loadItem(forTypeIdentifier: kUTTypeURL as String) { item, _ in
if let url = item as? NSURL {
completion(url.host)
} else {
@ -149,7 +149,7 @@ extension NSItemProvider {
}
}
self.loadItem(forTypeIdentifier: kUTTypePropertyList as String) { item, _ in
loadItem(forTypeIdentifier: kUTTypePropertyList as String) { item, _ in
if let dict = item as? NSDictionary {
if let result = dict[NSExtensionJavaScriptPreprocessingResultsKey] as? NSDictionary {
completion(result.extractSearchText())
@ -157,7 +157,7 @@ extension NSItemProvider {
}
}
self.loadItem(forTypeIdentifier: PassExtensionActions.findLogin) { item, _ in
loadItem(forTypeIdentifier: PassExtensionActions.findLogin) { item, _ in
if let dict = item as? NSDictionary {
let text = dict.extractSearchText()
completion(text)

View file

@ -6,9 +6,9 @@
// Copyright © 2021 Bob Sun. All rights reserved.
//
import UIKit
import MobileCoreServices
import passKit
import UIKit
class CredentialProvider {
weak var extensionContext: NSExtensionContext?

View file

@ -98,8 +98,8 @@ public class PGPAgent {
public func decrypt(encryptedData: Data, requestPGPKeyPassphrase: (String) -> String) throws -> Data? {
// Remember the previous status and set the current status
let previousDecryptStatus = self.latestDecryptStatus
self.latestDecryptStatus = false
let previousDecryptStatus = latestDecryptStatus
latestDecryptStatus = false
// Init keys.
try checkAndInit()
// Get the PGP key passphrase.
@ -114,7 +114,7 @@ public class PGPAgent {
return nil
}
// The decryption step has succeed.
self.latestDecryptStatus = true
latestDecryptStatus = true
return result
}