From d7e85c1fdb31cb1e57bf30c603ca93af0410b065 Mon Sep 17 00:00:00 2001 From: Vansh Gandhi Date: Fri, 13 Oct 2023 15:46:26 -0700 Subject: [PATCH] Lints and fixes --- .github/workflows/sdk-primary.yml | 2 +- .../TextDetector/TextDetector.swift | 3 +++ .../Classes/Networking/Models/JobStatus.swift | 15 +++++++++++++-- .../Classes/Networking/SmileIDService.swift | 3 +-- .../SelfieCapture/View/SelfieCaptureView.swift | 2 +- Tests/Mocks/NetworkingMocks.swift | 2 +- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sdk-primary.yml b/.github/workflows/sdk-primary.yml index 9e05934b1..2cb853214 100644 --- a/.github/workflows/sdk-primary.yml +++ b/.github/workflows/sdk-primary.yml @@ -23,7 +23,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Danger - uses: docker://ghcr.io/danger/danger-swift-with-swiftlint:3.15.0 + uses: docker://ghcr.io/danger/danger-swift-with-swiftlint:3.17.1 with: args: --failOnErrors --no-publish-check env: diff --git a/Sources/SmileID/Classes/DocumentVerification/TextDetector/TextDetector.swift b/Sources/SmileID/Classes/DocumentVerification/TextDetector/TextDetector.swift index 0ee39b023..a92edd392 100644 --- a/Sources/SmileID/Classes/DocumentVerification/TextDetector/TextDetector.swift +++ b/Sources/SmileID/Classes/DocumentVerification/TextDetector/TextDetector.swift @@ -11,6 +11,9 @@ class TextDetector { onDetectionResult(false) return } + if let error = error { + print("Text Detection Error: \(error)") + } let recognisedString = observations.compactMap { $0.topCandidates(1).first?.string } diff --git a/Sources/SmileID/Classes/Networking/Models/JobStatus.swift b/Sources/SmileID/Classes/Networking/Models/JobStatus.swift index 4e7ce2d8d..903bfe935 100644 --- a/Sources/SmileID/Classes/Networking/Models/JobStatus.swift +++ b/Sources/SmileID/Classes/Networking/Models/JobStatus.swift @@ -26,7 +26,7 @@ public typealias DocumentVerificationJobStatusResponse = public typealias EnhancedDocumentVerificationJobStatusResponse = JobStatusResponse -public class JobStatusResponse: Codable { +public final class JobStatusResponse: Codable { public let timestamp: String public let jobComplete: Bool public let jobSuccess: Bool @@ -36,7 +36,18 @@ public class JobStatusResponse: Codable { public let history: [T]? public let imageLinks: ImageLinks? - required public init(from decoder: Decoder) throws { + internal init(jobComplete: Bool = true) { + self.jobComplete = jobComplete + timestamp = "" + jobSuccess = true + code = "0" + result = nil + resultString = nil + history = nil + imageLinks = nil + } + + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) timestamp = try container.decode(String.self, forKey: .timestamp) jobComplete = try container.decode(Bool.self, forKey: .jobComplete) diff --git a/Sources/SmileID/Classes/Networking/SmileIDService.swift b/Sources/SmileID/Classes/Networking/SmileIDService.swift index 58ab3653d..e3f647088 100644 --- a/Sources/SmileID/Classes/Networking/SmileIDService.swift +++ b/Sources/SmileID/Classes/Networking/SmileIDService.swift @@ -52,10 +52,9 @@ extension SmileIDServiceable { attemptCount += 1 return SmileID.api.getJobStatus(request: request) - .delay(for: .seconds(interval), scheduler: RunLoop.main) // swiftlint:disable force_cast .map { response in response as! JobStatusResponse } - // swiftlint:disable force_cast + // swiftlint:enable force_cast .flatMap { response -> AnyPublisher, Error> in if response.jobComplete { return Just(response).setFailureType(to: Error.self) diff --git a/Sources/SmileID/Classes/SelfieCapture/View/SelfieCaptureView.swift b/Sources/SmileID/Classes/SelfieCapture/View/SelfieCaptureView.swift index fc1199bdb..2416c1010 100644 --- a/Sources/SmileID/Classes/SelfieCapture/View/SelfieCaptureView.swift +++ b/Sources/SmileID/Classes/SelfieCapture/View/SelfieCaptureView.swift @@ -87,7 +87,7 @@ public struct SelfieCaptureView: View, SelfieViewDelegate { } } .overlay(ZStack { - if (showBackButton) { + if showBackButton { NavigationBar { viewModel.resetState() viewModel.pauseCameraSession() diff --git a/Tests/Mocks/NetworkingMocks.swift b/Tests/Mocks/NetworkingMocks.swift index b060c2f4e..edf34d8b6 100644 --- a/Tests/Mocks/NetworkingMocks.swift +++ b/Tests/Mocks/NetworkingMocks.swift @@ -110,7 +110,7 @@ class MockSmileIdentityService: SmileIDServiceable { func getJobStatus( request _: JobStatusRequest ) -> AnyPublisher, Error> { - let response = try! JobStatusResponse(from: JSONDecoder() as! Decoder) + let response = try! JobStatusResponse(jobComplete: MockHelper.jobComplete) if MockHelper.shouldFail { return Fail(error: SmileIDError.request(URLError(.resourceUnavailable))) .eraseToAnyPublisher()