From 8f253cef6517b1f5e868be46fb679511f317d78a Mon Sep 17 00:00:00 2001 From: Nicklas Lundin Date: Tue, 16 Apr 2024 10:35:08 +0200 Subject: [PATCH] ci: run swiftlint with strict flag (#93) --- .github/workflows/ci.yaml | 2 +- .../xcschemes/Confidence-Package.xcscheme | 123 ------------------ .../xcschemes/Confidence.xcscheme | 66 ---------- .../xcschemes/ConfidenceProvider.xcscheme | 92 ------------- .../ConfidenceDemoTests.swift | 19 --- .../ConfidenceDemoUITests.swift | 31 ----- .../ConfidenceDemoUITestsLaunchTests.swift | 25 ---- Sources/Common/Backport.swift | 4 - .../ConfidenceFeatureProviderTest.swift | 1 + .../EventUploaderMock.swift | 6 +- .../FlagApplierWithRetriesTest.swift | 1 + .../RemoteConfidenceClientTests.swift | 3 +- 12 files changed, 9 insertions(+), 364 deletions(-) delete mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/Confidence-Package.xcscheme delete mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/Confidence.xcscheme delete mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/ConfidenceProvider.xcscheme delete mode 100644 ConfidenceDemoApp/ConfidenceDemoAppTests/ConfidenceDemoTests.swift delete mode 100644 ConfidenceDemoApp/ConfidenceDemoAppUITests/ConfidenceDemoUITests.swift delete mode 100644 ConfidenceDemoApp/ConfidenceDemoAppUITests/ConfidenceDemoUITestsLaunchTests.swift diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1cb5df83..ffb1f3dd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,4 +29,4 @@ jobs: - name: GitHub Action for SwiftLint uses: norio-nomura/action-swiftlint@3.2.1 with: - args: --config .swiftlint.yml + args: --strict --config .swiftlint.yml diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/Confidence-Package.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/Confidence-Package.xcscheme deleted file mode 100644 index 4f466f8b..00000000 --- a/.swiftpm/xcode/xcshareddata/xcschemes/Confidence-Package.xcscheme +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/Confidence.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/Confidence.xcscheme deleted file mode 100644 index 0e8ddb01..00000000 --- a/.swiftpm/xcode/xcshareddata/xcschemes/Confidence.xcscheme +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/ConfidenceProvider.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/ConfidenceProvider.xcscheme deleted file mode 100644 index 6eaaa02e..00000000 --- a/.swiftpm/xcode/xcshareddata/xcschemes/ConfidenceProvider.xcscheme +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ConfidenceDemoApp/ConfidenceDemoAppTests/ConfidenceDemoTests.swift b/ConfidenceDemoApp/ConfidenceDemoAppTests/ConfidenceDemoTests.swift deleted file mode 100644 index 3f155efe..00000000 --- a/ConfidenceDemoApp/ConfidenceDemoAppTests/ConfidenceDemoTests.swift +++ /dev/null @@ -1,19 +0,0 @@ -import XCTest -@testable import ConfidenceDemoApp - -final class ConfidenceDemoTests: XCTestCase { - func testExample() throws { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - // Any test you write for XCTest can be annotated as throws and async. - // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. - // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. - } - - func testPerformanceExample() throws { - // This is an example of a performance test case. - self.measure { - // Put the code you want to measure the time of here. - } - } -} diff --git a/ConfidenceDemoApp/ConfidenceDemoAppUITests/ConfidenceDemoUITests.swift b/ConfidenceDemoApp/ConfidenceDemoAppUITests/ConfidenceDemoUITests.swift deleted file mode 100644 index 59ec3be2..00000000 --- a/ConfidenceDemoApp/ConfidenceDemoAppUITests/ConfidenceDemoUITests.swift +++ /dev/null @@ -1,31 +0,0 @@ -import XCTest - -final class ConfidenceDemoUITests: XCTestCase { - override func setUpWithError() throws { - try super.setUpWithError() - - // Put setup code here. This method is called before the invocation of each test method in the class. - - // In UI tests it is usually best to stop immediately when a failure occurs. - continueAfterFailure = false - - // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. - } - - func testExample() throws { - // UI tests must launch the application that they test. - let app = XCUIApplication() - app.launch() - - // Use XCTAssert and related functions to verify your tests produce the correct results. - } - - func testLaunchPerformance() throws { - if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { - // This measures how long it takes to launch your application. - measure(metrics: [XCTApplicationLaunchMetric()]) { - XCUIApplication().launch() - } - } - } -} diff --git a/ConfidenceDemoApp/ConfidenceDemoAppUITests/ConfidenceDemoUITestsLaunchTests.swift b/ConfidenceDemoApp/ConfidenceDemoAppUITests/ConfidenceDemoUITestsLaunchTests.swift deleted file mode 100644 index d720bacc..00000000 --- a/ConfidenceDemoApp/ConfidenceDemoAppUITests/ConfidenceDemoUITestsLaunchTests.swift +++ /dev/null @@ -1,25 +0,0 @@ -import XCTest - -final class ConfidenceDemoUITestsLaunchTests: XCTestCase { - override class var runsForEachTargetApplicationUIConfiguration: Bool { - true - } - - override func setUpWithError() throws { - try super.setUpWithError() - continueAfterFailure = false - } - - func testLaunch() throws { - let app = XCUIApplication() - app.launch() - - // Insert steps here to perform after app launch but before taking a screenshot, - // such as logging into a test account or navigating somewhere in the app - - let attachment = XCTAttachment(screenshot: app.screenshot()) - attachment.name = "Launch Screen" - attachment.lifetime = .keepAlways - add(attachment) - } -} diff --git a/Sources/Common/Backport.swift b/Sources/Common/Backport.swift index 2b069b0c..9b44fa05 100644 --- a/Sources/Common/Backport.swift +++ b/Sources/Common/Backport.swift @@ -3,10 +3,6 @@ import Foundation extension URL { public struct Backport { var base: URL - - init(base: URL) { - self.base = base - } } public var backport: Backport { diff --git a/Tests/ConfidenceProviderTests/ConfidenceFeatureProviderTest.swift b/Tests/ConfidenceProviderTests/ConfidenceFeatureProviderTest.swift index 1b9bccca..1e04878b 100644 --- a/Tests/ConfidenceProviderTests/ConfidenceFeatureProviderTest.swift +++ b/Tests/ConfidenceProviderTests/ConfidenceFeatureProviderTest.swift @@ -976,3 +976,4 @@ final class DispatchQueueFakeSlow: DispatchQueueType { } } } +// swiftlint:enable type_body_length diff --git a/Tests/ConfidenceProviderTests/EventUploaderMock.swift b/Tests/ConfidenceProviderTests/EventUploaderMock.swift index 4f79cbbc..4e96bab9 100644 --- a/Tests/ConfidenceProviderTests/EventUploaderMock.swift +++ b/Tests/ConfidenceProviderTests/EventUploaderMock.swift @@ -34,8 +34,10 @@ final class EventStorageMock: EventStorage { } func eventsFrom(id: String) throws -> [ConfidenceEvent] { - // swiftlint:disable:next force_unwrapping - return batches[id]! + guard let events = batches[id] else { + fatalError("id \(id) not found in batches") + } + return events } func remove(id: String) throws { diff --git a/Tests/ConfidenceProviderTests/FlagApplierWithRetriesTest.swift b/Tests/ConfidenceProviderTests/FlagApplierWithRetriesTest.swift index a95c0b4c..30bac189 100644 --- a/Tests/ConfidenceProviderTests/FlagApplierWithRetriesTest.swift +++ b/Tests/ConfidenceProviderTests/FlagApplierWithRetriesTest.swift @@ -549,3 +549,4 @@ class FlagApplierWithRetriesTest: XCTestCase { } } } +// swiftlint:enable type_body_length diff --git a/Tests/ConfidenceTests/RemoteConfidenceClientTests.swift b/Tests/ConfidenceTests/RemoteConfidenceClientTests.swift index 9e7a89d3..dd448ba5 100644 --- a/Tests/ConfidenceTests/RemoteConfidenceClientTests.swift +++ b/Tests/ConfidenceTests/RemoteConfidenceClientTests.swift @@ -4,7 +4,6 @@ import XCTest @testable import Confidence -// swiftlint:enable:next force_cast class RemoteConfidenceClientTest: XCTestCase { override func setUp() { MockedClientURLProtocol.reset() @@ -75,6 +74,7 @@ class RemoteConfidenceClientTest: XCTestCase { ) ]) } catch { + // swiftlint:disable:next force_cast caughtError = error as! ConfidenceError? } let expectedError = ConfidenceError.badRequest(message: "explanation about malformed request") @@ -99,6 +99,7 @@ class RemoteConfidenceClientTest: XCTestCase { ) ]) } catch { + // swiftlint:disable:next force_cast caughtError = error as! ConfidenceError? } let expectedError = ConfidenceError.internalError(message: "invalidResponse")