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 --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 ### Number of spaces to indent, or "tab" to use tabs

View file

@ -36,7 +36,7 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {
} }
@IBAction @IBAction
private func cancel(_ sender: Any) { private func cancel(_: Any) {
navigationController?.popViewController(animated: true) 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 UITableView.automaticDimension
} }
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { override func tableView(_: UITableView, estimatedHeightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension 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 UITableView.automaticDimension
} }
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { override func tableView(_: UITableView, estimatedHeightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension UITableView.automaticDimension
} }

View file

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

View file

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

View file

@ -1,6 +1,6 @@
import UIKit
import passKit import passKit
import SVProgressHUD import SVProgressHUD
import UIKit
extension UIStoryboard { extension UIStoryboard {
static var passwordNavigationViewController: PasswordNavigationViewController { 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 UITableView.automaticDimension
} }
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { func tableView(_: UITableView, heightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension 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" { if identifier == "showPasswordDetail" {
guard PGPAgent.shared.isPrepared else { guard PGPAgent.shared.isPrepared else {
Utils.alert(title: "CannotShowPassword".localize(), message: "PgpKeyNotSet.".localize(), controller: self) Utils.alert(title: "CannotShowPassword".localize(), message: "PgpKeyNotSet.".localize(), controller: self)
@ -369,7 +369,7 @@ extension PasswordNavigationViewController: UISearchBarDelegate {
cancelSearch() cancelSearch()
} }
func searchBarTextDidEndEditing(_ searchBar: UISearchBar) { func searchBarTextDidEndEditing(_: UISearchBar) {
cancelSearch() cancelSearch()
} }

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@ import passKit
class CredentialProviderViewController: ASCredentialProviderViewController { class CredentialProviderViewController: ASCredentialProviderViewController {
var passcodelock: PasscodeExtensionDisplay { var passcodelock: PasscodeExtensionDisplay {
PasscodeExtensionDisplay(extensionContext: self.extensionContext) PasscodeExtensionDisplay(extensionContext: extensionContext)
} }
var embeddedNavigationController: UINavigationController { var embeddedNavigationController: UINavigationController {
@ -62,7 +62,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController {
@objc @objc
private func cancel(_: AnyObject?) { 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. // Copyright © 2020 Bob Sun. All rights reserved.
// //
import UIKit
import AuthenticationServices import AuthenticationServices
import passKit import passKit
import UIKit
class PasswordsViewController: UIViewController { class PasswordsViewController: UIViewController {
@IBOutlet var tableView: UITableView! @IBOutlet var tableView: UITableView!
@ -70,6 +70,6 @@ extension PasswordsViewController: UITableViewDelegate {
tableView.deselectRow(at: indexPath, animated: true) tableView.deselectRow(at: indexPath, animated: true)
let entry = dataSource.tableEntry(at: indexPath) let entry = dataSource.tableEntry(at: indexPath)
UIImpactFeedbackGenerator(style: .medium).impactOccurred() 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. // Copyright © 2020 Bob Sun. All rights reserved.
// //
import UIKit
import passKit import passKit
import UIKit
class PasswordsTableDataSource: NSObject, UITableViewDataSource { class PasswordsTableDataSource: NSObject, UITableViewDataSource {
var passwordTableEntries: [PasswordTableEntry] var passwordTableEntries: [PasswordTableEntry]
@ -18,13 +18,13 @@ class PasswordsTableDataSource: NSObject, UITableViewDataSource {
var showSuggestion: Bool = false var showSuggestion: Bool = false
init(entries: [PasswordTableEntry] = []) { init(entries: [PasswordTableEntry] = []) {
passwordTableEntries = entries self.passwordTableEntries = entries
filteredPasswordsTableEntries = passwordTableEntries self.filteredPasswordsTableEntries = passwordTableEntries
suggestedPasswordsTableEntries = [] self.suggestedPasswordsTableEntries = []
otherPasswordsTableEntries = [] self.otherPasswordsTableEntries = []
} }
func numberOfSections(in tableView: UITableView) -> Int { func numberOfSections(in _: UITableView) -> Int {
if !showSuggestion { if !showSuggestion {
return 1 return 1
} else { } 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 tableEntries(at: section).count
} }
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { func tableView(_: UITableView, titleForHeaderInSection section: Int) -> String? {
if suggestedPasswordsTableEntries.isEmpty { if suggestedPasswordsTableEntries.isEmpty {
return nil return nil
} }

View file

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

View file

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

View file

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