Make code pass lint validation
This commit is contained in:
parent
e56f64daa3
commit
1ca3184fd8
|
@ -1,5 +1,8 @@
|
|||
disabled_rules:
|
||||
- function_body_length
|
||||
- identifier_name
|
||||
- line_length
|
||||
- todo
|
||||
- trailing_whitespace
|
||||
- type_name
|
||||
- vertical_whitespace
|
||||
|
|
|
@ -14,7 +14,7 @@ import Foundation
|
|||
*/
|
||||
public protocol AuthenticationService: AnyObject {
|
||||
|
||||
typealias AuthCompletion = (_ result: AuthResult) -> ()
|
||||
typealias AuthCompletion = (_ result: AuthResult) -> Void
|
||||
typealias AuthError = AuthenticationServiceError
|
||||
typealias AuthResult = Result<Void, Error>
|
||||
|
||||
|
|
|
@ -12,13 +12,19 @@ public class StandardCsvParser: CsvParser {
|
|||
|
||||
public init() {}
|
||||
|
||||
public func parseCvsString(_ string: String, separator: Character) -> [[String]] {
|
||||
public func parseCvsString(
|
||||
_ string: String,
|
||||
separator: Character) -> [[String]] {
|
||||
let allRows = string.components(separatedBy: .newlines)
|
||||
let rows = allRows.filter { $0.trimmingCharacters(in: .whitespaces).count > 0 }
|
||||
return rows.map { $0.split(separator: separator).map { String($0) } }
|
||||
}
|
||||
|
||||
public func parseCvsFile(named fileName: String, withExtension ext: String, in bundle: Bundle, separator: Character) throws -> [[String]] {
|
||||
public func parseCvsFile(
|
||||
named fileName: String,
|
||||
withExtension ext: String,
|
||||
in bundle: Bundle,
|
||||
separator: Character) throws -> [[String]] {
|
||||
let url = bundle.url(forResource: fileName, withExtension: ext)
|
||||
guard let fileUrl = url else { throw CsvParserError.noSuchFile(fileName, fileExtension: ext) }
|
||||
let data = try Data(contentsOf: fileUrl)
|
||||
|
|
|
@ -38,4 +38,3 @@ public extension Date {
|
|||
calendar.dateComponents([.second], from: date, to: self).second ?? 0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public extension JSONEncoder {
|
|||
|
||||
private extension JSONEncoder.DateEncodingStrategy {
|
||||
|
||||
static let customISO8601 = custom { (date, encoder) throws -> () in
|
||||
static let customISO8601 = custom { (date, encoder) throws -> Void in
|
||||
let formatter = DateFormatter.iso8601Milliseconds
|
||||
let string = formatter.string(from: date)
|
||||
var container = encoder.singleValueContainer()
|
||||
|
|
|
@ -33,7 +33,7 @@ private extension BundleFileFinder {
|
|||
let files = try fileManager.contentsOfDirectory(atPath: path)
|
||||
let array = files as NSArray
|
||||
let filteredFiles = array.filtered(using: predicate)
|
||||
return filteredFiles as! [String]
|
||||
return filteredFiles as? [String] ?? []
|
||||
} catch {
|
||||
return [String]()
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ import Foundation
|
|||
but as soon as you call `setLocale` the standard translator
|
||||
will replaced with a `BundleTranslator`, that will used the
|
||||
bundle of the new locale.
|
||||
|
||||
`TODO` Write unit tests with mocked types for this service.
|
||||
*/
|
||||
open class StandardLocalizationService: LocalizationService {
|
||||
|
||||
|
|
|
@ -103,7 +103,10 @@ private class TestClass: BiometricAuthenticationService, Mockable {
|
|||
invoke(canAuthenticateUserRef, args: (auth))
|
||||
}
|
||||
|
||||
override func performAuthentication(for auth: Authentication, reason: String, completion: @escaping BiometricAuthenticationService.AuthCompletion) {
|
||||
override func performAuthentication(
|
||||
for auth: Authentication,
|
||||
reason: String,
|
||||
completion: @escaping AuthCompletion) {
|
||||
invoke(performAuthenticationRef, args: (auth, reason, completion))
|
||||
if let error = authError { return completion(.failure(error)) }
|
||||
completion(.success(()))
|
||||
|
|
|
@ -84,21 +84,21 @@ class CachedAuthenticationServiceProxyTests: QuickSpec {
|
|||
|
||||
it("is false after a failed authentication") {
|
||||
mock.authError = TestError.failure
|
||||
service.authenticateUser(for: .standard, reason: "") { result in
|
||||
service.authenticateUser(for: .standard, reason: "") { _ in
|
||||
expect(service.isUserAuthenticated(for: .standard)).to(beFalse())
|
||||
asyncTrigger.trigger()
|
||||
}
|
||||
}
|
||||
|
||||
it("is true after a successful authentication") {
|
||||
service.authenticateUser(for: .standard, reason: "") { result in
|
||||
service.authenticateUser(for: .standard, reason: "") { _ in
|
||||
expect(service.isUserAuthenticated(for: .standard)).to(beTrue())
|
||||
asyncTrigger.trigger()
|
||||
}
|
||||
}
|
||||
|
||||
it("becomes false when authentication cache is reset") {
|
||||
service.authenticateUser(for: .standard, reason: "") { result in
|
||||
service.authenticateUser(for: .standard, reason: "") { _ in
|
||||
expect(service.isUserAuthenticated(for: .standard)).to(beTrue())
|
||||
service.resetUserAuthentication(for: .standard)
|
||||
expect(service.isUserAuthenticated(for: .standard)).to(beFalse())
|
||||
|
@ -111,8 +111,8 @@ class CachedAuthenticationServiceProxyTests: QuickSpec {
|
|||
|
||||
it("resets all state") {
|
||||
let auth = Authentication(id: "another-auth")
|
||||
service.authenticateUser(for: .standard, reason: "") { result in
|
||||
service.authenticateUser(for: auth, reason: "") { result in
|
||||
service.authenticateUser(for: .standard, reason: "") { _ in
|
||||
service.authenticateUser(for: auth, reason: "") { _ in
|
||||
expect(service.isUserAuthenticated(for: .standard)).to(beTrue())
|
||||
expect(service.isUserAuthenticated(for: auth)).to(beTrue())
|
||||
service.resetUserAuthentication()
|
||||
|
@ -129,8 +129,8 @@ class CachedAuthenticationServiceProxyTests: QuickSpec {
|
|||
|
||||
it("resets a single state") {
|
||||
let auth = Authentication(id: "another-auth")
|
||||
service.authenticateUser(for: .standard, reason: "") { result in
|
||||
service.authenticateUser(for: auth, reason: "") { result in
|
||||
service.authenticateUser(for: .standard, reason: "") { _ in
|
||||
service.authenticateUser(for: auth, reason: "") { _ in
|
||||
expect(service.isUserAuthenticated(for: .standard)).to(beTrue())
|
||||
expect(service.isUserAuthenticated(for: auth)).to(beTrue())
|
||||
service.resetUserAuthentication(for: .standard)
|
||||
|
|
|
@ -44,7 +44,9 @@ class Url_QueryParametersTests: QuickSpec {
|
|||
}
|
||||
|
||||
it("handles encoded query parameters") {
|
||||
let url = URL(string: "http://foo.bar/home?p1=me%20%26%20you&p2=%C3%A5%C3%A4%C3%B6%C3%85%C3%84%C3%96")!
|
||||
let url = URL(string: """
|
||||
http://foo.bar/home?p1=me%20%26%20you&p2=%C3%A5%C3%A4%C3%B6%C3%85%C3%84%C3%96
|
||||
""")!
|
||||
let result = url.queryParameters
|
||||
expect(result.count).to(equal(2))
|
||||
expect(result[0].name).to(equal("p1"))
|
||||
|
@ -78,7 +80,9 @@ class Url_QueryParametersTests: QuickSpec {
|
|||
}
|
||||
|
||||
it("handles encoded query parameters") {
|
||||
let url = URL(string: "http://foo.bar/home?p1=me%20%26%20you&p2=%C3%A5%C3%A4%C3%B6%C3%85%C3%84%C3%96")!
|
||||
let url = URL(string: """
|
||||
http://foo.bar/home?p1=me%20%26%20you&p2=%C3%A5%C3%A4%C3%B6%C3%85%C3%84%C3%96
|
||||
""")!
|
||||
let result = url.queryParametersDictionary
|
||||
expect(result.count).to(equal(2))
|
||||
expect(result["p1"]).to(equal("me & you"))
|
||||
|
|
|
@ -3,7 +3,7 @@ import XCTest
|
|||
#if !canImport(ObjectiveC)
|
||||
public func allTests() -> [XCTestCaseEntry] {
|
||||
return [
|
||||
testCase(SwiftKitTests.allTests),
|
||||
testCase(SwiftKitTests.allTests)
|
||||
]
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue