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:
parent
a22e872a8c
commit
d9bd0f3014
24 changed files with 90 additions and 272 deletions
|
|
@ -113,7 +113,7 @@ public class Password {
|
|||
|
||||
private func checkPasswordForOtpToken() {
|
||||
let (key, value) = Parser.getKeyValuePair(from: password)
|
||||
if let key = key, Constants.isOtpKeyword(key) {
|
||||
if let key, Constants.isOtpKeyword(key) {
|
||||
firstLineIsOTPField = true
|
||||
additions.append(key => value)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import SwiftyUserDefaults
|
|||
|
||||
public extension PasswordEntity {
|
||||
var nameWithCategory: String {
|
||||
if let path = path {
|
||||
if let path {
|
||||
if path.hasSuffix(".gpg") {
|
||||
return String(path.prefix(upTo: path.index(path.endIndex, offsetBy: -4)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ public class PasswordStore {
|
|||
}
|
||||
|
||||
private func checkoutAndChangeBranch(withName localBranchName: String, progressBlock: @escaping (String, UInt, UInt) -> Void) throws {
|
||||
guard let storeRepository = storeRepository else {
|
||||
guard let storeRepository else {
|
||||
throw AppError.repositoryNotSet
|
||||
}
|
||||
let remoteBranchName = "origin/\(localBranchName)"
|
||||
|
|
@ -218,7 +218,7 @@ public class PasswordStore {
|
|||
options: [String: Any],
|
||||
progressBlock: @escaping (UnsafePointer<git_transfer_progress>, UnsafeMutablePointer<ObjCBool>) -> Void = { _, _ in }
|
||||
) throws {
|
||||
guard let storeRepository = storeRepository else {
|
||||
guard let storeRepository else {
|
||||
throw AppError.repositoryNotSet
|
||||
}
|
||||
let remote = try GTRemote(name: "origin", in: storeRepository)
|
||||
|
|
@ -284,7 +284,7 @@ public class PasswordStore {
|
|||
}
|
||||
|
||||
public func getRecentCommits(count: Int) throws -> [GTCommit] {
|
||||
guard let storeRepository = storeRepository else {
|
||||
guard let storeRepository else {
|
||||
return []
|
||||
}
|
||||
var commits = [GTCommit]()
|
||||
|
|
@ -328,8 +328,7 @@ public class PasswordStore {
|
|||
let passwordEntityFetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "PasswordEntity")
|
||||
passwordEntityFetchRequest.predicate = NSPredicate(format: "synced = %i", 0)
|
||||
do {
|
||||
let passwordEntities = try context.fetch(passwordEntityFetchRequest) as! [PasswordEntity]
|
||||
return passwordEntities
|
||||
return try context.fetch(passwordEntityFetchRequest) as! [PasswordEntity]
|
||||
} catch {
|
||||
fatalError("FailedToFetchPasswords".localize(error))
|
||||
}
|
||||
|
|
@ -357,7 +356,7 @@ public class PasswordStore {
|
|||
}
|
||||
|
||||
public func getLatestUpdateInfo(filename: String) -> String {
|
||||
guard let storeRepository = storeRepository else {
|
||||
guard let storeRepository else {
|
||||
return "Unknown".localize()
|
||||
}
|
||||
guard let blameHunks = try? storeRepository.blame(withFile: filename, options: nil).hunks else {
|
||||
|
|
@ -374,7 +373,7 @@ public class PasswordStore {
|
|||
}
|
||||
|
||||
private func gitAdd(path: String) throws {
|
||||
guard let storeRepository = storeRepository else {
|
||||
guard let storeRepository else {
|
||||
throw AppError.repositoryNotSet
|
||||
}
|
||||
try storeRepository.index().addFile(path)
|
||||
|
|
@ -382,7 +381,7 @@ public class PasswordStore {
|
|||
}
|
||||
|
||||
private func gitRm(path: String) throws {
|
||||
guard let storeRepository = storeRepository else {
|
||||
guard let storeRepository else {
|
||||
throw AppError.repositoryNotSet
|
||||
}
|
||||
let url = storeURL.appendingPathComponent(path)
|
||||
|
|
@ -417,7 +416,7 @@ public class PasswordStore {
|
|||
}
|
||||
|
||||
private func gitCommit(message: String) throws -> GTCommit? {
|
||||
guard let storeRepository = storeRepository else {
|
||||
guard let storeRepository else {
|
||||
throw AppError.repositoryNotSet
|
||||
}
|
||||
let newTree = try storeRepository.index().writeTree()
|
||||
|
|
@ -428,12 +427,11 @@ public class PasswordStore {
|
|||
guard let signature = gitSignatureForNow else {
|
||||
throw AppError.gitCreateSignature
|
||||
}
|
||||
let commit = try storeRepository.createCommit(with: newTree, message: message, author: signature, committer: signature, parents: [parent], updatingReferenceNamed: headReference.name)
|
||||
return commit
|
||||
return try storeRepository.createCommit(with: newTree, message: message, author: signature, committer: signature, parents: [parent], updatingReferenceNamed: headReference.name)
|
||||
}
|
||||
|
||||
private func getLocalBranch(withName branchName: String) throws -> GTBranch? {
|
||||
guard let storeRepository = storeRepository else {
|
||||
guard let storeRepository else {
|
||||
throw AppError.repositoryNotSet
|
||||
}
|
||||
let reference = GTBranch.localNamePrefix().appending(branchName)
|
||||
|
|
@ -445,7 +443,7 @@ public class PasswordStore {
|
|||
options: [String: Any],
|
||||
transferProgressBlock: @escaping (UInt32, UInt32, Int, UnsafeMutablePointer<ObjCBool>) -> Void = { _, _, _, _ in }
|
||||
) throws {
|
||||
guard let storeRepository = storeRepository else {
|
||||
guard let storeRepository else {
|
||||
throw AppError.repositoryNotSet
|
||||
}
|
||||
if let branch = try getLocalBranch(withName: Defaults.gitBranchName) {
|
||||
|
|
@ -588,7 +586,7 @@ public class PasswordStore {
|
|||
}
|
||||
|
||||
public func updateImage(passwordEntity: PasswordEntity, image: Data?) {
|
||||
guard let image = image else {
|
||||
guard let image else {
|
||||
return
|
||||
}
|
||||
let privateMOC = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
|
||||
|
|
@ -638,7 +636,7 @@ public class PasswordStore {
|
|||
|
||||
// return the number of discarded commits
|
||||
public func reset() throws -> Int {
|
||||
guard let storeRepository = storeRepository else {
|
||||
guard let storeRepository else {
|
||||
throw AppError.repositoryNotSet
|
||||
}
|
||||
// get a list of local commits
|
||||
|
|
@ -662,7 +660,7 @@ public class PasswordStore {
|
|||
}
|
||||
|
||||
private func getLocalCommits() throws -> [GTCommit] {
|
||||
guard let storeRepository = storeRepository else {
|
||||
guard let storeRepository else {
|
||||
throw AppError.repositoryNotSet
|
||||
}
|
||||
// get the remote branch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue