diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 41aa8c8..91389a1 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -10,9 +10,12 @@ jobs: with: xcode-version: '16.4' - uses: actions/checkout@v3 - - name: Install SwiftLint + - name: Install SwiftLint and SwiftFormat run: | - brew install swiftlint + brew install swiftlint swiftformat + - name: SwiftFormat Lint + run: | + swiftformat --lint NativeAppTemplate # Commented out due to an error. # - name: Unit Tests # run: | diff --git a/CLAUDE.md b/CLAUDE.md index 6604637..5d98dd0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -42,6 +42,9 @@ swiftlint swiftlint --strict ``` +### Linting and Formatting +Always run `make lint` before pushing to verify SwiftLint and SwiftFormat checks pass (matches CI). Use `make format` to auto-fix SwiftFormat issues. + ### Formatting ```bash # Run SwiftFormat (must be installed via: brew install swiftformat) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1502ad0 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +.PHONY: lint format + +lint: + swiftlint lint --strict NativeAppTemplate + swiftformat --lint NativeAppTemplate + +format: + swiftformat NativeAppTemplate diff --git a/NativeAppTemplate/Constants.swift b/NativeAppTemplate/Constants.swift index df8461f..9bf19a0 100644 --- a/NativeAppTemplate/Constants.swift +++ b/NativeAppTemplate/Constants.swift @@ -3,8 +3,8 @@ // NativeAppTemplate // -import SwiftUI import typealias Foundation.TimeInterval +import SwiftUI extension Int { static let minimumPasswordLength: Int = 8 diff --git a/NativeAppTemplate/Logging/Logger.swift b/NativeAppTemplate/Logging/Logger.swift index 4f2c636..fede01f 100644 --- a/NativeAppTemplate/Logging/Logger.swift +++ b/NativeAppTemplate/Logging/Logger.swift @@ -69,9 +69,9 @@ struct Failure { func log() { appLogger.error( """ - \(self.action, privacy: .public) \ - source=\(self.source, privacy: .public) \ - reason=\(self.reason, privacy: .private) + \(action, privacy: .public) \ + source=\(source, privacy: .public) \ + reason=\(reason, privacy: .private) """ ) } @@ -99,6 +99,6 @@ struct Event { private let action: String func log() { - appLogger.info("EVENT:: source: \(self.source, privacy: .public), action: \(self.action, privacy: .public)") + appLogger.info("EVENT:: source: \(source, privacy: .public), action: \(action, privacy: .public)") } } diff --git a/NativeAppTemplate/Models/ItemTag.swift b/NativeAppTemplate/Models/ItemTag.swift index 8a9895e..1e197c2 100644 --- a/NativeAppTemplate/Models/ItemTag.swift +++ b/NativeAppTemplate/Models/ItemTag.swift @@ -5,7 +5,7 @@ import Foundation -struct ItemTag: Codable, Hashable, Identifiable, Sendable { +struct ItemTag: Codable, Hashable, Identifiable { var id: String = "" var shopId: String = "" var queueNumber: String = "" diff --git a/NativeAppTemplate/Models/Shop.swift b/NativeAppTemplate/Models/Shop.swift index b6b4463..d5d0df0 100644 --- a/NativeAppTemplate/Models/Shop.swift +++ b/NativeAppTemplate/Models/Shop.swift @@ -5,7 +5,7 @@ import Foundation -struct Shop: Codable, Identifiable, Sendable { +struct Shop: Codable, Identifiable { var id: String var name: String var description: String diff --git a/NativeAppTemplate/Networking/Network/CertificatePinningDelegate.swift b/NativeAppTemplate/Networking/Network/CertificatePinningDelegate.swift index ac18604..1cbe7ec 100644 --- a/NativeAppTemplate/Networking/Network/CertificatePinningDelegate.swift +++ b/NativeAppTemplate/Networking/Network/CertificatePinningDelegate.swift @@ -2,16 +2,14 @@ // CertificatePinningDelegate.swift // NativeAppTemplate // -// Created by Daisuke Adachi. -// import CommonCrypto import Foundation final class CertificatePinningDelegate: NSObject, URLSessionDelegate { - // SPKI SHA-256 hashes (base64-encoded) for api.nativeapptemplate.com - // The server uses Google Trust Services certificates (Render hosting). - // Pin the leaf public key and Google Trust Services intermediate CAs as backup. + /// SPKI SHA-256 hashes (base64-encoded) for api.nativeapptemplate.com + /// The server uses Google Trust Services certificates (Render hosting). + /// Pin the leaf public key and Google Trust Services intermediate CAs as backup. static let pinnedHashes: Set = [ // Leaf certificate public key (api.nativeapptemplate.com) "54Il7gpV4QvX8fAyEKV+6fp8VGjgHqIAAqF5bLCfYNQ=", @@ -21,19 +19,19 @@ final class CertificatePinningDelegate: NSObject, URLSessionDelegate { static let pinnedDomain = String.domain - // ASN.1 header for EC 256-bit public key (SPKI prefix) + /// ASN.1 header for EC 256-bit public key (SPKI prefix) private static let ecDsaSecp256r1Asn1Header: [UInt8] = [ - 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, - 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, - 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, + 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, + 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, + 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00 ] - // ASN.1 header for RSA 2048-bit public key (SPKI prefix) + /// ASN.1 header for RSA 2048-bit public key (SPKI prefix) private static let rsa2048Asn1Header: [UInt8] = [ - 0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, - 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00 + 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, + 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, + 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00 ] func urlSession( @@ -52,7 +50,7 @@ final class CertificatePinningDelegate: NSObject, URLSessionDelegate { let certificateCount = SecTrustGetCertificateCount(serverTrust) var pinMatched = false - for index in 0..