diff --git a/apple/OmnivoreKit/Sources/App/AppExtensions/Share/ExtensionSaveService.swift b/apple/OmnivoreKit/Sources/App/AppExtensions/Share/ExtensionSaveService.swift index c58d4f97d..4875e0ba6 100644 --- a/apple/OmnivoreKit/Sources/App/AppExtensions/Share/ExtensionSaveService.swift +++ b/apple/OmnivoreKit/Sources/App/AppExtensions/Share/ExtensionSaveService.swift @@ -18,7 +18,10 @@ class ExtensionSaveService { self.queue = OperationQueue() } - private func queueSaveOperation(_ pageScrape: PageScrapePayload, shareExtensionViewModel: ShareExtensionChildViewModel) { + private func queueSaveOperation( + _ pageScrape: PageScrapePayload, + shareExtensionViewModel: ShareExtensionChildViewModel + ) { ProcessInfo().performExpiringActivity(withReason: "app.omnivore.SaveActivity") { [self] expiring in guard !expiring else { self.queue.cancelAllOperations() @@ -85,6 +88,7 @@ class ExtensionSaveService { var queue: OperationQueue? var uploadTask: URLSessionTask? + // swiftlint:disable:next nesting enum State: Int { case created case started diff --git a/apple/OmnivoreKit/Sources/App/AppExtensions/Share/ShareExtensionScene.swift b/apple/OmnivoreKit/Sources/App/AppExtensions/Share/ShareExtensionScene.swift index 467d158f7..1b3225cfe 100644 --- a/apple/OmnivoreKit/Sources/App/AppExtensions/Share/ShareExtensionScene.swift +++ b/apple/OmnivoreKit/Sources/App/AppExtensions/Share/ShareExtensionScene.swift @@ -55,7 +55,12 @@ struct ShareExtensionView: View { var body: some View { ShareExtensionChildView( viewModel: childViewModel, - onAppearAction: { viewModel.savePage(extensionContext: extensionContext, shareExtensionViewModel: childViewModel) }, + onAppearAction: { + viewModel.savePage( + extensionContext: extensionContext, + shareExtensionViewModel: childViewModel + ) + }, readNowButtonAction: { viewModel.handleReadNowAction(requestId: $0, extensionContext: extensionContext) }, dismissButtonTappedAction: { _, _ in extensionContext?.completeRequest(returningItems: [], completionHandler: nil) diff --git a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift index d6217081c..28a8811ff 100644 --- a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift +++ b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewer.swift @@ -2,6 +2,7 @@ import Combine import SwiftUI import Utils +// swiftlint:disable file_length #if os(iOS) import PSPDFKit import PSPDFKitUI @@ -147,7 +148,7 @@ import Utils pdfStateObject.document = document pdfStateObject.coordinator = PDFViewCoordinator(document: document, viewModel: viewModel) } else { - errorMessage = "Unable to download PDF: \(pdfURL)" + errorMessage = "Unable to download PDF: \(pdfURL?.description ?? "")" } } } @@ -220,6 +221,7 @@ import Utils return result } + // swiftlint:disable:next function_body_length func highlightSelection(pageView: PDFPageView, selectedText: String, dataService: DataService) -> String { let highlightID = UUID().uuidString.lowercased() let quote = quoteFromSelectedText(selectedText) diff --git a/apple/OmnivoreKit/Sources/App/Services.swift b/apple/OmnivoreKit/Sources/App/Services.swift index cc394380f..b7b602c17 100644 --- a/apple/OmnivoreKit/Sources/App/Services.swift +++ b/apple/OmnivoreKit/Sources/App/Services.swift @@ -102,4 +102,5 @@ public final class Services { #endif // Command to simulate BG Task +// swiftlint:disable:next line_length // e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"app.omnivore.fetchLinkedItems"] diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 480e84012..bb53c910c 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -5,6 +5,7 @@ import UserNotifications import Utils import Views +// swiftlint:disable file_length #if os(iOS) private let enableGrid = UIDevice.isIPad || FeatureFlag.enableGridCardsOnPhone @@ -196,7 +197,10 @@ import Views } .padding(.horizontal) .sheet(isPresented: $showLabelsSheet) { - FilterByLabelsView(initiallySelected: viewModel.selectedLabels, initiallyNegated: viewModel.negatedLabels) { + FilterByLabelsView( + initiallySelected: viewModel.selectedLabels, + initiallyNegated: viewModel.negatedLabels + ) { self.viewModel.selectedLabels = $0 self.viewModel.negatedLabels = $1 } diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift index d2b47ab95..a16e2a307 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift @@ -73,6 +73,7 @@ import WebKit return webView } + // swiftlint:disable:next cyclomatic_complexity func updateUIView(_ webView: WKWebView, context: Context) { if annotationSaveTransactionID != context.coordinator.lastSavedAnnotationID { context.coordinator.lastSavedAnnotationID = annotationSaveTransactionID diff --git a/apple/OmnivoreKit/Sources/Models/LinkedItemFilter.swift b/apple/OmnivoreKit/Sources/Models/LinkedItemFilter.swift index c257b92ef..62669a63c 100644 --- a/apple/OmnivoreKit/Sources/Models/LinkedItemFilter.swift +++ b/apple/OmnivoreKit/Sources/Models/LinkedItemFilter.swift @@ -58,11 +58,17 @@ public extension LinkedItemFilter { return NSCompoundPredicate(andPredicateWithSubpredicates: [undeletedPredicate, notInArchivePredicate]) case .readlater: // non-archived or deleted items without the Newsletter label - let nonNewsletterLabelPredicate = NSPredicate(format: "NOT SUBQUERY(labels, $label, $label.name == \"Newsletter\") .@count > 0") - return NSCompoundPredicate(andPredicateWithSubpredicates: [undeletedPredicate, notInArchivePredicate, nonNewsletterLabelPredicate]) + let nonNewsletterLabelPredicate = NSPredicate( + format: "NOT SUBQUERY(labels, $label, $label.name == \"Newsletter\") .@count > 0" + ) + return NSCompoundPredicate(andPredicateWithSubpredicates: [ + undeletedPredicate, notInArchivePredicate, nonNewsletterLabelPredicate + ]) case .newsletters: // non-archived or deleted items with the Newsletter label - let newsletterLabelPredicate = NSPredicate(format: "SUBQUERY(labels, $label, $label.name == \"Newsletter\").@count > 0") + let newsletterLabelPredicate = NSPredicate( + format: "SUBQUERY(labels, $label, $label.name == \"Newsletter\").@count > 0" + ) return NSCompoundPredicate(andPredicateWithSubpredicates: [notInArchivePredicate, newsletterLabelPredicate]) case .all: // include everything undeleted diff --git a/apple/OmnivoreKit/Sources/Models/PageScrapePayload.swift b/apple/OmnivoreKit/Sources/Models/PageScrapePayload.swift index 106d425b4..1b997e82f 100644 --- a/apple/OmnivoreKit/Sources/Models/PageScrapePayload.swift +++ b/apple/OmnivoreKit/Sources/Models/PageScrapePayload.swift @@ -256,20 +256,7 @@ private extension PageScrapePayload { let localFile = UUID().uuidString.lowercased() + ".pdf" dest.appendPathComponent(localFile) do { - print("EXISTING PDF URL", url) - let attr = try? FileManager.default.attributesOfItem(atPath: url.path) - if let attr = attr { - print("EXISTING FILE SIZE", attr[.size]) - } - try FileManager.default.copyItem(at: url, to: dest) - print("COPIED TO URL", dest) - - let attr2 = try? FileManager.default.attributesOfItem(atPath: dest.path) - if let attr2 = attr2 { - print("COPIED FILE SIZE", attr2[.size]) - } - return PageScrapePayload(url: url.absoluteString, localUrl: dest) } catch { print("error copying file locally", error) diff --git a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift index a4426aaec..b35582b0d 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift @@ -122,6 +122,7 @@ public final class DataService: ObservableObject { return isFirstRunOfVersion || isFirstRunWithBuildNumber } + // swiftlint:disable:next function_body_length public func persistPageScrapePayload(_ pageScrape: PageScrapePayload, requestId: String) async throws { let normalizedURL = normalizeURL(pageScrape.url) diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/CreateLabelPublisher.swift b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/CreateLabelPublisher.swift index 8df8b0d4a..e053a8717 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/CreateLabelPublisher.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/CreateLabelPublisher.swift @@ -26,6 +26,7 @@ extension DataService { } } + // swiftlint:disable:next function_body_length func syncLabelCreation(label: InternalLinkedItemLabel) { enum MutationResult { case saved(label: InternalLinkedItemLabel) diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/DeleteSubscription.swift b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/DeleteSubscription.swift index d8bdf3289..e35a8bd69 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/DeleteSubscription.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/DeleteSubscription.swift @@ -13,7 +13,9 @@ public extension DataService { let selection = Selection { try $0.on( unsubscribeError: .init { .error(errorMessage: (try $0.errorCodes().first ?? .unauthorized).rawValue) }, - unsubscribeSuccess: .init { .success(id: try $0.subscription(selection: Selection.Subscription { try $0.id() })) } + unsubscribeSuccess: .init { + .success(id: try $0.subscription(selection: Selection.Subscription { try $0.id() })) + } ) } diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/MergeHighlight.swift b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/MergeHighlight.swift index 4f8eefc3f..798fcddd6 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/MergeHighlight.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/MergeHighlight.swift @@ -38,6 +38,7 @@ extension DataService { return internalHighlight.encoded() } + // swiftlint:disable:next function_body_length func syncHighlightMerge(highlight: InternalHighlight, articleId: String, overlapHighlightIdList: [String]) { enum MutationResult { case saved(highlight: InternalHighlight) diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SaveArticle.swift b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SaveArticle.swift index 69e7e511e..2c0766899 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SaveArticle.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SaveArticle.swift @@ -84,8 +84,11 @@ public extension Networker { } public extension DataService { - // swiftlint:disable:next line_length - func saveArticlePublisher(pageScrapePayload: PageScrapePayload, uploadFileId: String?) -> AnyPublisher { + // swiftlint:disable:next function_body_length + func saveArticlePublisher( + pageScrapePayload: PageScrapePayload, + uploadFileId: String? + ) -> AnyPublisher { enum MutationResult { case saved(created: Bool) case error(errorCode: Enums.CreateArticleErrorCode) diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SavePDF.swift b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SavePDF.swift index c5b53b58e..3e9d7787f 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SavePDF.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/SavePDF.swift @@ -11,6 +11,7 @@ public struct UploadFileRequestPayload { } public extension DataService { + // swiftlint:disable:next function_body_length func uploadFileRequest(id: String, url: String) async throws -> UploadFileRequestPayload { enum MutationResult { case success(payload: UploadFileRequestPayload) @@ -60,11 +61,7 @@ public extension DataService { switch payload.data { case let .success(payload): - if let urlString = payload.urlString, let url = URL(string: urlString) { - continuation.resume(returning: payload) - } else { - continuation.resume(throwing: SaveArticleError.unknown(description: "No upload URL")) - } + continuation.resume(returning: payload) case let .error(errorCode: errorCode): switch errorCode { case .unauthorized: @@ -85,12 +82,6 @@ public extension DataService { request.httpMethod = "PUT" request.addValue("application/pdf", forHTTPHeaderField: "content-type") - print("UPLOADING PDF", localPdfURL) - let attr = try? FileManager.default.attributesOfItem(atPath: localPdfURL.path) - if let attr = attr { - print("UPLOADING ATTR", attr[.size]) - } - return try await withCheckedThrowingContinuation { continuation in let task = networker.urlSession.uploadTask(with: request, fromFile: localPdfURL) { _, response, _ in if let httpResponse = response as? HTTPURLResponse, 200 ... 299 ~= httpResponse.statusCode { diff --git a/apple/OmnivoreKit/Sources/Services/DataService/SaveService.swift b/apple/OmnivoreKit/Sources/Services/DataService/SaveService.swift deleted file mode 100644 index 8b1378917..000000000 --- a/apple/OmnivoreKit/Sources/Services/DataService/SaveService.swift +++ /dev/null @@ -1 +0,0 @@ - diff --git a/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift b/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift index f4e267546..a7fe46e3b 100644 --- a/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift +++ b/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift @@ -31,7 +31,7 @@ struct InternalLinkedItem { if let contentReader = contentReader { return contentReader == "PDF" } - return (pageURLString ?? "").hasSuffix("pdf") + return pageURLString.hasSuffix("pdf") } func asManagedObject(inContext context: NSManagedObjectContext) -> LinkedItem { diff --git a/apple/OmnivoreKit/Sources/Views/Article/WebView.swift b/apple/OmnivoreKit/Sources/Views/Article/WebView.swift index 32ebc172e..62e6ebd76 100644 --- a/apple/OmnivoreKit/Sources/Views/Article/WebView.swift +++ b/apple/OmnivoreKit/Sources/Views/Article/WebView.swift @@ -40,7 +40,9 @@ public final class WebView: WKWebView { } public func updateMaxWidthPercentage() { - if let maxWidthPercentage = UserDefaults.standard.value(forKey: UserDefaultKey.preferredWebMaxWidthPercentage.rawValue) as? Int { + if let maxWidthPercentage = UserDefaults.standard.value( + forKey: UserDefaultKey.preferredWebMaxWidthPercentage.rawValue + ) as? Int { dispatchEvent(.updateMaxWidthPercentage(maxWidthPercentage: maxWidthPercentage)) } } diff --git a/apple/OmnivoreKit/Sources/Views/ShareExtensionView.swift b/apple/OmnivoreKit/Sources/Views/ShareExtensionView.swift index 8d6f4774d..bf5186771 100644 --- a/apple/OmnivoreKit/Sources/Views/ShareExtensionView.swift +++ b/apple/OmnivoreKit/Sources/Views/ShareExtensionView.swift @@ -46,7 +46,11 @@ struct CornerRadiusStyle: ViewModifier { var corners = UIRectCorner.allCorners func path(in rect: CGRect) -> Path { - let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius)) + let path = UIBezierPath( + roundedRect: rect, + byRoundingCorners: corners, + cornerRadii: CGSize(width: radius, height: radius) + ) return Path(path.cgPath) } } diff --git a/apple/OmnivoreKit/Tests/UtilsTests/UtilsTests.swift b/apple/OmnivoreKit/Tests/UtilsTests/UtilsTests.swift index 8439564aa..8034aa1b9 100644 --- a/apple/OmnivoreKit/Tests/UtilsTests/UtilsTests.swift +++ b/apple/OmnivoreKit/Tests/UtilsTests/UtilsTests.swift @@ -14,6 +14,7 @@ final class UtilsTests: XCTestCase { XCTAssertEqual(normalizeURL("https://omnivore.app/"), "https://omnivore.app") // utm_ removed + // swiftlint:disable:next line_length XCTAssertEqual(normalizeURL("https://omnivore.app/?aa=a&bb=b&utm_track=track&cc=c"), "https://omnivore.app?aa=a&bb=b&cc=c") // query params sorted