From d1789bd8350b8b21f1c4c86e63ea257128ee2fd8 Mon Sep 17 00:00:00 2001 From: Libec Date: Sat, 24 Feb 2024 17:40:16 +0100 Subject: [PATCH] Update swiftformat to swift version 5.9 --- .../System/SystemKeyboardObserver.swift | 36 +++++++++---------- App/Windows/System/WindowsController.swift | 22 ++++++------ App/Windows/System/WindowsFactory.swift | 6 ++-- .../Domain/MoveViewPortUseCase.swift | 8 ++--- .../Clipboard/System/ClipsRepository.swift | 8 ++--- .../Pasteboard/Domain/PasteTextUseCase.swift | 2 +- .../Presentation/SettingsViewModel.swift | 6 ++-- .../Domain/CheckTutorialUseCase.swift | 6 ++-- .../Tutorial/Domain/TutorialRepository.swift | 2 +- .../System/LocalTutorialResource.swift | 6 ++-- .../System/UserDefaultsTutorialResource.swift | 6 ++-- .../Features/Tutorial/View/TutorialView.swift | 6 ++-- .../System/SwinjectInstanceProvider.swift | 2 +- .../Logger/Infrastructure/Logger.swift | 12 +++---- .../Navigation/Domain/Navigation.swift | 4 +-- .../Swift Types Extensions/Bool+Binding.swift | 2 +- .../Result+ErrorAccessor.swift | 4 +-- .../Clipboard/Domain/PasteUseCaseTests.swift | 2 +- .../ClipboardViewModelTests.swift | 2 +- .../Presentation/SettingsViewModelTests.swift | 2 +- .../Presentation/TutorialViewModelTests.swift | 2 +- 21 files changed, 73 insertions(+), 73 deletions(-) diff --git a/App/Keyboard Handling/System/SystemKeyboardObserver.swift b/App/Keyboard Handling/System/SystemKeyboardObserver.swift index e90e575..9f2de47 100644 --- a/App/Keyboard Handling/System/SystemKeyboardObserver.swift +++ b/App/Keyboard Handling/System/SystemKeyboardObserver.swift @@ -18,41 +18,41 @@ final class SystemKeyboardObserver: KeyboardObserver { private func keyboardEvent(from shortcutsKeyPress: KeyboardShortcuts.Key) -> KeyboardEvent? { switch shortcutsKeyPress { case .downArrow: - return .down + .down case .upArrow: - return .up + .up case .rightArrow: - return .right + .right case .leftArrow: - return .left + .left case .delete: - return .delete + .delete case .keypadEnter, .return: - return .enter + .enter case .space: - return .space + .space case .escape: - return .escape + .escape case .keypad1, .one: - return .number(number: 1) + .number(number: 1) case .keypad2, .two: - return .number(number: 2) + .number(number: 2) case .keypad3, .three: - return .number(number: 3) + .number(number: 3) case .keypad4, .four: - return .number(number: 4) + .number(number: 4) case .keypad5, .five: - return .number(number: 5) + .number(number: 5) case .keypad6, .six: - return .number(number: 6) + .number(number: 6) case .keypad7, .seven: - return .number(number: 7) + .number(number: 7) case .keypad8, .eight: - return .number(number: 8) + .number(number: 8) case .keypad9, .nine: - return .number(number: 9) + .number(number: 9) default: - return nil + nil } } } diff --git a/App/Windows/System/WindowsController.swift b/App/Windows/System/WindowsController.swift index 937a057..42ff30e 100644 --- a/App/Windows/System/WindowsController.swift +++ b/App/Windows/System/WindowsController.swift @@ -76,26 +76,26 @@ class WindowsController { case .hideApp: NSApp.hide(nil) case .showClipboard: - self.closeSettingsWindows() - self.closeClipsWindows() - self.activate(appWindow: .clips) + closeSettingsWindows() + closeClipsWindows() + activate(appWindow: .clips) case .showSettings: - self.closeSettingsWindows() - self.closeClipsWindows() - self.activate(appWindow: .settings) + closeSettingsWindows() + closeClipsWindows() + activate(appWindow: .settings) case .showAppUsage: let clipboardWindows = NSApp.windows.filter { $0 is ClipboardWindow } if let clipboardWindow = clipboardWindows.first { clipboardWindow.makeKeyAndOrderFront(nil) - self.activeWindow = clipboardWindow + activeWindow = clipboardWindow } else { - self.activate(appWindow: .clips) + activate(appWindow: .clips) } - self.showModal(modalWindow: .tutorial) + showModal(modalWindow: .tutorial) case .showTutorial: - self.showModal(modalWindow: .tutorial) + showModal(modalWindow: .tutorial) case .hideTutorial: - self.hideModal() + hideModal() case .showSystemSettings: let accessibilityUrl = Strings.Settings.PasteDirectly.accessibilityUrl guard let url = URL(string: accessibilityUrl) else { diff --git a/App/Windows/System/WindowsFactory.swift b/App/Windows/System/WindowsFactory.swift index 9e35e4c..cc215e9 100644 --- a/App/Windows/System/WindowsFactory.swift +++ b/App/Windows/System/WindowsFactory.swift @@ -18,11 +18,11 @@ final class WindowsFactoryImpl: WindowsFactory { func make(appWindow: AppWindow) -> StyledWindow { switch appWindow { case .clips: - return makeClipsWindow() + makeClipsWindow() case .settings: - return makeSettingsWindow() + makeSettingsWindow() case .tutorial: - return makeTutorialWindow() + makeTutorialWindow() } } diff --git a/ClipNinja/Sources/Features/Clipboard/Domain/MoveViewPortUseCase.swift b/ClipNinja/Sources/Features/Clipboard/Domain/MoveViewPortUseCase.swift index fcae9a2..31ec1f6 100644 --- a/ClipNinja/Sources/Features/Clipboard/Domain/MoveViewPortUseCase.swift +++ b/ClipNinja/Sources/Features/Clipboard/Domain/MoveViewPortUseCase.swift @@ -39,10 +39,10 @@ class MoveViewPortUseCaseImpl: MoveViewPortUseCase { private func movementAmount(for viewPortMovement: ViewPortMovement) -> Int { switch viewPortMovement { - case .up: return -1 - case .down: return 1 - case .left: return -viewPortConfiguration.clipsPerPage - case .right: return viewPortConfiguration.clipsPerPage + case .up: -1 + case .down: 1 + case .left: -viewPortConfiguration.clipsPerPage + case .right: viewPortConfiguration.clipsPerPage } } } diff --git a/ClipNinja/Sources/Features/Clipboard/System/ClipsRepository.swift b/ClipNinja/Sources/Features/Clipboard/System/ClipsRepository.swift index 4d8bb44..6bb195e 100644 --- a/ClipNinja/Sources/Features/Clipboard/System/ClipsRepository.swift +++ b/ClipNinja/Sources/Features/Clipboard/System/ClipsRepository.swift @@ -77,7 +77,7 @@ final class ClipsRepositoryImpl: ClipsRepository { clipsSubject .throttle(for: 1, scheduler: storageScheduler, latest: true) .sink(receiveValue: { [unowned self] clips in - self.persist(clips: clips) + persist(clips: clips) }) .store(in: &subscriptions) } @@ -85,7 +85,7 @@ final class ClipsRepositoryImpl: ClipsRepository { private func observePasteboard() { pasteboardObserver.newCopiedText.map(Clip.newClip(with:)) .sink { [unowned self] newClip in - self.addNewClipFromPasteboard(newClip: newClip) + addNewClipFromPasteboard(newClip: newClip) }.store(in: &subscriptions) } @@ -100,14 +100,14 @@ final class ClipsRepositoryImpl: ClipsRepository { let newClipIsTheSameAsLastlyPastedClip = lastPastedClip?.text == newClip.text let shouldSkipMovingExistingClipsToTheMostRecent = !settingsRepository.lastSettings.movePastedClipToTop - if newClipIsTheSameAsLastlyPastedClip && shouldSkipMovingExistingClipsToTheMostRecent { + if newClipIsTheSameAsLastlyPastedClip, shouldSkipMovingExistingClipsToTheMostRecent { return } if let clipIndex = clipsSubject.value.firstIndex(of: newClip) { delete(at: clipIndex) } - let pinnedClips = clipsSubject.value.filter { $0.pinned }.count + let pinnedClips = clipsSubject.value.filter(\.pinned).count clipsSubject.value.insert(newClip, at: max(0, pinnedClips)) clipsSubject.value = Array(clipsSubject.value.prefix(viewPortConfiguration.clipsPerPage * viewPortConfiguration.totalPages)) } diff --git a/ClipNinja/Sources/Features/Pasteboard/Domain/PasteTextUseCase.swift b/ClipNinja/Sources/Features/Pasteboard/Domain/PasteTextUseCase.swift index bae478e..53dbdde 100644 --- a/ClipNinja/Sources/Features/Pasteboard/Domain/PasteTextUseCase.swift +++ b/ClipNinja/Sources/Features/Pasteboard/Domain/PasteTextUseCase.swift @@ -22,7 +22,7 @@ final class PasteTextUseCaseImpl: PasteTextUseCase { func paste(text: String) { pasteboardResource.insert(text: text) - if settingsRepository.lastSettings.pasteDirectly && permissionsResource.pastingAllowed { + if settingsRepository.lastSettings.pasteDirectly, permissionsResource.pastingAllowed { pasteCommand.paste() } } diff --git a/ClipNinja/Sources/Features/Settings/Presentation/SettingsViewModel.swift b/ClipNinja/Sources/Features/Settings/Presentation/SettingsViewModel.swift index ab94b35..aa4668e 100644 --- a/ClipNinja/Sources/Features/Settings/Presentation/SettingsViewModel.swift +++ b/ClipNinja/Sources/Features/Settings/Presentation/SettingsViewModel.swift @@ -75,9 +75,9 @@ final class SettingsViewModelImpl: SettingsViewModel { private func subscribe() { getSettingsUseCase.settings .sink { [unowned self] newSettings in - self.pasteDirectly = newSettings.pasteDirectly - self.movePastedClipToTop = newSettings.movePastedClipToTop - self.launchAtLogin = newSettings.launchAtLogin + pasteDirectly = newSettings.pasteDirectly + movePastedClipToTop = newSettings.movePastedClipToTop + launchAtLogin = newSettings.launchAtLogin } .store(in: &subscriptions) } diff --git a/ClipNinja/Sources/Features/Tutorial/Domain/CheckTutorialUseCase.swift b/ClipNinja/Sources/Features/Tutorial/Domain/CheckTutorialUseCase.swift index cf8ff79..36955a3 100644 --- a/ClipNinja/Sources/Features/Tutorial/Domain/CheckTutorialUseCase.swift +++ b/ClipNinja/Sources/Features/Tutorial/Domain/CheckTutorialUseCase.swift @@ -5,9 +5,9 @@ enum TutorialTriggeringEvent: CaseIterable { fileprivate var eventDescription: String { switch self { - case .clipsAppear: return "Clips appeared" - case .clipsMovement: return "Clips movement event" - case .pasteText: return "Paste text" + case .clipsAppear: "Clips appeared" + case .clipsMovement: "Clips movement event" + case .pasteText: "Paste text" } } diff --git a/ClipNinja/Sources/Features/Tutorial/Domain/TutorialRepository.swift b/ClipNinja/Sources/Features/Tutorial/Domain/TutorialRepository.swift index eee55d6..d220117 100644 --- a/ClipNinja/Sources/Features/Tutorial/Domain/TutorialRepository.swift +++ b/ClipNinja/Sources/Features/Tutorial/Domain/TutorialRepository.swift @@ -26,7 +26,7 @@ final class TutorialRepositoryImpl: TutorialRepository { case .clipsMovement: break case .pasteText: - if !permissionsResource.pastingAllowed && !resource.contains(flag: .pasteText) { + if !permissionsResource.pastingAllowed, !resource.contains(flag: .pasteText) { currentTutorial = .pasting } } diff --git a/ClipNinja/Sources/Features/Tutorial/System/LocalTutorialResource.swift b/ClipNinja/Sources/Features/Tutorial/System/LocalTutorialResource.swift index 63c89d8..1c84dc6 100644 --- a/ClipNinja/Sources/Features/Tutorial/System/LocalTutorialResource.swift +++ b/ClipNinja/Sources/Features/Tutorial/System/LocalTutorialResource.swift @@ -14,8 +14,8 @@ final class LocalTutorialResource: TutorialResource { func contains(flag: TutorialFlag) -> Bool { switch flag { - case .onboard: return userOnboard - case .pasteText: return pastedText + case .onboard: userOnboard + case .pasteText: pastedText } } @@ -29,7 +29,7 @@ final class LocalTutorialResource: TutorialResource { func value(for numericValue: TutorialNumericValue) -> Int { switch numericValue { case .clipsMovement: - return clipsMovement + clipsMovement } } } diff --git a/ClipNinja/Sources/Features/Tutorial/System/UserDefaultsTutorialResource.swift b/ClipNinja/Sources/Features/Tutorial/System/UserDefaultsTutorialResource.swift index 443a06d..c643c04 100644 --- a/ClipNinja/Sources/Features/Tutorial/System/UserDefaultsTutorialResource.swift +++ b/ClipNinja/Sources/Features/Tutorial/System/UserDefaultsTutorialResource.swift @@ -28,7 +28,7 @@ class UserDefaultsTutorialResource: TutorialResource { private extension TutorialNumericValue { private var key: String { switch self { - case .clipsMovement: return "ClipsMovement" + case .clipsMovement: "ClipsMovement" } } @@ -40,8 +40,8 @@ private extension TutorialNumericValue { private extension TutorialFlag { private var key: String { switch self { - case .pasteText: return "PasteText" - case .onboard: return "Onboard" + case .pasteText: "PasteText" + case .onboard: "Onboard" } } diff --git a/ClipNinja/Sources/Features/Tutorial/View/TutorialView.swift b/ClipNinja/Sources/Features/Tutorial/View/TutorialView.swift index bf4fbf6..6d94b69 100644 --- a/ClipNinja/Sources/Features/Tutorial/View/TutorialView.swift +++ b/ClipNinja/Sources/Features/Tutorial/View/TutorialView.swift @@ -33,11 +33,11 @@ struct TutorialView: View { private var tutorialView: some View { switch viewModel.tutorial { case .welcome: - return AnyView(WelcomeTutorialView()) + AnyView(WelcomeTutorialView()) case .pasting: - return AnyView(PasteDirectlyTutorialView()) + AnyView(PasteDirectlyTutorialView()) case .none: - return AnyView(AppUsageTutorialView()) + AnyView(AppUsageTutorialView()) } } } diff --git a/ClipNinja/Sources/Infrastructure/Instance Provider/System/SwinjectInstanceProvider.swift b/ClipNinja/Sources/Infrastructure/Instance Provider/System/SwinjectInstanceProvider.swift index 6fcd2ee..14eb378 100644 --- a/ClipNinja/Sources/Infrastructure/Instance Provider/System/SwinjectInstanceProvider.swift +++ b/ClipNinja/Sources/Infrastructure/Instance Provider/System/SwinjectInstanceProvider.swift @@ -11,7 +11,7 @@ class SwinjectInstanceProvider: InstanceProvider { resolver.resolve(type)! } - func resolve(_ type: Instance.Type, argument: Argument) -> Instance { + func resolve(_ type: Instance.Type, argument: some Any) -> Instance { resolver.resolve(type, argument: argument)! } diff --git a/ClipNinja/Sources/Infrastructure/Logger/Infrastructure/Logger.swift b/ClipNinja/Sources/Infrastructure/Logger/Infrastructure/Logger.swift index b18018d..ac9841c 100644 --- a/ClipNinja/Sources/Infrastructure/Logger/Infrastructure/Logger.swift +++ b/ClipNinja/Sources/Infrastructure/Logger/Infrastructure/Logger.swift @@ -15,12 +15,12 @@ public enum LogCategory: CaseIterable { fileprivate var logDescription: String { switch self { - case .main: return "system" - case .storage: return "storage" - case .tutorial: return "tutorial" - case .viewPort: return "view port" - case .windows: return "windows" - case .migration: return "migration" + case .main: "system" + case .storage: "storage" + case .tutorial: "tutorial" + case .viewPort: "view port" + case .windows: "windows" + case .migration: "migration" } } diff --git a/ClipNinja/Sources/Infrastructure/Navigation/Domain/Navigation.swift b/ClipNinja/Sources/Infrastructure/Navigation/Domain/Navigation.swift index f802d97..cbc4f57 100644 --- a/ClipNinja/Sources/Infrastructure/Navigation/Domain/Navigation.swift +++ b/ClipNinja/Sources/Infrastructure/Navigation/Domain/Navigation.swift @@ -12,9 +12,9 @@ public enum NavigationEvent { public var delayedEvent: Bool { switch self { case .showTutorial: - return true + true case .showClipboard, .showSettings, .hideApp, .showSystemSettings, .showAppUsage, .hideTutorial: - return false + false } } diff --git a/ClipNinja/Sources/Infrastructure/Swift Types Extensions/Bool+Binding.swift b/ClipNinja/Sources/Infrastructure/Swift Types Extensions/Bool+Binding.swift index 89fa901..12aa3f0 100644 --- a/ClipNinja/Sources/Infrastructure/Swift Types Extensions/Bool+Binding.swift +++ b/ClipNinja/Sources/Infrastructure/Swift Types Extensions/Bool+Binding.swift @@ -2,7 +2,7 @@ import SwiftUI extension Bool { func binding(onChange: @escaping () -> Void) -> Binding { - return Binding { + Binding { self } set: { _ in onChange() diff --git a/ClipNinja/Sources/Infrastructure/Swift Types Extensions/Result+ErrorAccessor.swift b/ClipNinja/Sources/Infrastructure/Swift Types Extensions/Result+ErrorAccessor.swift index 617ed33..7998c21 100644 --- a/ClipNinja/Sources/Infrastructure/Swift Types Extensions/Result+ErrorAccessor.swift +++ b/ClipNinja/Sources/Infrastructure/Swift Types Extensions/Result+ErrorAccessor.swift @@ -1,8 +1,8 @@ public extension Result where Failure: Error { func error() -> Failure? { switch self { - case .success: return nil - case let .failure(error): return error + case .success: nil + case let .failure(error): error } } } diff --git a/ClipNinja/Tests/Features/Clipboard/Domain/PasteUseCaseTests.swift b/ClipNinja/Tests/Features/Clipboard/Domain/PasteUseCaseTests.swift index e35972b..7636768 100644 --- a/ClipNinja/Tests/Features/Clipboard/Domain/PasteUseCaseTests.swift +++ b/ClipNinja/Tests/Features/Clipboard/Domain/PasteUseCaseTests.swift @@ -223,7 +223,7 @@ class PasteUseCaseTests: XCTestCase { clipsRepository: ClipsRepository, viewPortRepository: ViewPortRepository ) -> PasteUseCase { - return PasteUseCaseImpl( + PasteUseCaseImpl( clipsRepository: clipsRepository, viewPortRepository: viewPortRepository, hideAppUseCase: hideAppUseCase, diff --git a/ClipNinja/Tests/Features/Clipboard/Presentation/ClipboardViewModelTests.swift b/ClipNinja/Tests/Features/Clipboard/Presentation/ClipboardViewModelTests.swift index 2b7938d..6254576 100644 --- a/ClipNinja/Tests/Features/Clipboard/Presentation/ClipboardViewModelTests.swift +++ b/ClipNinja/Tests/Features/Clipboard/Presentation/ClipboardViewModelTests.swift @@ -125,7 +125,7 @@ class ClipboardViewModelTests: XCTestCase { class ClipboardPreviewFactoryDummy: ClipboardPreviewFactory { func makePreview(from _: Clip, index _: Int, selected _: Bool) -> ClipPreview { - return .dummy + .dummy } } diff --git a/ClipNinja/Tests/Features/Settings/Presentation/SettingsViewModelTests.swift b/ClipNinja/Tests/Features/Settings/Presentation/SettingsViewModelTests.swift index 52fe19f..b00f72f 100644 --- a/ClipNinja/Tests/Features/Settings/Presentation/SettingsViewModelTests.swift +++ b/ClipNinja/Tests/Features/Settings/Presentation/SettingsViewModelTests.swift @@ -126,7 +126,7 @@ class GetSettingsUseCaseStub: GetSettingsUseCase { } var settings: AnyPublisher { - return Just(storedSettings) + Just(storedSettings) .eraseToAnyPublisher() } } diff --git a/ClipNinja/Tests/Features/Tutorial/Presentation/TutorialViewModelTests.swift b/ClipNinja/Tests/Features/Tutorial/Presentation/TutorialViewModelTests.swift index 11fcb28..8f55b91 100644 --- a/ClipNinja/Tests/Features/Tutorial/Presentation/TutorialViewModelTests.swift +++ b/ClipNinja/Tests/Features/Tutorial/Presentation/TutorialViewModelTests.swift @@ -48,7 +48,7 @@ class TutorialsSpy: Tutorials { init() {} - func getCurrent() -> Tutorial? { return nil } + func getCurrent() -> Tutorial? { nil } func finish() { finishCalled = true