Remove redundant 'else' blocks
This commit is contained in:
parent
ad4ed9419e
commit
1454693308
9 changed files with 22 additions and 57 deletions
|
|
@ -228,9 +228,8 @@ class PasswordEditorTableViewController: UITableViewController {
|
|||
if section == passwordSection, hidePasswordSettings {
|
||||
// hide the password section, only the password should be shown
|
||||
return 1
|
||||
} else {
|
||||
return tableData[section].count
|
||||
}
|
||||
return tableData[section].count
|
||||
}
|
||||
|
||||
override func tableView(_: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||
|
|
|
|||
|
|
@ -102,9 +102,8 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
let gitURL = Defaults.gitURL
|
||||
if gitURL.scheme == nil {
|
||||
return URL(string: "scheme://" + gitURL.absoluteString)?.host
|
||||
} else {
|
||||
return gitURL.host
|
||||
}
|
||||
return gitURL.host
|
||||
}()
|
||||
passwordRepositoryTableViewCell.detailTextLabel?.text = host
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,17 +81,15 @@ class LabelTableViewCell: UITableViewCell {
|
|||
case .password:
|
||||
if isReveal {
|
||||
return action == #selector(copy(_:)) || action == #selector(concealPassword(_:))
|
||||
} else {
|
||||
return action == #selector(copy(_:)) || action == #selector(revealPassword(_:))
|
||||
}
|
||||
return action == #selector(copy(_:)) || action == #selector(revealPassword(_:))
|
||||
case .URL:
|
||||
return action == #selector(copy(_:)) || action == #selector(openLink(_:))
|
||||
case .HOTP:
|
||||
if isReveal {
|
||||
return action == #selector(copy(_:)) || action == #selector(concealPassword(_:)) || action == #selector(getNextHOTP(_:))
|
||||
} else {
|
||||
return action == #selector(copy(_:)) || action == #selector(revealPassword(_:)) || action == #selector(getNextHOTP(_:))
|
||||
}
|
||||
return action == #selector(copy(_:)) || action == #selector(revealPassword(_:)) || action == #selector(getNextHOTP(_:))
|
||||
default:
|
||||
return action == #selector(copy(_:))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,11 +25,7 @@ class PasswordsTableDataSource: NSObject, UITableViewDataSource {
|
|||
}
|
||||
|
||||
func numberOfSections(in _: UITableView) -> Int {
|
||||
if !showSuggestion {
|
||||
return 1
|
||||
} else {
|
||||
return 2
|
||||
}
|
||||
!showSuggestion ? 1 : 2
|
||||
}
|
||||
|
||||
func tableView(_: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
|
|
@ -40,16 +36,13 @@ class PasswordsTableDataSource: NSObject, UITableViewDataSource {
|
|||
if suggestedPasswordsTableEntries.isEmpty {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !showSuggestion {
|
||||
return "All Passwords"
|
||||
}
|
||||
|
||||
if section == 0 {
|
||||
return "Suggested Passwords"
|
||||
} else {
|
||||
return "Other Passwords"
|
||||
}
|
||||
return "Other Passwords"
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
|
|
@ -97,11 +90,9 @@ class PasswordsTableDataSource: NSObject, UITableViewDataSource {
|
|||
if showSuggestion {
|
||||
if section == 0 {
|
||||
return suggestedPasswordsTableEntries
|
||||
} else {
|
||||
return otherPasswordsTableEntries
|
||||
}
|
||||
} else {
|
||||
return filteredPasswordsTableEntries
|
||||
return otherPasswordsTableEntries
|
||||
}
|
||||
return filteredPasswordsTableEntries
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,15 +100,13 @@ extension NSDictionary {
|
|||
if let value = self[PassExtensionKey.URLStringKey] as? String {
|
||||
if let host = URL(string: value)?.host {
|
||||
return host
|
||||
} else {
|
||||
return value
|
||||
}
|
||||
return value
|
||||
} else if let value = self[NSExtensionJavaScriptPreprocessingResultsKey] as? String {
|
||||
if let host = URL(string: value)?.host {
|
||||
return host
|
||||
} else {
|
||||
return value
|
||||
}
|
||||
return value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,9 +74,8 @@ struct GopenPGPInterface: PGPInterface {
|
|||
let key: CryptoKey? = {
|
||||
if let keyID = keyID {
|
||||
return privateKeys.first(where: { key, _ in key.hasSuffix(keyID.lowercased()) })?.value
|
||||
} else {
|
||||
return privateKeys.first?.value
|
||||
}
|
||||
return privateKeys.first?.value
|
||||
}()
|
||||
|
||||
guard let privateKey = key else {
|
||||
|
|
@ -112,9 +111,8 @@ struct GopenPGPInterface: PGPInterface {
|
|||
let key: CryptoKey? = {
|
||||
if let keyID = keyID {
|
||||
return publicKeys.first(where: { key, _ in key.hasSuffix(keyID.lowercased()) })?.value
|
||||
} else {
|
||||
return publicKeys.first?.value
|
||||
}
|
||||
return publicKeys.first?.value
|
||||
}()
|
||||
|
||||
guard let publicKey = key else {
|
||||
|
|
|
|||
|
|
@ -13,32 +13,28 @@ extension UIView {
|
|||
var safeTopAnchor: NSLayoutYAxisAnchor {
|
||||
if #available(iOS 11.0, *) {
|
||||
return self.safeAreaLayoutGuide.topAnchor
|
||||
} else {
|
||||
return topAnchor
|
||||
}
|
||||
return topAnchor
|
||||
}
|
||||
|
||||
var safeLeftAnchor: NSLayoutXAxisAnchor {
|
||||
if #available(iOS 11.0, *) {
|
||||
return self.safeAreaLayoutGuide.leftAnchor
|
||||
} else {
|
||||
return leftAnchor
|
||||
}
|
||||
return leftAnchor
|
||||
}
|
||||
|
||||
var safeRightAnchor: NSLayoutXAxisAnchor {
|
||||
if #available(iOS 11.0, *) {
|
||||
return self.safeAreaLayoutGuide.rightAnchor
|
||||
} else {
|
||||
return rightAnchor
|
||||
}
|
||||
return rightAnchor
|
||||
}
|
||||
|
||||
var safeBottomAnchor: NSLayoutYAxisAnchor {
|
||||
if #available(iOS 11.0, *) {
|
||||
return self.safeAreaLayoutGuide.bottomAnchor
|
||||
} else {
|
||||
return bottomAnchor
|
||||
}
|
||||
return bottomAnchor
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,8 @@ public extension PasswordEntity {
|
|||
if let path = path {
|
||||
if path.hasSuffix(".gpg") {
|
||||
return String(path.prefix(upTo: path.index(path.endIndex, offsetBy: -4)))
|
||||
} else {
|
||||
return path
|
||||
}
|
||||
return path
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,12 +144,7 @@ public class PasswordStore {
|
|||
let passwordEntityFetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "PasswordEntity")
|
||||
do {
|
||||
passwordEntityFetchRequest.predicate = NSPredicate(format: "name = %@ and path = %@", password.name, password.url.path)
|
||||
let count = try context.count(for: passwordEntityFetchRequest)
|
||||
if count > 0 {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
return try context.count(for: passwordEntityFetchRequest) > 0
|
||||
} catch {
|
||||
fatalError("FailedToFetchPasswordEntities".localize(error))
|
||||
}
|
||||
|
|
@ -159,12 +154,7 @@ public class PasswordStore {
|
|||
let passwordEntityFetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "PasswordEntity")
|
||||
do {
|
||||
passwordEntityFetchRequest.predicate = NSPredicate(format: "path = %@", path)
|
||||
let count = try context.count(for: passwordEntityFetchRequest)
|
||||
if count > 0 {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
return try context.count(for: passwordEntityFetchRequest) > 0
|
||||
} catch {
|
||||
fatalError("FailedToFetchPasswordEntities".localize(error))
|
||||
}
|
||||
|
|
@ -704,9 +694,8 @@ public class PasswordStore {
|
|||
if Defaults.isEnableGPGIDOn {
|
||||
let keyID = keyID ?? findGPGID(from: encryptedDataPath)
|
||||
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
} else {
|
||||
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
}
|
||||
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
}()
|
||||
guard let decryptedData = data else {
|
||||
throw AppError.decryption
|
||||
|
|
@ -722,9 +711,8 @@ public class PasswordStore {
|
|||
}
|
||||
if Defaults.isEnableGPGIDOn {
|
||||
return try decrypt(passwordEntity: passwordEntity, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
} else {
|
||||
return try decrypt(passwordEntity: passwordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
}
|
||||
return try decrypt(passwordEntity: passwordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
}
|
||||
|
||||
public func encrypt(password: Password, keyID: String? = nil) throws -> Data {
|
||||
|
|
@ -732,9 +720,8 @@ public class PasswordStore {
|
|||
let keyID = keyID ?? findGPGID(from: encryptedDataPath)
|
||||
if Defaults.isEnableGPGIDOn {
|
||||
return try PGPAgent.shared.encrypt(plainData: password.plainData, keyID: keyID)
|
||||
} else {
|
||||
return try PGPAgent.shared.encrypt(plainData: password.plainData)
|
||||
}
|
||||
return try PGPAgent.shared.encrypt(plainData: password.plainData)
|
||||
}
|
||||
|
||||
public func removeGitSSHKeys() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue