Skip to content

Commit

Permalink
Update swiftformat to swift version 5.9
Browse files Browse the repository at this point in the history
  • Loading branch information
libec committed Feb 24, 2024
1 parent 050b9f4 commit d1789bd
Show file tree
Hide file tree
Showing 21 changed files with 73 additions and 73 deletions.
36 changes: 18 additions & 18 deletions App/Keyboard Handling/System/SystemKeyboardObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
22 changes: 11 additions & 11 deletions App/Windows/System/WindowsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions App/Windows/System/WindowsFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ final class ClipsRepositoryImpl<StorageScheduler: Scheduler>: 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)
}

private func observePasteboard() {
pasteboardObserver.newCopiedText.map(Clip.newClip(with:))
.sink { [unowned self] newClip in
self.addNewClipFromPasteboard(newClip: newClip)
addNewClipFromPasteboard(newClip: newClip)
}.store(in: &subscriptions)
}

Expand All @@ -100,14 +100,14 @@ final class ClipsRepositoryImpl<StorageScheduler: Scheduler>: 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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -29,7 +29,7 @@ final class LocalTutorialResource: TutorialResource {
func value(for numericValue: TutorialNumericValue) -> Int {
switch numericValue {
case .clipsMovement:
return clipsMovement
clipsMovement
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UserDefaultsTutorialResource: TutorialResource {
private extension TutorialNumericValue {
private var key: String {
switch self {
case .clipsMovement: return "ClipsMovement"
case .clipsMovement: "ClipsMovement"
}
}

Expand All @@ -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"
}
}

Expand Down
6 changes: 3 additions & 3 deletions ClipNinja/Sources/Features/Tutorial/View/TutorialView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ struct TutorialView<ViewModel: TutorialViewModel>: 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())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SwinjectInstanceProvider: InstanceProvider {
resolver.resolve(type)!
}

func resolve<Instance, Argument>(_ type: Instance.Type, argument: Argument) -> Instance {
func resolve<Instance>(_ type: Instance.Type, argument: some Any) -> Instance {
resolver.resolve(type, argument: argument)!
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SwiftUI

extension Bool {
func binding(onChange: @escaping () -> Void) -> Binding<Bool> {
return Binding<Bool> {
Binding<Bool> {
self
} set: { _ in
onChange()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class PasteUseCaseTests: XCTestCase {
clipsRepository: ClipsRepository,
viewPortRepository: ViewPortRepository
) -> PasteUseCase {
return PasteUseCaseImpl(
PasteUseCaseImpl(
clipsRepository: clipsRepository,
viewPortRepository: viewPortRepository,
hideAppUseCase: hideAppUseCase,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class ClipboardViewModelTests: XCTestCase {

class ClipboardPreviewFactoryDummy: ClipboardPreviewFactory {
func makePreview(from _: Clip, index _: Int, selected _: Bool) -> ClipPreview {
return .dummy
.dummy
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class GetSettingsUseCaseStub: GetSettingsUseCase {
}

var settings: AnyPublisher<Settings, Never> {
return Just(storedSettings)
Just(storedSettings)
.eraseToAnyPublisher()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TutorialsSpy: Tutorials {

init() {}

func getCurrent() -> Tutorial? { return nil }
func getCurrent() -> Tutorial? { nil }

func finish() {
finishCalled = true
Expand Down

0 comments on commit d1789bd

Please sign in to comment.