From 7d6fab204bb60b327728345ccbfb12c4d18f3963 Mon Sep 17 00:00:00 2001 From: Maxwell Weru Date: Tue, 12 Mar 2024 08:44:41 +0300 Subject: [PATCH] Added codespell workflow which replaces misspell --- .codespellrc | 4 ++++ .github/workflows/codespell.yml | 21 +++++++++++++++++++ .github/workflows/misspell.yml | 20 ------------------ .../SharedKeyAuthenticationProvider.swift | 2 +- ...t+Extenstion.swift => Int+Extension.swift} | 8 +++---- .../Middleware/AppDetailsMiddleware.swift | 2 +- .../Middleware/LoggingMiddleware.swift | 2 +- Sources/TingleApiClient/MultipartBody.swift | 2 +- ...yTests.swift => Multipart BodyTests.swift} | 4 ++-- 9 files changed, 35 insertions(+), 30 deletions(-) create mode 100644 .codespellrc create mode 100644 .github/workflows/codespell.yml delete mode 100644 .github/workflows/misspell.yml rename Sources/TingleApiClient/Extensions/{Int+Extenstion.swift => Int+Extension.swift} (87%) rename Tests/TingleApiClientTests/{MultipartBodyTests.swift => Multipart BodyTests.swift} (81%) diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..ce1deb3 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,4 @@ +[codespell] +skip = .git +# some modules, parts of regexes, and variable names to ignore +ignore-words-list = inout diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 0000000..df18e8f --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,21 @@ +name: Codespell + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Codespell + uses: codespell-project/actions-codespell@v2 diff --git a/.github/workflows/misspell.yml b/.github/workflows/misspell.yml deleted file mode 100644 index 70a6f23..0000000 --- a/.github/workflows/misspell.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: misspell - -on: - workflow_dispatch: - schedule: - - cron: '0 0 * * *' - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: sobolevn/misspell-fixer-action@0.1.0 - - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: 'Fixes by misspell-fixer' - title: 'Typos fix by misspell-fixer' diff --git a/Sources/TingleApiClient/Authentication/SharedKeyAuthenticationProvider.swift b/Sources/TingleApiClient/Authentication/SharedKeyAuthenticationProvider.swift index 8968138..2d886d6 100644 --- a/Sources/TingleApiClient/Authentication/SharedKeyAuthenticationProvider.swift +++ b/Sources/TingleApiClient/Authentication/SharedKeyAuthenticationProvider.swift @@ -111,7 +111,7 @@ public final class SharedKeyAuthenticationProvider: AuthenticationHeaderProvider * - Parameter method: The HTTP request method * - Parameter contentLength: The value for the `Content-Length`header * - Parameter contentType: The value for the `Content-Type`header - * - Parameter date: The date alue used to make the request, set in the header with key specified by `dateHeaderName` + * - Parameter date: The date value used to make the request, set in the header with key specified by `dateHeaderName` * - Parameter resource: The resource that is being accessed */ private func sign(method: String, contentLength: Int64, contentType: String, date: String, resource: String) -> String? { diff --git a/Sources/TingleApiClient/Extensions/Int+Extenstion.swift b/Sources/TingleApiClient/Extensions/Int+Extension.swift similarity index 87% rename from Sources/TingleApiClient/Extensions/Int+Extenstion.swift rename to Sources/TingleApiClient/Extensions/Int+Extension.swift index 9e910a0..0526a51 100644 --- a/Sources/TingleApiClient/Extensions/Int+Extenstion.swift +++ b/Sources/TingleApiClient/Extensions/Int+Extension.swift @@ -1,5 +1,5 @@ // -// Int+Extenstion.swift +// Int+Extension.swift // // // Created by Maxwell Weru on 5/28/20. @@ -13,15 +13,15 @@ extension Int { func formatAbbreviated () -> String { let numFormatter = NumberFormatter() - typealias Abbrevation = (threshold:Double, divisor:Double, suffix:String) - let abbreviations:[Abbrevation] = [(0, 1, ""), + typealias Abbreviation = (threshold:Double, divisor:Double, suffix:String) + let abbreviations:[Abbreviation] = [(0, 1, ""), (1000.0, 1000.0, "K"), (100_000.0, 1_000_000.0, "M"), (100_000_000.0, 1_000_000_000.0, "B"), (100_000_000_000.0, 1_000_000_000_000.0, "T")] // you can add more ! let startValue = Double (abs(self)) - let abbreviation:Abbrevation = { + let abbreviation:Abbreviation = { var prevAbbreviation = abbreviations[0] for tmpAbbreviation in abbreviations { if (startValue < tmpAbbreviation.threshold) { diff --git a/Sources/TingleApiClient/Middleware/AppDetailsMiddleware.swift b/Sources/TingleApiClient/Middleware/AppDetailsMiddleware.swift index 0b5ec6d..9b8e255 100644 --- a/Sources/TingleApiClient/Middleware/AppDetailsMiddleware.swift +++ b/Sources/TingleApiClient/Middleware/AppDetailsMiddleware.swift @@ -18,7 +18,7 @@ public final class AppDetailsMiddleware: TingleApiClientMiddleware { private let appKind: String /** - * Intitialize and instance of `AppDetailsMiddleware` + * Initialize and instance of `AppDetailsMiddleware` * * - Parameter bundleId: The identifier of the application bundle * - Parameter shortBundleVersion: The short version of the application bundle diff --git a/Sources/TingleApiClient/Middleware/LoggingMiddleware.swift b/Sources/TingleApiClient/Middleware/LoggingMiddleware.swift index 0d23d2c..f066d50 100644 --- a/Sources/TingleApiClient/Middleware/LoggingMiddleware.swift +++ b/Sources/TingleApiClient/Middleware/LoggingMiddleware.swift @@ -24,7 +24,7 @@ public final class LoggingMiddleware: TingleApiClientMiddleware { * * - Parameter level: The level of data from a request/response to log. This defaults to `.NONE`. * - Parameter logLevel: The logging level to use when writing the logs to the output. This depends on the logging implementation in use. The default level is `.trace` - * - Parameter loggerLabel: The lable to use for use when logging. This is useful for filtering logs. When not provided, it defaults to the name of this class i.e.`String(describing: LoggingMiddleware.self)` + * - Parameter loggerLabel: The label to use for use when logging. This is useful for filtering logs. When not provided, it defaults to the name of this class i.e.`String(describing: LoggingMiddleware.self)` */ public init(_ level: Level = .NONE, _ logLevel: Logger.Level = Logger.Level.trace, loggerLabel: String = String(describing: LoggingMiddleware.self)) { self.logger = Logger(label: loggerLabel) diff --git a/Sources/TingleApiClient/MultipartBody.swift b/Sources/TingleApiClient/MultipartBody.swift index 2ed923c..f9c60ed 100644 --- a/Sources/TingleApiClient/MultipartBody.swift +++ b/Sources/TingleApiClient/MultipartBody.swift @@ -136,7 +136,7 @@ public class MultipartBody{ public func build() throws -> MultipartBody { - if parts.isEmpty{ fatalError("Mutlipart body must have at least one part")} + if parts.isEmpty{ fatalError("Multipart body must have at least one part")} return MultipartBody(boundary: boundary, type: type, parts: parts) } } diff --git a/Tests/TingleApiClientTests/MultipartBodyTests.swift b/Tests/TingleApiClientTests/Multipart BodyTests.swift similarity index 81% rename from Tests/TingleApiClientTests/MultipartBodyTests.swift rename to Tests/TingleApiClientTests/Multipart BodyTests.swift index bee74e7..5a13e7c 100644 --- a/Tests/TingleApiClientTests/MultipartBodyTests.swift +++ b/Tests/TingleApiClientTests/Multipart BodyTests.swift @@ -1,14 +1,14 @@ import XCTest @testable import TingleApiClient -class MutlipartBodyTests: XCTestCase{ +class MultipartBodyTests: XCTestCase{ func testSerializationOfFormData(){ let url = URL(string: "www.example.com")! var request = URLRequest(url: url) request.httpMethod = "POST" let body = try! MultipartBody.Builder(&request, type: .FORM) - .addFormDataPart(name: "Currecny", value:"USD") + .addFormDataPart(name: "Currency", value:"USD") .addFormDataPart(name: "Amount", value: "1234") .build()