Enable SwiftLint rule 'trailing_closure' and fix all violations

This commit is contained in:
Danny Moesch 2020-07-05 23:15:29 +02:00 committed by Mingshen Sun
parent 937019d6e8
commit 0317f5a83b
5 changed files with 6 additions and 6 deletions

View file

@ -163,7 +163,7 @@ whitelist_rules:
- syntactic_sugar - syntactic_sugar
- todo - todo
- toggle_bool - toggle_bool
# - trailing_closure - trailing_closure
# - trailing_comma # - trailing_comma
- trailing_newline - trailing_newline
- trailing_semicolon - trailing_semicolon

View file

@ -63,11 +63,11 @@ struct GopenPGPInterface: PGPInterface {
} }
func containsPublicKey(with keyID: String) -> Bool { func containsPublicKey(with keyID: String) -> Bool {
publicKeys.keys.contains(where: { key in key.hasSuffix(keyID.lowercased()) }) publicKeys.keys.contains { key in key.hasSuffix(keyID.lowercased()) }
} }
func containsPrivateKey(with keyID: String) -> Bool { func containsPrivateKey(with keyID: String) -> Bool {
privateKeys.keys.contains(where: { key in key.hasSuffix(keyID.lowercased()) }) privateKeys.keys.contains { key in key.hasSuffix(keyID.lowercased()) }
} }
func decrypt(encryptedData: Data, keyID: String, passphrase: String) throws -> Data? { func decrypt(encryptedData: Data, keyID: String, passphrase: String) throws -> Data? {

View file

@ -30,7 +30,7 @@ public enum AppError: Error, Equatable {
extension AppError: LocalizedError { extension AppError: LocalizedError {
public var errorDescription: String? { public var errorDescription: String? {
let localizationKey = "\(String(describing: self).prefix(while: { $0 != "(" }))Error." let localizationKey = "\(String(describing: self).prefix { $0 != "(" })Error."
switch self { 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) return localizationKey.localize(name)

View file

@ -130,7 +130,7 @@ public class Password {
private func getAdditionValue(withKey key: String, caseSensitive: Bool = false) -> String? { private func getAdditionValue(withKey key: String, caseSensitive: Bool = false) -> String? {
let toLowercase = { (string: String) -> String in caseSensitive ? string : string.lowercased() } let toLowercase = { (string: String) -> String in caseSensitive ? string : string.lowercased() }
return additions.first(where: { toLowercase($0.title) == toLowercase(key) })?.content return additions.first { toLowercase($0.title) == toLowercase(key) }?.content
} }
/// Set the OTP token if we are able to construct a valid one. /// Set the OTP token if we are able to construct a valid one.

View file

@ -70,7 +70,7 @@ class PasswordGeneratorTest: XCTestCase {
PasswordGenerator(flavor: .xkcd, length: 8, useSpecialSymbols: false), PasswordGenerator(flavor: .xkcd, length: 8, useSpecialSymbols: false),
PasswordGenerator(flavor: .xkcd, length: 1, useSpecialSymbols: false), PasswordGenerator(flavor: .xkcd, length: 1, useSpecialSymbols: false),
].forEach { generator in ].forEach { generator in
XCTAssertEqual(generator.generate().split(whereSeparator: { "0123456789".contains($0) }).count, generator.limitedLength) XCTAssertEqual(generator.generate().split { "0123456789".contains($0) }.count, generator.limitedLength)
} }
} }