From a4a4e33c1d5d89ef694173eead488bdf7e08b438 Mon Sep 17 00:00:00 2001 From: Lukas Pistrol Date: Fri, 4 Oct 2024 12:47:14 +0200 Subject: [PATCH] fix lint errors --- TimeMachineStatus.xcodeproj/project.pbxproj | 2 +- .../xcschemes/TimeMachineStatus.xcscheme | 78 +++++++++++++++++++ .../Components/ExpandableSection.swift | 2 +- .../HideWindowControlsViewModifier.swift | 6 +- .../Components/UserfacingErrorView.swift | 2 +- .../Model/Preferences/Preferences.swift | 8 +- TimeMachineStatus/TimeMachineStatusApp.swift | 2 +- TimeMachineStatus/ViewModel/TMUtility.swift | 2 +- TimeMachineStatus/Views/MenuView.swift | 6 +- 9 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 TimeMachineStatus.xcodeproj/xcshareddata/xcschemes/TimeMachineStatus.xcscheme diff --git a/TimeMachineStatus.xcodeproj/project.pbxproj b/TimeMachineStatus.xcodeproj/project.pbxproj index 118def9..ff1f485 100644 --- a/TimeMachineStatus.xcodeproj/project.pbxproj +++ b/TimeMachineStatus.xcodeproj/project.pbxproj @@ -473,7 +473,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nif [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\nif which swiftlint > /dev/null; then\n if $CI; then\n echo \"Skipping SwiftLint (CI)\"\n else\n swiftlint\n fi\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; + shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nif [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\nif which swiftlint > /dev/null; then\n if [[ $CI ]]; then\n echo \"Skipping SwiftLint (CI)\"\n else\n swiftlint\n fi\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/TimeMachineStatus.xcodeproj/xcshareddata/xcschemes/TimeMachineStatus.xcscheme b/TimeMachineStatus.xcodeproj/xcshareddata/xcschemes/TimeMachineStatus.xcscheme new file mode 100644 index 0000000..5e9731d --- /dev/null +++ b/TimeMachineStatus.xcodeproj/xcshareddata/xcschemes/TimeMachineStatus.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TimeMachineStatus/Components/ExpandableSection.swift b/TimeMachineStatus/Components/ExpandableSection.swift index 67b6fe4..233156f 100644 --- a/TimeMachineStatus/Components/ExpandableSection.swift +++ b/TimeMachineStatus/Components/ExpandableSection.swift @@ -37,7 +37,7 @@ struct ExpandableSection: View { HStack { header() Spacer() - Image(systemName: "chevron.right") + Image(systemSymbol: .chevronRight) .rotationEffect(expanded ? .degrees(90) : .zero) .padding(.horizontal, 12) .contentShape(.rect) diff --git a/TimeMachineStatus/Components/HideWindowControlsViewModifier.swift b/TimeMachineStatus/Components/HideWindowControlsViewModifier.swift index 8c25922..7333f8a 100644 --- a/TimeMachineStatus/Components/HideWindowControlsViewModifier.swift +++ b/TimeMachineStatus/Components/HideWindowControlsViewModifier.swift @@ -11,13 +11,13 @@ import SwiftUI -private struct HideWindowControllsViewModifier: ViewModifier { +private struct HideWindowControlsViewModifier: ViewModifier { let types: [NSWindow.ButtonType] func body(content: Content) -> some View { content - .onReceive(NotificationCenter.default.publisher(for: NSWindow.didBecomeKeyNotification)) { notification in + .onReceive(NotificationCenter.default.publisher(for: NSWindow.didBecomeKeyNotification)) { _ in guard let window = NSApplication.shared.windows.first(where: { $0.isKeyWindow }) else { return } hideWindowControls(for: window) } @@ -38,6 +38,6 @@ extension View { .zoomButton ] ) -> some View { - modifier(HideWindowControllsViewModifier(types: types)) + modifier(HideWindowControlsViewModifier(types: types)) } } diff --git a/TimeMachineStatus/Components/UserfacingErrorView.swift b/TimeMachineStatus/Components/UserfacingErrorView.swift index 9dc4f66..6d9ac3d 100644 --- a/TimeMachineStatus/Components/UserfacingErrorView.swift +++ b/TimeMachineStatus/Components/UserfacingErrorView.swift @@ -38,7 +38,7 @@ struct UserfacingErrorView: View { if let action = error.action { Divider() switch action { - case .link(let title, let url): + case let .link(title, url): Button(title) { NSWorkspace.shared.open(url) } diff --git a/TimeMachineStatus/Model/Preferences/Preferences.swift b/TimeMachineStatus/Model/Preferences/Preferences.swift index c017406..45b0922 100644 --- a/TimeMachineStatus/Model/Preferences/Preferences.swift +++ b/TimeMachineStatus/Model/Preferences/Preferences.swift @@ -40,7 +40,7 @@ struct Preferences: Decodable { ) self.destinations = try container .decodeIfPresent([Destination].self, forKey: .destinations)? - .sorted {$0.lastKnownVolumeName ?? "" < $1.lastKnownVolumeName ?? "" } + .sorted { $0.lastKnownVolumeName ?? "" < $1.lastKnownVolumeName ?? "" } self.skipPaths = try container.decodeIfPresent([String].self, forKey: .skipPaths) } @@ -144,13 +144,13 @@ extension Destination { bytesAvailable: .random(in: 10_000_000_000...100_000_000_000), filesystemTypeName: "APFS", lastKnownEncryptionState: "Encrypted", - quotaGB: .random(in: 400...1000), + quotaGB: .random(in: 400...1_000), networkURL: network ? "smb://nas.local/share" : nil, destinationID: UUID(), consistencyScanDate: .distantPast, referenceLocalSnapshotDate: .now, - snapshotDates: [.distantPast, .now.addingTimeInterval(.random(in: -100000...0))], - attemptDates: [.distantPast, .now.addingTimeInterval(.random(in: -100000...0))] + snapshotDates: [.distantPast, .now.addingTimeInterval(.random(in: -100_000...0))], + attemptDates: [.distantPast, .now.addingTimeInterval(.random(in: -100_000...0))] ) } } diff --git a/TimeMachineStatus/TimeMachineStatusApp.swift b/TimeMachineStatus/TimeMachineStatusApp.swift index 798012d..9239814 100644 --- a/TimeMachineStatus/TimeMachineStatusApp.swift +++ b/TimeMachineStatus/TimeMachineStatusApp.swift @@ -11,8 +11,8 @@ import Logging import LoggingOSLog -import SwiftUI @_exported import SFSafeSymbols +import SwiftUI @main struct TimeMachineStatusApp: App { diff --git a/TimeMachineStatus/ViewModel/TMUtility.swift b/TimeMachineStatus/ViewModel/TMUtility.swift index d416b7d..5fa113d 100644 --- a/TimeMachineStatus/ViewModel/TMUtility.swift +++ b/TimeMachineStatus/ViewModel/TMUtility.swift @@ -87,7 +87,7 @@ class TMUtilityImpl: TMUtility { var canReadPreferences: Bool { do { - let _ = try Data(contentsOf: Constants.URLs.timeMachinePreferencesPlist) + _ = try Data(contentsOf: Constants.URLs.timeMachinePreferencesPlist) return true } catch { return false diff --git a/TimeMachineStatus/Views/MenuView.swift b/TimeMachineStatus/Views/MenuView.swift index 8f7db13..a24f278 100644 --- a/TimeMachineStatus/Views/MenuView.swift +++ b/TimeMachineStatus/Views/MenuView.swift @@ -266,7 +266,11 @@ struct MenuView: View { #Preview("Light Error") { MenuView( - utility: TMUtilityMock(preferences: .mock, error: .preferencesFilePermissionNotGranted, canReadPreferences: false), + utility: TMUtilityMock( + preferences: .mock, + error: .preferencesFilePermissionNotGranted, + canReadPreferences: false + ), updater: SPUStandardUpdaterController(updaterDelegate: nil, userDriverDelegate: nil).updater ) .preferredColorScheme(.light)