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_direct_init
# - discouraged_object_literal # - discouraged_object_literal
- discouraged_optional_boolean - discouraged_optional_boolean
# - discouraged_optional_collection # - discouraged_optional_collection # Too many false positives in implementations of system protocols.
- duplicate_enum_cases - duplicate_enum_cases
- duplicate_imports - duplicate_imports
- dynamic_inline - dynamic_inline

View file

@ -654,8 +654,10 @@ public class PasswordStore {
throw AppError.RepositoryNotSet throw AppError.RepositoryNotSet
} }
// get a list of local commits // get a list of local commits
if let localCommits = try getLocalCommits(), let localCommits = try getLocalCommits()
!localCommits.isEmpty { if localCommits.isEmpty {
return 0 // no new commit
}
// get the oldest local commit // get the oldest local commit
guard let firstLocalCommit = localCommits.last, guard let firstLocalCommit = localCommits.last,
firstLocalCommit.parents.count == 1, firstLocalCommit.parents.count == 1,
@ -669,12 +671,9 @@ public class PasswordStore {
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil) NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
NotificationCenter.default.post(name: .passwordStoreChangeDiscarded, object: nil) NotificationCenter.default.post(name: .passwordStoreChangeDiscarded, object: nil)
return localCommits.count return localCommits.count
} else {
return 0 // no new commit
}
} }
private func getLocalCommits() throws -> [GTCommit]? { private func getLocalCommits() throws -> [GTCommit] {
guard let storeRepository = storeRepository else { guard let storeRepository = storeRepository else {
throw AppError.RepositoryNotSet throw AppError.RepositoryNotSet
} }