Enable SwiftLint rule 'identifier_name' and handle all violations
This commit is contained in:
parent
7ada4dd96d
commit
e8389eb262
21 changed files with 157 additions and 156 deletions
|
|
@ -7,34 +7,35 @@
|
|||
//
|
||||
|
||||
public enum AppError: Error, Equatable {
|
||||
case RepositoryNotSet
|
||||
case RepositoryRemoteBranchNotFound(_: String)
|
||||
case RepositoryBranchNotFound(_: String)
|
||||
case KeyImport
|
||||
case ReadingFile(_: String)
|
||||
case PasswordDuplicated
|
||||
case GitReset
|
||||
case GitCreateSignature
|
||||
case GitPushNotSuccessful
|
||||
case PasswordEntity
|
||||
case PgpPublicKeyNotFound(keyID: String)
|
||||
case PgpPrivateKeyNotFound(keyID: String)
|
||||
case KeyExpiredOrIncompatible
|
||||
case WrongPassphrase
|
||||
case WrongPasswordFilename
|
||||
case Decryption
|
||||
case Encryption
|
||||
case Encoding
|
||||
case Unknown
|
||||
case repositoryNotSet
|
||||
case repositoryRemoteBranchNotFound(branchName: String)
|
||||
case repositoryBranchNotFound(branchName: String)
|
||||
case keyImport
|
||||
case readingFile(fileName: String)
|
||||
case passwordDuplicated
|
||||
case gitReset
|
||||
case gitCreateSignature
|
||||
case gitPushNotSuccessful
|
||||
case passwordEntity
|
||||
case pgpPublicKeyNotFound(keyID: String)
|
||||
case pgpPrivateKeyNotFound(keyID: String)
|
||||
case keyExpiredOrIncompatible
|
||||
case wrongPassphrase
|
||||
case wrongPasswordFilename
|
||||
case decryption
|
||||
case encryption
|
||||
case encoding
|
||||
case unknown
|
||||
}
|
||||
|
||||
extension AppError: LocalizedError {
|
||||
public var errorDescription: String? {
|
||||
let localizationKey = "\(String(describing: self).prefix { $0 != "(" })Error."
|
||||
let enumName = String(describing: self)
|
||||
let localizationKey = "\(enumName.first!.uppercased())\(enumName.dropFirst().prefix { $0 != "(" })Error."
|
||||
switch self {
|
||||
case let .RepositoryRemoteBranchNotFound(name), let .RepositoryBranchNotFound(name), let .ReadingFile(name):
|
||||
case let .repositoryRemoteBranchNotFound(name), let .repositoryBranchNotFound(name), let .readingFile(name):
|
||||
return localizationKey.localize(name)
|
||||
case let .PgpPublicKeyNotFound(keyID), let .PgpPrivateKeyNotFound(keyID):
|
||||
case let .pgpPublicKeyNotFound(keyID), let .pgpPrivateKeyNotFound(keyID):
|
||||
return localizationKey.localize(keyID)
|
||||
default:
|
||||
return localizationKey.localize()
|
||||
|
|
|
|||
|
|
@ -44,11 +44,9 @@ public class AppKeychain: KeyStore {
|
|||
}
|
||||
|
||||
public func removeAllContent(withPrefix prefix: String) {
|
||||
for k in keychain.allKeys() {
|
||||
if k.hasPrefix(prefix) {
|
||||
try? keychain.remove(k)
|
||||
}
|
||||
}
|
||||
keychain.allKeys()
|
||||
.filter { $0.hasPrefix(prefix) }
|
||||
.forEach { try? keychain.remove($0) }
|
||||
}
|
||||
|
||||
public static func getPGPKeyPassphraseKey(keyID: String) -> String {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class KeyFileManager {
|
|||
|
||||
public func importKey(from string: String) throws {
|
||||
guard string.unicodeScalars.allSatisfy({ $0.isASCII }) else {
|
||||
throw AppError.Encoding
|
||||
throw AppError.encoding
|
||||
}
|
||||
keyHandler(string, keyType.getKeychainKey())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue