Fix SwiftLint errors

This commit is contained in:
Conrad Kramer 2024-09-07 17:36:48 -07:00
parent fa1ef6fcda
commit 3fbb520a10
5 changed files with 33 additions and 25 deletions

View file

@ -27,7 +27,9 @@ runs:
Apple/DerivedData Apple/DerivedData
key: ${{ runner.os }}-${{ inputs.scheme }}-${{ hashFiles('**/Package.resolved') }} key: ${{ runner.os }}-${{ inputs.scheme }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: | restore-keys: |
${{ runner.os }}-${{ inputs.scheme }}-${{ hashFiles('**/Package.resolved') }}
${{ runner.os }}-${{ inputs.scheme }}- ${{ runner.os }}-${{ inputs.scheme }}-
${{ runner.os }}-
- name: Build - name: Build
shell: bash shell: bash
working-directory: Apple working-directory: Apple

View file

@ -21,14 +21,16 @@ jobs:
- x86_64-unknown-linux-gnu - x86_64-unknown-linux-gnu
targets: targets:
- aarch64-unknown-linux-gnu - aarch64-unknown-linux-gnu
- os: macos-12 - os: macos-13
platform: macOS (Intel) platform: macOS (Intel)
xcode: /Applications/Xcode_15.2.app
test-targets: test-targets:
- x86_64-apple-darwin - x86_64-apple-darwin
targets: targets:
- x86_64-apple-ios - x86_64-apple-ios
- os: macos-14 - os: macos-14
platform: macOS platform: macOS
xcode: /Applications/Xcode_16.0.app
test-targets: test-targets:
- aarch64-apple-darwin - aarch64-apple-darwin
targets: targets:
@ -42,7 +44,7 @@ jobs:
- aarch64-pc-windows-msvc - aarch64-pc-windows-msvc
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
DEVELOPER_DIR: /Applications/Xcode_16.0.app/Contents/Developer DEVELOPER_DIR: ${{ matrix.xcode }}/Contents/Developer
CARGO_INCREMENTAL: 0 CARGO_INCREMENTAL: 0
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
RUST_BACKTRACE: short RUST_BACKTRACE: short

View file

@ -2,7 +2,8 @@
import AppKit import AppKit
import SwiftUI import SwiftUI
@MainActor @main @main
@MainActor
class AppDelegate: NSObject, NSApplicationDelegate { class AppDelegate: NSObject, NSApplicationDelegate {
private let quitItem: NSMenuItem = { private let quitItem: NSMenuItem = {
let quitItem = NSMenuItem( let quitItem = NSMenuItem(

View file

@ -42,7 +42,6 @@ struct BurrowView: View {
} }
private func addWireGuardNetwork() { private func addWireGuardNetwork() {
} }
private func authenticateWithSlack() async throws { private func authenticateWithSlack() async throws {

View file

@ -1,6 +1,6 @@
import AuthenticationServices import AuthenticationServices
import SwiftUI
import Foundation import Foundation
import SwiftUI
enum OAuth2 { enum OAuth2 {
enum Error: Swift.Error { enum Error: Swift.Error {
@ -35,7 +35,7 @@ enum OAuth2 {
} }
} }
public init( init(
authorizationEndpoint: URL, authorizationEndpoint: URL,
tokenEndpoint: URL, tokenEndpoint: URL,
redirectURI: URL, redirectURI: URL,
@ -125,7 +125,11 @@ enum OAuth2 {
var refreshToken: String? var refreshToken: String?
var credential: Credential { var credential: Credential {
.init(accessToken: accessToken, refreshToken: refreshToken, expirationDate: expiresIn.map { Date.init(timeIntervalSinceNow: $0) }) .init(
accessToken: accessToken,
refreshToken: refreshToken,
expirationDate: expiresIn.map { Date(timeIntervalSinceNow: $0) }
)
} }
} }
@ -203,7 +207,24 @@ enum OAuth2 {
} }
extension WebAuthenticationSession { extension WebAuthenticationSession {
func start(url: URL, redirectURI: URL) async throws -> URL { #if canImport(BrowserEngineKit)
@available(iOS 17.4, macOS 14.4, tvOS 17.4, watchOS 10.4, *)
fileprivate static func callback(for redirectURI: URL) throws -> ASWebAuthenticationSession.Callback {
switch redirectURI.scheme {
case "https":
guard let host = redirectURI.host else { throw OAuth2.Error.invalidRedirectURI }
return .https(host: host, path: redirectURI.path)
case "http":
throw OAuth2.Error.invalidRedirectURI
case .some(let scheme):
return .customScheme(scheme)
case .none:
throw OAuth2.Error.invalidRedirectURI
}
}
#endif
fileprivate func start(url: URL, redirectURI: URL) async throws -> URL {
#if canImport(BrowserEngineKit) #if canImport(BrowserEngineKit)
if #available(iOS 17.4, macOS 14.4, tvOS 17.4, watchOS 10.4, *) { if #available(iOS 17.4, macOS 14.4, tvOS 17.4, watchOS 10.4, *) {
return try await authenticate( return try await authenticate(
@ -231,23 +252,6 @@ extension WebAuthenticationSession {
return url return url
} }
} }
#if canImport(BrowserEngineKit)
@available(iOS 17.4, macOS 14.4, tvOS 17.4, watchOS 10.4, *)
fileprivate static func callback(for redirectURI: URL) throws -> ASWebAuthenticationSession.Callback {
switch redirectURI.scheme {
case "https":
guard let host = redirectURI.host else { throw OAuth2.Error.invalidRedirectURI }
return .https(host: host, path: redirectURI.path)
case "http":
throw OAuth2.Error.invalidRedirectURI
case .some(let scheme):
return .customScheme(scheme)
case .none:
throw OAuth2.Error.invalidRedirectURI
}
}
#endif
} }
extension View { extension View {