Keep SwiftLint rule 'discouraged_optional_collection' disabled

This commit is contained in:
Danny Moesch 2020-07-04 22:19:01 +02:00 committed by Mingshen Sun
parent 2e6cf69b03
commit 37bcbdeef2
2 changed files with 17 additions and 18 deletions

View file

@ -33,7 +33,7 @@ whitelist_rules:
- discouraged_direct_init
# - discouraged_object_literal
- discouraged_optional_boolean
# - discouraged_optional_collection
# - discouraged_optional_collection # Too many false positives in implementations of system protocols.
- duplicate_enum_cases
- duplicate_imports
- dynamic_inline

View file

@ -654,27 +654,26 @@ public class PasswordStore {
throw AppError.RepositoryNotSet
}
// get a list of local commits
if let localCommits = try getLocalCommits(),
!localCommits.isEmpty {
// get the oldest local commit
guard let firstLocalCommit = localCommits.last,
firstLocalCommit.parents.count == 1,
let newHead = firstLocalCommit.parents.first else {
throw AppError.GitReset
}
try storeRepository.reset(to: newHead, resetType: .hard)
setAllSynced()
updatePasswordEntityCoreData()
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
NotificationCenter.default.post(name: .passwordStoreChangeDiscarded, object: nil)
return localCommits.count
} else {
let localCommits = try getLocalCommits()
if localCommits.isEmpty {
return 0 // no new commit
}
// get the oldest local commit
guard let firstLocalCommit = localCommits.last,
firstLocalCommit.parents.count == 1,
let newHead = firstLocalCommit.parents.first else {
throw AppError.GitReset
}
try storeRepository.reset(to: newHead, resetType: .hard)
setAllSynced()
updatePasswordEntityCoreData()
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
NotificationCenter.default.post(name: .passwordStoreChangeDiscarded, object: nil)
return localCommits.count
}
private func getLocalCommits() throws -> [GTCommit]? {
private func getLocalCommits() throws -> [GTCommit] {
guard let storeRepository = storeRepository else {
throw AppError.RepositoryNotSet
}