From 8156328cf61e637aee8f3a5dd94c4402e722ca8e Mon Sep 17 00:00:00 2001 From: Sixten Otto Date: Mon, 20 Feb 2023 11:52:03 -0700 Subject: [PATCH] fix some linter warnings on deliberate code --- .../App/AppExtensions/Share/Views/ShareExtensionView.swift | 2 +- apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift | 2 +- .../Sources/App/PDFSupport/PDFViewerViewModel.swift | 1 + .../Sources/App/Views/AudioPlayer/ExpandedPlayer.swift | 2 +- .../Sources/App/Views/Home/LibraryAddLinkView.swift | 1 - .../App/Views/Profile/PushNotificationDevicesView.swift | 1 - .../App/Views/Profile/PushNotificationSettingsView.swift | 1 - .../Sources/App/Views/WebReader/WebReaderContainer.swift | 2 +- .../Sources/App/Views/WebReader/WebReaderContent.swift | 2 +- apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift | 1 + .../Sources/Services/AudioSession/SpeechPlayerItem.swift | 2 +- .../Services/DataService/Mutations/CreateHighlight.swift | 1 + apple/OmnivoreKit/Sources/Utils/UserDefaultKeys.swift | 1 + apple/OmnivoreKit/Sources/Views/Article/OmnivoreWebView.swift | 4 ++++ 14 files changed, 14 insertions(+), 9 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift b/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift index 1dc41ba03..1aa17c4bc 100644 --- a/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift +++ b/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift @@ -4,7 +4,7 @@ import SwiftUI import Utils import Views -// swiftlint:disable:next type_body_length +// swiftlint:disable file_length type_body_length public struct ShareExtensionView: View { let extensionContext: NSExtensionContext? @StateObject var labelsViewModel = LabelsViewModel() diff --git a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift index 4958503ca..296f04d7b 100644 --- a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift +++ b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift @@ -2,7 +2,7 @@ import Combine import SwiftUI import Utils -// swiftlint:disable file_length +// swiftlint:disable file_length type_body_length #if os(iOS) import PSPDFKit import PSPDFKitUI diff --git a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift index 4b443aaed..b3b2f8fab 100644 --- a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift @@ -17,6 +17,7 @@ final class PDFViewerViewModel: ObservableObject { onComplete(pdfItem.highlights.map { $0.patch ?? "" }) } + // swiftlint:disable:next function_parameter_count func createHighlight( dataService: DataService, shortId: String, diff --git a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift index 08e997372..d888b04e3 100644 --- a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift @@ -1,11 +1,11 @@ #if os(iOS) - import Foundation import Models import Services import SwiftUI import Views + // swiftlint:disable file_length type_body_length public struct ExpandedPlayer: View { @EnvironmentObject var audioController: AudioController @Environment(\.colorScheme) private var colorScheme: ColorScheme diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/LibraryAddLinkView.swift b/apple/OmnivoreKit/Sources/App/Views/Home/LibraryAddLinkView.swift index 9298fe44e..5fb2822b4 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/LibraryAddLinkView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/LibraryAddLinkView.swift @@ -1,4 +1,3 @@ - import Introspect import Models import Services diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationDevicesView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationDevicesView.swift index a4743c16a..2e3346a00 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationDevicesView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationDevicesView.swift @@ -1,4 +1,3 @@ - import Models import Services import SwiftUI diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationSettingsView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationSettingsView.swift index 3ad069694..5ced54f95 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationSettingsView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/PushNotificationSettingsView.swift @@ -1,4 +1,3 @@ - import Models import Services import SwiftUI diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift index 744afb314..bd6a1cc26 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift @@ -6,7 +6,7 @@ import Utils import Views import WebKit -// swiftlint:disable:next type_body_length +// swiftlint:disable file_length type_body_length struct WebReaderContainerView: View { let item: LinkedItem diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift index 4d49d2806..548b1f7bf 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift @@ -101,7 +101,7 @@ struct WebReaderContent { """ } - // swiftlint:disable line_length + // swiftlint:disable line_length function_body_length static func emptyContent(isDark: Bool) -> String { let themeKey = isDark ? "Gray" : "LightGray" // let savedAt = "new Date(\(item.unwrappedSavedAt.timeIntervalSince1970 * 1000)).toISOString()" diff --git a/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift b/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift index f839d0561..937cc1631 100644 --- a/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift +++ b/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift @@ -203,6 +203,7 @@ public extension LinkedItem { return item } + // swiftlint:disable:next cyclomatic_complexity func update( inContext context: NSManagedObjectContext, newReadingProgress: Double? = nil, diff --git a/apple/OmnivoreKit/Sources/Services/AudioSession/SpeechPlayerItem.swift b/apple/OmnivoreKit/Sources/Services/AudioSession/SpeechPlayerItem.swift index 954fed78e..ac6d68a99 100644 --- a/apple/OmnivoreKit/Sources/Services/AudioSession/SpeechPlayerItem.swift +++ b/apple/OmnivoreKit/Sources/Services/AudioSession/SpeechPlayerItem.swift @@ -12,7 +12,7 @@ import Models // Somewhat based on: https://github.com/neekeetab/CachingPlayerItem/blob/master/CachingPlayerItem.swift class SpeechPlayerItem: AVPlayerItem { - let resourceLoaderDelegate = ResourceLoaderDelegate() + let resourceLoaderDelegate = ResourceLoaderDelegate() // swiftlint:disable:this weak_delegate let session: AudioController let speechItem: SpeechItem var speechMarks: [SpeechMark]? diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/CreateHighlight.swift b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/CreateHighlight.swift index 6ecca9f23..88555002d 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/CreateHighlight.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/CreateHighlight.swift @@ -4,6 +4,7 @@ import Models import SwiftGraphQL extension DataService { + // swiftlint:disable:next function_parameter_count public func createHighlight( shortId: String, highlightID: String, diff --git a/apple/OmnivoreKit/Sources/Utils/UserDefaultKeys.swift b/apple/OmnivoreKit/Sources/Utils/UserDefaultKeys.swift index 9549f5fc8..0f3c956cf 100644 --- a/apple/OmnivoreKit/Sources/Utils/UserDefaultKeys.swift +++ b/apple/OmnivoreKit/Sources/Utils/UserDefaultKeys.swift @@ -1,5 +1,6 @@ import Foundation +// swiftlint:disable identifier_name public enum UserDefaultKey: String { case preferredWebFont case preferredWebFontSize diff --git a/apple/OmnivoreKit/Sources/Views/Article/OmnivoreWebView.swift b/apple/OmnivoreKit/Sources/Views/Article/OmnivoreWebView.swift index 523f2515b..f840e46a7 100644 --- a/apple/OmnivoreKit/Sources/Views/Article/OmnivoreWebView.swift +++ b/apple/OmnivoreKit/Sources/Views/Article/OmnivoreWebView.swift @@ -1,6 +1,7 @@ import Models import Utils import WebKit +// swiftlint:disable file_length /// Describes actions that can be sent from the WebView back to native views. /// The names on the javascript side must match for an action to be handled. @@ -273,6 +274,7 @@ public final class OmnivoreWebView: WKWebView { true } + // swiftlint:disable:next cyclomatic_complexity override public func canPerformAction(_ action: Selector, withSender _: Any?) -> Bool { switch action { case #selector(annotateSelection): return true @@ -418,6 +420,7 @@ public enum WebViewDispatchEvent { case saveReadPosition var script: String { + // swiftlint:disable:next implicit_getter get throws { let propertyLine = try scriptPropertyLine return "var event = new Event('\(eventName)');\(propertyLine)document.dispatchEvent(event);" @@ -470,6 +473,7 @@ public enum WebViewDispatchEvent { } private var scriptPropertyLine: String { + // swiftlint:disable:next implicit_getter get throws { switch self { case let .handleFontContrastChange(isHighContrast: isHighContrast):