diff --git a/.claude/settings.local.json b/.claude/settings.local.json index b8b258661..205b61aae 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -68,7 +68,8 @@ "Bash(echo:*)", "Bash(done)", "Bash(# Show files touched by state restoration related commits echo \"\"=== Files changed in state restoration commits ===\"\" for commit in 04e98a47d 89b31858c d788af388 1d49b9328 236943f82 38d6b11c5 3be027699 16c66513c 1ef2aa162 6ce3bdadc 1954f5b65 55b7da75d 20b3bda94 4bf57afc1 e0074d70b 616b9deeb f6bca9ee8 ea6eedb86 380617920 d68106ac0 d30c62757 813f0706b 2ea00619c; do git diff-tree --no-commit-id --name-only -r \"\"$commit\"\" done)", - "Bash(swiftlint version:*)" + "Bash(swiftlint version:*)", + "Bash(swiftlint:*)" ], "deny": [], "ask": [] diff --git a/Mac/AppDefaults.swift b/Mac/AppDefaults.swift index 7315294be..b2ae98c1e 100644 --- a/Mac/AppDefaults.swift +++ b/Mac/AppDefaults.swift @@ -65,7 +65,7 @@ final class AppDefaults: Sendable { }() let isFirstRun: Bool = { - if UserDefaults.standard.object(forKey: Key.firstRunDate) as? Date != nil { + if UserDefaults.standard.object(forKey: Key.firstRunDate) is Date { return false } firstRunDate = Date() diff --git a/Mac/MainWindow/Detail/DetailContainerView.swift b/Mac/MainWindow/Detail/DetailContainerView.swift index f51ec96ef..f52a747b2 100644 --- a/Mac/MainWindow/Detail/DetailContainerView.swift +++ b/Mac/MainWindow/Detail/DetailContainerView.swift @@ -38,7 +38,7 @@ final class DetailContainerView: NSView { override func draw(_ dirtyRect: NSRect) { NSColor.controlBackgroundColor.set() - let r = NSIntersectionRect(dirtyRect, bounds) + let r = dirtyRect.intersection(bounds) r.fill() } } diff --git a/Mac/MainWindow/Detail/DetailWebViewController.swift b/Mac/MainWindow/Detail/DetailWebViewController.swift index 84dc41ce2..b002d48b6 100644 --- a/Mac/MainWindow/Detail/DetailWebViewController.swift +++ b/Mac/MainWindow/Detail/DetailWebViewController.swift @@ -68,7 +68,7 @@ final class DetailWebViewController: NSViewController { private var isShowingExtractedArticle: Bool { switch state { - case .extracted(_, _, _): + case .extracted: return true default: return false @@ -269,7 +269,7 @@ private extension DetailWebViewController { } func reloadHTMLMaintainingScrollPosition() { - fetchScrollInfo() { scrollInfo in + fetchScrollInfo { scrollInfo in self.windowScrollY = scrollInfo?.offsetY self.reloadHTML() } @@ -319,7 +319,7 @@ private extension DetailWebViewController { private func fetchScrollInfo(_ completion: @escaping (ScrollInfo?) -> Void) { let javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: document.body.scrollTop}; x" - webView.evaluateJavaScript(javascriptString) { (info, error) in + webView.evaluateJavaScript(javascriptString) { (info, _) in guard let info = info as? [String: Any] else { completion(nil) return diff --git a/Mac/MainWindow/IconView.swift b/Mac/MainWindow/IconView.swift index 6163fbb3c..0795d8025 100644 --- a/Mac/MainWindow/IconView.swift +++ b/Mac/MainWindow/IconView.swift @@ -79,7 +79,7 @@ final class IconView: NSView { } override func layout() { - resizeSubviews(withOldSize: NSZeroSize) + resizeSubviews(withOldSize: NSSize.zero) } override func resizeSubviews(withOldSize oldSize: NSSize) { @@ -106,7 +106,7 @@ private extension IconView { func rectForImageView() -> NSRect { guard !(iconImage?.isSymbol ?? false) else { - return NSMakeRect(0.0, 0.0, bounds.size.width, bounds.size.height) + return NSRect(x: 0.0, y: 0.0, width: bounds.size.width, height: bounds.size.height) } guard let image = iconImage?.image else { @@ -118,21 +118,21 @@ private extension IconView { if imageSize.height == imageSize.width { if imageSize.height >= viewSize.height * 0.75 { // Close enough to viewSize to scale up the image. - return NSMakeRect(0.0, 0.0, viewSize.width, viewSize.height) + return NSRect(x: 0.0, y: 0.0, width: viewSize.width, height: viewSize.height) } let offset = floor((viewSize.height - imageSize.height) / 2.0) - return NSMakeRect(offset, offset, imageSize.width, imageSize.height) + return NSRect(x: offset, y: offset, width: imageSize.width, height: imageSize.height) } else if imageSize.height > imageSize.width { let factor = viewSize.height / imageSize.height let width = imageSize.width * factor let originX = floor((viewSize.width - width) / 2.0) - return NSMakeRect(originX, 0.0, width, viewSize.height) + return NSRect(x: originX, y: 0.0, width: width, height: viewSize.height) } // Wider than tall: imageSize.width > imageSize.height let factor = viewSize.width / imageSize.width let height = imageSize.height * factor let originY = floor((viewSize.height - height) / 2.0) - return NSMakeRect(0.0, originY, viewSize.width, height) + return NSRect(x: 0.0, y: originY, width: viewSize.width, height: height) } } diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index 0fa9b8310..2dea53d48 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -336,7 +336,7 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations @IBAction func openArticleInBrowser(_ sender: Any?) { if let link = currentLink { Browser.open(link, invertPreference: NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false) - } + } } @IBAction func openInBrowser(_ sender: Any?) { @@ -443,7 +443,7 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations } @IBAction func markAllAsReadAndGoToNextUnread(_ sender: Any?) { - currentTimelineViewController?.markAllAsRead() { + currentTimelineViewController?.markAllAsRead { self.nextUnread(sender) } } @@ -980,7 +980,7 @@ private extension MainWindowController { let splitViewWidths: [Int] if let splitView = splitViewController?.splitView { - splitViewWidths = splitView.arrangedSubviews.map{ Int(floor($0.frame.width)) } + splitViewWidths = splitView.arrangedSubviews.map { Int(floor($0.frame.width)) } } else { splitViewWidths = [] } diff --git a/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift b/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift index 22ea6a6e9..f8ce19696 100644 --- a/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift +++ b/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift @@ -73,7 +73,7 @@ final class SidebarCell: NSTableCellView { }() private let faviconImageView = IconView() - private let unreadCountView = UnreadCountView(frame: NSZeroRect) + private let unreadCountView = UnreadCountView(frame: NSRect.zero) override var backgroundStyle: NSView.BackgroundStyle { didSet { @@ -100,7 +100,7 @@ final class SidebarCell: NSTableCellView { if let cellAppearance = cellAppearance { titleView.font = cellAppearance.textFieldFont } - resizeSubviews(withOldSize: NSZeroSize) + resizeSubviews(withOldSize: NSSize.zero) } override func resizeSubviews(withOldSize oldSize: NSSize) { diff --git a/Mac/MainWindow/Sidebar/Cell/SidebarCellLayout.swift b/Mac/MainWindow/Sidebar/Cell/SidebarCellLayout.swift index bee49702d..15d0adca4 100644 --- a/Mac/MainWindow/Sidebar/Cell/SidebarCellLayout.swift +++ b/Mac/MainWindow/Sidebar/Cell/SidebarCellLayout.swift @@ -17,7 +17,6 @@ import RSCore let unreadCountRect: CGRect init(appearance: SidebarCellAppearance, cellSize: NSSize, shouldShowImage: Bool, textField: NSTextField, unreadCountView: UnreadCountView) { - let bounds = NSRect(x: 0.0, y: 0.0, width: floor(cellSize.width), height: floor(cellSize.height)) var rFavicon = NSRect.zero @@ -31,7 +30,7 @@ import RSCore var rTextField = NSRect(x: 0.0, y: 0.0, width: textFieldSize.width, height: textFieldSize.height) if shouldShowImage { - rTextField.origin.x = NSMaxX(rFavicon) + appearance.imageMarginRight + rTextField.origin.x = rFavicon.maxX + appearance.imageMarginRight } rTextField = rTextField.centeredVertically(in: bounds) @@ -41,17 +40,17 @@ import RSCore var rUnread = NSRect.zero if !unreadCountIsHidden { rUnread.size = unreadCountSize - rUnread.origin.x = NSMaxX(bounds) - unreadCountSize.width + rUnread.origin.x = bounds.maxX - unreadCountSize.width rUnread = rUnread.centeredVertically(in: bounds) - let textFieldMaxX = NSMinX(rUnread) - appearance.unreadCountMarginLeft - if NSMaxX(rTextField) > textFieldMaxX { - rTextField.size.width = textFieldMaxX - NSMinX(rTextField) + let textFieldMaxX = rUnread.minX - appearance.unreadCountMarginLeft + if rTextField.maxX > textFieldMaxX { + rTextField.size.width = textFieldMaxX - rTextField.minX } } self.unreadCountRect = rUnread - if NSMaxX(rTextField) > NSMaxX(bounds) { - rTextField.size.width = NSMaxX(bounds) - NSMinX(rTextField) + if rTextField.maxX > bounds.maxX { + rTextField.size.width = bounds.maxX - rTextField.minX } self.titleRect = rTextField } diff --git a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift index 4031874cb..d31d264b3 100644 --- a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift +++ b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift @@ -64,7 +64,7 @@ import Account func outlineView(_ outlineView: NSOutlineView, validateDrop info: NSDraggingInfo, proposedItem item: Any?, proposedChildIndex index: Int) -> NSDragOperation { let draggedFolders = PasteboardFolder.pasteboardFolders(with: info.draggingPasteboard) let draggedFeeds = PasteboardFeed.pasteboardFeeds(with: info.draggingPasteboard) - if (draggedFolders == nil && draggedFeeds == nil) || (draggedFolders != nil && draggedFeeds != nil) { + if (draggedFolders == nil && draggedFeeds == nil) || (draggedFolders != nil && draggedFeeds != nil) { return SidebarOutlineDataSource.dragOperationNone } let parentNode = nodeForItem(item) @@ -100,7 +100,7 @@ import Account func outlineView(_ outlineView: NSOutlineView, acceptDrop info: NSDraggingInfo, item: Any?, childIndex index: Int) -> Bool { let draggedFolders = PasteboardFolder.pasteboardFolders(with: info.draggingPasteboard) let draggedFeeds = PasteboardFeed.pasteboardFeeds(with: info.draggingPasteboard) - if (draggedFolders == nil && draggedFeeds == nil) || (draggedFolders != nil && draggedFeeds != nil) { + if (draggedFolders == nil && draggedFeeds == nil) || (draggedFolders != nil && draggedFeeds != nil) { return false } let parentNode = nodeForItem(item) @@ -236,7 +236,7 @@ private extension SidebarOutlineDataSource { return localDragOperation(parentNode: parentNode, draggedFeeds) } - func localDragOperation(parentNode: Node, _ draggedFeeds: Set)-> NSDragOperation { + func localDragOperation(parentNode: Node, _ draggedFeeds: Set) -> NSDragOperation { guard let firstDraggedFeed = draggedFeeds.first else { return .move } if sameAccount(firstDraggedFeed, parentNode) { if NSApplication.shared.currentEvent?.modifierFlags.contains(.option) ?? false { diff --git a/Mac/MainWindow/Sidebar/SidebarViewController.swift b/Mac/MainWindow/Sidebar/SidebarViewController.swift index e0f77c879..1d1ed36f4 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController.swift @@ -339,7 +339,7 @@ extension Notification.Name { // MARK: - Navigation func canGoToNextUnread(wrappingToTop wrapping: Bool = false) -> Bool { - if let _ = nextSelectableRowWithUnreadArticle(wrappingToTop: wrapping) { + if nextSelectableRowWithUnreadArticle(wrappingToTop: wrapping) != nil { return true } return false @@ -857,7 +857,7 @@ private extension SidebarViewController { } func applyToAvailableCells(_ completion: (SidebarCell, Node) -> Void) { - outlineView.enumerateAvailableRowViews { (rowView: NSTableRowView, row: Int) -> Void in + outlineView.enumerateAvailableRowViews { (rowView: NSTableRowView, row: Int) in guard let cell = cellForRowView(rowView), let node = nodeForRow(row) else { return } diff --git a/Mac/MainWindow/Sidebar/UnreadCountView.swift b/Mac/MainWindow/Sidebar/UnreadCountView.swift index 25c63cd5a..f1042982f 100644 --- a/Mac/MainWindow/Sidebar/UnreadCountView.swift +++ b/Mac/MainWindow/Sidebar/UnreadCountView.swift @@ -46,11 +46,11 @@ final class UnreadCountView: NSView { } private var intrinsicContentSizeIsValid = false - private var _intrinsicContentSize = NSZeroSize + private var _intrinsicContentSize = NSSize.zero override var intrinsicContentSize: NSSize { if !intrinsicContentSizeIsValid { - var size = NSZeroSize + var size = NSSize.zero if unreadCount > 0 { size = textSize() size.width += (Appearance.padding.left + Appearance.padding.right) @@ -74,7 +74,7 @@ final class UnreadCountView: NSView { private func textSize() -> NSSize { if unreadCount < 1 { - return NSZeroSize + return NSSize.zero } if let cachedSize = UnreadCountView.textSizeCache[unreadCount] { @@ -91,9 +91,9 @@ final class UnreadCountView: NSView { private func textRect() -> NSRect { let size = textSize() - var r = NSZeroRect + var r = NSRect.zero r.size = size - r.origin.x = (NSMaxX(bounds) - Appearance.padding.right) - r.size.width + r.origin.x = (bounds.maxX - Appearance.padding.right) - r.size.width r.origin.y = Appearance.padding.top return r } diff --git a/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift b/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift index fd28bfaa9..8ce8e3ac9 100644 --- a/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift +++ b/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift @@ -122,13 +122,13 @@ import RSCore return (r, sizeInfo.numberOfLinesUsed) } - static func rectForSummary(_ textBoxRect: NSRect, _ titleRect: NSRect, _ titleNumberOfLines: Int, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect { + static func rectForSummary(_ textBoxRect: NSRect, _ titleRect: NSRect, _ titleNumberOfLines: Int, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect { if titleNumberOfLines >= appearance.titleNumberOfLines || cellData.text.isEmpty { return NSRect.zero } var r = textBoxRect - r.origin.y = NSMaxY(titleRect) + r.origin.y = titleRect.maxY let summaryNumberOfLines = appearance.titleNumberOfLines - titleNumberOfLines let sizeInfo = MultilineTextFieldSizer.size(for: cellData.text, font: appearance.textOnlyFont, numberOfLines: summaryNumberOfLines, width: Int(textBoxRect.width)) @@ -159,9 +159,9 @@ import RSCore static func rectForDate(_ textBoxRect: NSRect, _ rectAbove: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect { let textFieldSize = SingleLineTextFieldSizer.size(for: cellData.dateString, font: appearance.dateFont) - var r = NSZeroRect + var r = NSRect.zero r.size = textFieldSize - r.origin.y = NSMaxY(rectAbove) + appearance.titleBottomMargin + r.origin.y = rectAbove.maxY + appearance.titleBottomMargin r.size.width = textFieldSize.width r.origin.x = textBoxRect.maxX - textFieldSize.width @@ -171,11 +171,11 @@ import RSCore static func rectForFeedName(_ textBoxRect: NSRect, _ dateRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect { if cellData.showFeedName == .none { - return NSZeroRect + return NSRect.zero } let textFieldSize = SingleLineTextFieldSizer.size(for: cellData.feedName, font: appearance.feedNameFont) - var r = NSZeroRect + var r = NSRect.zero r.size = textFieldSize r.origin.y = dateRect.minY r.origin.x = textBoxRect.origin.x @@ -186,7 +186,7 @@ import RSCore static func rectForUnreadIndicator(_ appearance: TimelineCellAppearance, _ titleRect: NSRect) -> NSRect { - var r = NSZeroRect + var r = NSRect.zero r.size = NSSize(width: appearance.unreadCircleDimension, height: appearance.unreadCircleDimension) r.origin.x = appearance.cellPadding.left r.origin.y = titleRect.minY + 6 diff --git a/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift b/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift index 0c2ed3618..89c10788d 100644 --- a/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift +++ b/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift @@ -14,7 +14,7 @@ final class TimelineTableCellView: NSTableCellView { private let titleView = TimelineTableCellView.multiLineTextField() private let summaryView = TimelineTableCellView.multiLineTextField() private let textView = TimelineTableCellView.multiLineTextField() - private let unreadIndicatorView = UnreadIndicatorView(frame: NSZeroRect) + private let unreadIndicatorView = UnreadIndicatorView(frame: NSRect.zero) private let dateView = TimelineTableCellView.singleLineTextField() private let feedNameView = TimelineTableCellView.singleLineTextField() @@ -91,7 +91,7 @@ final class TimelineTableCellView: NSTableCellView { override func layout() { - resizeSubviews(withOldSize: NSZeroSize) + resizeSubviews(withOldSize: NSSize.zero) } override func resizeSubviews(withOldSize oldSize: NSSize) { @@ -299,7 +299,11 @@ private extension TimelineTableCellView { } func showOrHideView(_ view: NSView, _ shouldHide: Bool) { - shouldHide ? hideView(view) : showView(view) + if shouldHide { + hideView(view) + } else { + showView(view) + } } func updateSubviews() { diff --git a/Mac/MainWindow/Timeline/TimelineContainerViewController.swift b/Mac/MainWindow/Timeline/TimelineContainerViewController.swift index 054d140a7..e581ea199 100644 --- a/Mac/MainWindow/Timeline/TimelineContainerViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineContainerViewController.swift @@ -114,7 +114,7 @@ final class TimelineContainerViewController: NSViewController { return false } for object in representedObjects { - guard let _ = currentObjects.firstIndex(where: { $0 === object } ) else { + if currentObjects.firstIndex(where: { $0 === object }) == nil { return false } } diff --git a/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift b/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift index 9f9fb92de..c7db48812 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift @@ -248,11 +248,11 @@ private extension TimelineViewController { } func markAboveReadMenuItem(_ articles: [Article]) -> NSMenuItem { - return menuItem(NSLocalizedString("Mark Above as Read", comment: "Command"), #selector(markAboveArticlesReadFromContextualMenu(_:)), articles, image: Assets.Images.markAboveAsRead) + return menuItem(NSLocalizedString("Mark Above as Read", comment: "Command"), #selector(markAboveArticlesReadFromContextualMenu(_:)), articles, image: Assets.Images.markAboveAsRead) } func markBelowReadMenuItem(_ articles: [Article]) -> NSMenuItem { - return menuItem(NSLocalizedString("Mark Below as Read", comment: "Command"), #selector(markBelowArticlesReadFromContextualMenu(_:)), articles, image: Assets.Images.markBelowAsRead) + return menuItem(NSLocalizedString("Mark Below as Read", comment: "Command"), #selector(markBelowArticlesReadFromContextualMenu(_:)), articles, image: Assets.Images.markBelowAsRead) } func selectFeedInSidebarMenuItem(_ feed: Feed) -> NSMenuItem { diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index a75f7dfbd..e03d09d69 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -12,7 +12,7 @@ import Articles import Account import os.log -@MainActor protocol TimelineDelegate: AnyObject { +@MainActor protocol TimelineDelegate: AnyObject { func timelineSelectionDidChange(_: TimelineViewController, selectedArticles: [Article]?) func timelineRequestedFeedSelection(_: TimelineViewController, feed: Feed) func timelineInvalidatedRestorationState(_: TimelineViewController) @@ -631,10 +631,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr } func canGoToNextUnread(wrappingToTop wrapping: Bool = false) -> Bool { - guard let _ = indexOfNextUnreadArticle(wrappingToTop: wrapping) else { - return false - } - return true + return indexOfNextUnreadArticle(wrappingToTop: wrapping) != nil } func indexOfNextUnreadArticle(wrappingToTop wrapping: Bool = false) -> Int? { @@ -994,26 +991,26 @@ extension TimelineViewController: NSTableViewDelegate { switch edge { case .leading: - let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (action, row) in + let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (_, _) in self.toggleArticleRead(article) tableView.rowActionsVisible = false } action.image = article.status.read ? Assets.Images.swipeMarkUnread : Assets.Images.swipeMarkRead return [action] - + case .trailing: - let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (action, row) in + let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (_, _) in self.toggleArticleStarred(article) tableView.rowActionsVisible = false } action.backgroundColor = Assets.Colors.star action.image = article.status.starred ? Assets.Images.swipeMarkUnstarred : Assets.Images.swipeMarkStarred return [action] - + @unknown default: Self.logger.error("TimelineViewController: unknown edge \(edge.rawValue, privacy: .public)") } - + return [] } } @@ -1218,7 +1215,7 @@ private extension TimelineViewController { func fetchUnsortedArticlesSync(for representedObjects: [Any]) -> Set
{ cancelPendingAsyncFetches() - let fetchers = representedObjects.compactMap{ $0 as? ArticleFetcher } + let fetchers = representedObjects.compactMap { $0 as? ArticleFetcher } if fetchers.isEmpty { return Set
() } diff --git a/Mac/Preferences/PreferencesControlsBackgroundView.swift b/Mac/Preferences/PreferencesControlsBackgroundView.swift index 5625f3d3d..f5b59ad0e 100644 --- a/Mac/Preferences/PreferencesControlsBackgroundView.swift +++ b/Mac/Preferences/PreferencesControlsBackgroundView.swift @@ -29,7 +29,7 @@ final class PreferencesControlsBackgroundView: NSView { let fillColor = self.effectiveAppearance.isDarkMode ? darkModeFillColor : lightModeFillColor fillColor.setFill() - let r = NSIntersectionRect(dirtyRect, bounds) + let r = dirtyRect.intersection(bounds) r.fill() let borderColor = self.effectiveAppearance.isDarkMode ? darkModeBorderColor : lightModeBorderColor diff --git a/Mac/Preferences/PreferencesTableViewBackgroundView.swift b/Mac/Preferences/PreferencesTableViewBackgroundView.swift index 21839a895..6450f242c 100644 --- a/Mac/Preferences/PreferencesTableViewBackgroundView.swift +++ b/Mac/Preferences/PreferencesTableViewBackgroundView.swift @@ -17,7 +17,7 @@ final class PreferencesTableViewBackgroundView: NSView { let color = self.effectiveAppearance.isDarkMode ? darkBorderColor : lightBorderColor color.setFill() - let r = NSIntersectionRect(dirtyRect, bounds) + let r = dirtyRect.intersection(bounds) r.fill() } } diff --git a/Mac/Preferences/PreferencesWindowController.swift b/Mac/Preferences/PreferencesWindowController.swift index 19081bcf7..5dcb8f361 100644 --- a/Mac/Preferences/PreferencesWindowController.swift +++ b/Mac/Preferences/PreferencesWindowController.swift @@ -167,9 +167,9 @@ private extension PreferencesWindowController { let windowFrame = window!.frame let contentViewFrame = window!.contentView!.frame - let deltaHeight = NSHeight(contentViewFrame) - NSHeight(viewFrame) - let heightForWindow = NSHeight(windowFrame) - deltaHeight - let windowOriginY = NSMinY(windowFrame) + deltaHeight + let deltaHeight = contentViewFrame.height - viewFrame.height + let heightForWindow = windowFrame.height - deltaHeight + let windowOriginY = windowFrame.minY + deltaHeight var updatedWindowFrame = windowFrame updatedWindowFrame.size.height = heightForWindow @@ -177,7 +177,7 @@ private extension PreferencesWindowController { updatedWindowFrame.size.width = windowWidth // NSWidth(viewFrame) var updatedViewFrame = viewFrame - updatedViewFrame.origin = NSZeroPoint + updatedViewFrame.origin = NSPoint.zero updatedViewFrame.size.width = windowWidth if viewFrame != updatedViewFrame { view.frame = updatedViewFrame diff --git a/Mac/SafariExtension/SafariExtensionHandler.swift b/Mac/SafariExtension/SafariExtensionHandler.swift index fc0944b11..95d079e7f 100644 --- a/Mac/SafariExtension/SafariExtensionHandler.swift +++ b/Mac/SafariExtension/SafariExtensionHandler.swift @@ -29,7 +29,7 @@ final class SafariExtensionHandler: SFSafariExtensionHandler { } // Maps from UUID to a validation wrapper - nonisolated(unsafe) static var gPingPongMap = Dictionary() + nonisolated(unsafe) static var gPingPongMap = [String: ValidationWrapper]() static let validationQueue = DispatchQueue(label: "Toolbar Validation") // Bottleneck for calling through to a validation handler we have saved, and removing it from the list. diff --git a/Mac/Scripting/Account+Scriptability.swift b/Mac/Scripting/Account+Scriptability.swift index d8a9f24ec..11116ad84 100644 --- a/Mac/Scripting/Account+Scriptability.swift +++ b/Mac/Scripting/Account+Scriptability.swift @@ -93,7 +93,7 @@ import RSCore // MARK: --- Scriptable elements --- @objc(feeds) - var feeds: NSArray { + var feeds: NSArray { account.topLevelFeeds.map { ScriptableFeed($0, container: self) } as NSArray } @@ -129,7 +129,7 @@ import RSCore } @objc(folders) - var folders: NSArray { + var folders: NSArray { let foldersSet = account.folders ?? Set() let folders = Array(foldersSet) return folders.map { ScriptableFolder($0, container: self) } as NSArray @@ -164,7 +164,7 @@ import RSCore // MARK: --- Scriptable properties --- @objc(allFeeds) - var allFeeds: NSArray { + var allFeeds: NSArray { let allFeeds = account.flattenedFeeds() let scriptableFeeds = allFeeds.map { feed in ScriptableFeed(feed, container: self) @@ -204,7 +204,7 @@ import RSCore } @objc(opmlRepresentation) - var opmlRepresentation: String { + var opmlRepresentation: String { self.account.OPMLString(indentLevel: 0) } diff --git a/Mac/Scripting/AppDelegate+Scriptability.swift b/Mac/Scripting/AppDelegate+Scriptability.swift index 9b17bd08d..d48d78c93 100644 --- a/Mac/Scripting/AppDelegate+Scriptability.swift +++ b/Mac/Scripting/AppDelegate+Scriptability.swift @@ -25,8 +25,8 @@ import Articles } @MainActor protocol ScriptingAppDelegate { - var scriptingCurrentArticle: Article? {get} - var scriptingSelectedArticles: [Article] {get} + var scriptingCurrentArticle: Article? {get} + var scriptingSelectedArticles: [Article] {get} var scriptingMainWindowController: ScriptingMainWindowController? {get} } @@ -60,7 +60,7 @@ extension AppDelegate: AppDelegateAppleEvents { if let themeURL = URL(string: themeURLString) { let request = URLRequest(url: themeURL) - let task = URLSession.shared.downloadTask(with: request) { location, response, error in + let task = URLSession.shared.downloadTask(with: request) { location, _, error in guard let location = location else { return } @@ -105,9 +105,9 @@ final class NetNewsWireCreateElementCommand: NSCreateCommand { let instance = unsafeSelf.value let classDescription: NSScriptClassDescription = instance.createClassDescription let command: NSCreateCommand = instance - if (classDescription.className == "feed") { + if classDescription.className == "feed" { return UnsafeSendable(value: ScriptableFeed.handleCreateElement(command: command)) - } else if (classDescription.className == "folder") { + } else if classDescription.className == "folder" { return UnsafeSendable(value: ScriptableFolder.handleCreateElement(command: command)) } return UnsafeSendable(value: nil) @@ -197,7 +197,7 @@ final class NetNewsWireExistsCommand: NSExistsCommand { override func performDefaultImplementation() -> Any? { guard let result = super.performDefaultImplementation() else { - return NSNumber(booleanLiteral: false) + return false as NSNumber } return result } diff --git a/Mac/Scripting/Article+Scriptability.swift b/Mac/Scripting/Article+Scriptability.swift index 91b83272e..d47ca8a20 100644 --- a/Mac/Scripting/Article+Scriptability.swift +++ b/Mac/Scripting/Article+Scriptability.swift @@ -49,63 +49,63 @@ import Articles } func deleteElement(_ element: ScriptingObject) { - print ("delete event not handled") + print("delete event not handled") } // MARK: - Scriptable properties @objc(url) - var url: String? { + var url: String? { article.preferredLink } @objc(permalink) - var permalink: String? { + var permalink: String? { article.link } @objc(externalUrl) - var externalUrl: String? { + var externalUrl: String? { article.externalLink } @objc(title) - var title: String { + var title: String { article.title ?? "" } @objc(contents) - var contents: String { + var contents: String { article.contentText ?? "" } @objc(html) - var html: String { + var html: String { article.contentHTML ?? "" } @objc(summary) - var summary: String { + var summary: String { article.summary ?? "" } @objc(datePublished) - var datePublished: Date? { + var datePublished: Date? { article.datePublished } @objc(dateModified) - var dateModified: Date? { + var dateModified: Date? { article.dateModified } @objc(dateArrived) - var dateArrived: Date { + var dateArrived: Date { article.status.dateArrived } @objc(read) - var read: Bool { + var read: Bool { get { article.status.boolStatus(forKey: .read) } @@ -115,7 +115,7 @@ import Articles } @objc(starred) - var starred: Bool { + var starred: Bool { get { article.status.boolStatus(forKey: .starred) } @@ -125,12 +125,12 @@ import Articles } @objc(deleted) - var deleted: Bool { + var deleted: Bool { false } @objc(imageURL) - var imageURL: String { + var imageURL: String { article.imageLink ?? "" } diff --git a/Mac/Scripting/Author+Scriptability.swift b/Mac/Scripting/Author+Scriptability.swift index dd20cf4f7..597dacdfb 100644 --- a/Mac/Scripting/Author+Scriptability.swift +++ b/Mac/Scripting/Author+Scriptability.swift @@ -47,22 +47,22 @@ import Articles // MARK: - Scriptable properties @objc(url) - var url: String { + var url: String { author.url ?? "" } @objc(name) - var name: String { + var name: String { author.name ?? "" } @objc(avatarURL) - var avatarURL: String { + var avatarURL: String { author.avatarURL ?? "" } @objc(emailAddress) - var emailAddress: String { + var emailAddress: String { author.emailAddress ?? "" } } diff --git a/Mac/Scripting/Folder+Scriptability.swift b/Mac/Scripting/Folder+Scriptability.swift index 58e1cb5b3..7dcaf9896 100644 --- a/Mac/Scripting/Folder+Scriptability.swift +++ b/Mac/Scripting/Folder+Scriptability.swift @@ -64,7 +64,7 @@ import RSCore or tell account X to make new folder at end with properties {name:"new folder name"} */ - static func handleCreateElement(command: NSCreateCommand) -> Any? { + static func handleCreateElement(command: NSCreateCommand) -> Any? { guard command.isCreateCommand(forClass: "fold") else { return nil } @@ -97,7 +97,7 @@ import RSCore // MARK: - Scriptable elements @objc(feeds) - var feeds: NSArray { + var feeds: NSArray { let feeds = Array(folder.topLevelFeeds) return feeds.map { ScriptableFeed($0, container: self) } as NSArray } @@ -142,7 +142,7 @@ import RSCore // MARK: - Scriptable properties @objc(name) - var name: String { + var name: String { folder.name ?? "" } diff --git a/Mac/Scripting/NSApplication+Scriptability.swift b/Mac/Scripting/NSApplication+Scriptability.swift index e745f342d..363ebdb54 100644 --- a/Mac/Scripting/NSApplication+Scriptability.swift +++ b/Mac/Scripting/NSApplication+Scriptability.swift @@ -18,7 +18,7 @@ extension NSApplication: @preconcurrency ScriptingObjectContainer { } func deleteElement(_ element: ScriptingObject) { - print ("delete event not handled") + print("delete event not handled") } nonisolated var scriptingKey: String { @@ -136,7 +136,7 @@ extension NSApplication: @preconcurrency ScriptingObjectContainer { @objc(valueInFeedsWithUniqueID:) func valueInFeeds(withUniqueID id: String) -> ScriptableFeed? { let feeds = allFeeds() - guard let feed = feeds.first(where: { $0.feedID == id} ) else { + guard let feed = feeds.first(where: { $0.feedID == id}) else { return nil } return ScriptableFeed(feed, container: self) diff --git a/Mac/Scripting/NSScriptCommand+NetNewsWire.swift b/Mac/Scripting/NSScriptCommand+NetNewsWire.swift index 46e7f6952..caa7f389a 100644 --- a/Mac/Scripting/NSScriptCommand+NetNewsWire.swift +++ b/Mac/Scripting/NSScriptCommand+NetNewsWire.swift @@ -11,9 +11,9 @@ import Account @MainActor extension NSScriptCommand { func property(forKey key: String) -> Any? { - if let evaluatedArguments = self.evaluatedArguments { + if let evaluatedArguments = self.evaluatedArguments { if let props = evaluatedArguments["KeyDictionary"] as? [String: Any] { - return props[key] + return props[key] } } return nil @@ -26,7 +26,7 @@ import Account guard let newObjectClass = arguments["ObjectClass"] as? Int else { return false } - guard (newObjectClass.fourCharCode == whatClass.fourCharCode) else { + guard newObjectClass.fourCharCode == whatClass.fourCharCode else { return false } return true @@ -42,9 +42,9 @@ import Account print("insertionLocation : \(insertionLocationDescriptor)") // insertion location can be a typeObjectSpecifier, e.g. 'in account "Acct"' // or a typeInsertionLocation, e.g. 'at end of folder " - if (insertionLocationDescriptor.descriptorType == "insl".fourCharCode) { + if insertionLocationDescriptor.descriptorType == "insl".fourCharCode { descriptorToConsider = insertionLocationDescriptor.forKeyword("kobj".fourCharCode) - } else if ( insertionLocationDescriptor.descriptorType == "obj ".fourCharCode) { + } else if insertionLocationDescriptor.descriptorType == "obj ".fourCharCode { descriptorToConsider = insertionLocationDescriptor } } else if let subjectDescriptor = appleEvent.attributeDescriptor(forKeyword: "subj".fourCharCode) { diff --git a/Mac/Scripting/ScriptingObject.swift b/Mac/Scripting/ScriptingObject.swift index 6952b0d30..f71fc36e6 100644 --- a/Mac/Scripting/ScriptingObject.swift +++ b/Mac/Scripting/ScriptingObject.swift @@ -9,7 +9,7 @@ import Foundation protocol ScriptingObject { - var objectSpecifier: NSScriptObjectSpecifier? { get } + var objectSpecifier: NSScriptObjectSpecifier? { get } var scriptingKey: String { get } } diff --git a/Modules/Account/Package.swift b/Modules/Account/Package.swift index 259e8bce2..21baad4a5 100644 --- a/Modules/Account/Package.swift +++ b/Modules/Account/Package.swift @@ -8,7 +8,7 @@ let package = Package( .library( name: "Account", type: .dynamic, - targets: ["Account"]), + targets: ["Account"]) ], dependencies: [ .package(path: "../Articles"), @@ -41,16 +41,16 @@ let package = Package( ], swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), - .enableUpcomingFeature("InferIsolatedConformances"), + .enableUpcomingFeature("InferIsolatedConformances") ] ), .testTarget( name: "AccountTests", dependencies: ["Account"], resources: [ - .copy("JSON"), + .copy("JSON") ], swiftSettings: [.swiftLanguageMode(.v6)] - ), + ) ] ) diff --git a/Modules/Account/Sources/Account/Account.swift b/Modules/Account/Sources/Account/Account.swift index c810dd3e1..cd54e2652 100644 --- a/Modules/Account/Sources/Account/Account.swift +++ b/Modules/Account/Sources/Account/Account.swift @@ -378,10 +378,10 @@ public enum FetchType { } public static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse, - client: OAuthAuthorizationClient, - accountType: AccountType, - transport: Transport = URLSession.webserviceTransport(), - completion: @escaping @MainActor (Result) -> Void) { + client: OAuthAuthorizationClient, + accountType: AccountType, + transport: Transport = URLSession.webserviceTransport(), + completion: @escaping @MainActor (Result) -> Void) { let grantingType: OAuthAuthorizationGranting.Type switch accountType { diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitArticlesZoneDelegate.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitArticlesZoneDelegate.swift index 5ebb0c254..cf4337390 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitArticlesZoneDelegate.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitArticlesZoneDelegate.swift @@ -77,7 +77,7 @@ private extension CloudKitArticlesZoneDelegate { // Parse items on background thread let feedIDsAndItems = await Task.detached(priority: .userInitiated) { let parsedItems = records.compactMap { makeParsedItem($0) } - return Dictionary(grouping: parsedItems, by: { item in item.feedURL } ).mapValues { Set($0) } + return Dictionary(grouping: parsedItems, by: { item in item.feedURL }).mapValues { Set($0) } }.value nonisolated(unsafe) var updateError: Error? diff --git a/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift b/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift index bcea1a1af..6376699f0 100644 --- a/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift @@ -644,11 +644,11 @@ private extension FeedbinAccountDelegate { for articleIDGroup in articleIDGroups { do { try await apiCall(articleIDGroup) - try? await self.syncDatabase.deleteSelectedForProcessing(Set(articleIDGroup.map { String($0) } )) + try? await self.syncDatabase.deleteSelectedForProcessing(Set(articleIDGroup.map { String($0) })) } catch { savedError = error Self.logger.error("Feedbin: Article status sync call failed: \(error.localizedDescription)") - try? await self.syncDatabase.resetSelectedForProcessing(Set(articleIDGroup.map { String($0) } )) + try? await self.syncDatabase.resetSelectedForProcessing(Set(articleIDGroup.map { String($0) })) } } @@ -799,7 +799,7 @@ private extension FeedbinAccountDelegate { func processEntries(account: Account, entries: [FeedbinEntry]?) async throws { let parsedItems = mapEntriesToParsedItems(entries: entries) - let feedIDsAndItems = Dictionary(grouping: parsedItems, by: { item in item.feedURL } ).mapValues { Set($0) } + let feedIDsAndItems = Dictionary(grouping: parsedItems, by: { item in item.feedURL }).mapValues { Set($0) } try await account.updateAsync(feedIDsAndItems: feedIDsAndItems, defaultRead: true) } @@ -827,7 +827,7 @@ private extension FeedbinAccountDelegate { return } - let feedbinUnreadArticleIDs = Set(articleIDs.map { String($0) } ) + let feedbinUnreadArticleIDs = Set(articleIDs.map { String($0) }) let updatableFeedbinUnreadArticleIDs = feedbinUnreadArticleIDs.subtracting(pendingArticleIDs) let currentUnreadArticleIDs = try await account.fetchUnreadArticleIDsAsync() @@ -854,7 +854,7 @@ private extension FeedbinAccountDelegate { return } - let feedbinStarredArticleIDs = Set(articleIDs.map { String($0) } ) + let feedbinStarredArticleIDs = Set(articleIDs.map { String($0) }) let updatableFeedbinStarredArticleIDs = feedbinStarredArticleIDs.subtracting(pendingArticleIDs) let currentStarredArticleIDs = try await account.fetchStarredArticleIDsAsync() diff --git a/Modules/Account/Sources/Account/Folder.swift b/Modules/Account/Sources/Account/Folder.swift index d9c5a7d6a..1e12db214 100644 --- a/Modules/Account/Sources/Account/Folder.swift +++ b/Modules/Account/Sources/Account/Folder.swift @@ -213,7 +213,7 @@ extension Folder: OPMLRepresentable { @MainActor extension Set where Element == Folder { - func sorted() -> Array { + func sorted() -> [Folder] { return sorted(by: { (folder1, folder2) -> Bool in return folder1.nameForDisplay.localizedStandardCompare(folder2.nameForDisplay) == .orderedAscending }) diff --git a/Modules/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift b/Modules/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift index 0b09a2474..58c55b0dc 100644 --- a/Modules/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift +++ b/Modules/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift @@ -293,7 +293,7 @@ import os.log return } - let newsBlurUnreadStoryHashes = Set(hashes.map { $0.hash } ) + let newsBlurUnreadStoryHashes = Set(hashes.map { $0.hash }) let updatableNewsBlurUnreadStoryHashes = newsBlurUnreadStoryHashes.subtracting(pendingStoryHashes) let currentUnreadArticleIDs = try await account.fetchUnreadArticleIDsAsync() @@ -320,7 +320,7 @@ import os.log return } - let newsBlurStarredStoryHashes = Set(hashes.map { $0.hash } ) + let newsBlurStarredStoryHashes = Set(hashes.map { $0.hash }) let updatableNewsBlurUnreadStoryHashes = newsBlurStarredStoryHashes.subtracting(pendingStoryHashes) let currentStarredArticleIDs = try await account.fetchStarredArticleIDsAsync() diff --git a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift index 3ece4589a..a4e1156c5 100644 --- a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift +++ b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift @@ -774,7 +774,7 @@ private extension ReaderAPIAccountDelegate { func processEntries(account: Account, entries: [ReaderAPIEntry]?) async { let parsedItems = mapEntriesToParsedItems(account: account, entries: entries) - let feedIDsAndItems = Dictionary(grouping: parsedItems, by: { item in item.feedURL } ).mapValues { Set($0) } + let feedIDsAndItems = Dictionary(grouping: parsedItems, by: { item in item.feedURL }).mapValues { Set($0) } try? await account.updateAsync(feedIDsAndItems: feedIDsAndItems, defaultRead: true) } diff --git a/Modules/Account/Sources/Account/URLRequest+Account.swift b/Modules/Account/Sources/Account/URLRequest+Account.swift index 0ebada65b..fdbf56936 100755 --- a/Modules/Account/Sources/Account/URLRequest+Account.swift +++ b/Modules/Account/Sources/Account/URLRequest+Account.swift @@ -55,14 +55,12 @@ public extension URLRequest { setValue(auth, forHTTPHeaderField: "Authorization") case .oauthAccessTokenSecret: assertionFailure("Token secrets are used by OAuth1. Did you mean to use `OAuthSwift` instead of a URLRequest?") - break case .oauthRefreshToken: // While both access and refresh tokens are credentials, it seems the `Credentials` cases // enumerates how the identity of the user can be proved rather than // credentials-in-general, such as in this refresh token case, // the authority to prove an identity. assertionFailure("Refresh tokens are used to replace expired access tokens. Did you mean to use `accessToken` instead?") - break } guard let conditionalGet = conditionalGet else { diff --git a/Modules/Articles/Package.swift b/Modules/Articles/Package.swift index 1f271b649..e05bf078b 100644 --- a/Modules/Articles/Package.swift +++ b/Modules/Articles/Package.swift @@ -8,10 +8,10 @@ let package = Package( .library( name: "Articles", type: .dynamic, - targets: ["Articles"]), + targets: ["Articles"]) ], dependencies: [ - .package(path: "../RSCore"), + .package(path: "../RSCore") ], targets: [ .target( @@ -21,7 +21,7 @@ let package = Package( ], swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), - .enableUpcomingFeature("InferIsolatedConformances"), - ]), + .enableUpcomingFeature("InferIsolatedConformances") + ]) ] ) diff --git a/Modules/Articles/Sources/Articles/Article.swift b/Modules/Articles/Sources/Articles/Article.swift index ac10958e9..44c417579 100644 --- a/Modules/Articles/Sources/Articles/Article.swift +++ b/Modules/Articles/Sources/Articles/Article.swift @@ -110,13 +110,21 @@ public extension Article { result.append(text) } - if let _ = scanner.scanString("<") { + if scanner.scanString("<") != nil { // All the allowed tags currently don't allow attributes if let tag = scanner.scanUpToString(">") { if Self.allowedTags.contains(tag.replacingOccurrences(of: "/", with: "")) { - forHTML ? result.append("<\(tag)>") : result.append("") + if forHTML { + result.append("<\(tag)>") + } else { + result.append("") + } } else { - forHTML ? result.append("<\(tag)>") : result.append("<\(tag)>") + if forHTML { + result.append("<\(tag)>") + } else { + result.append("<\(tag)>") + } } _ = scanner.scanString(">") diff --git a/Modules/Articles/Sources/Articles/ArticleStatus.swift b/Modules/Articles/Sources/Articles/ArticleStatus.swift index 2b420c417..e3f6ae1c8 100644 --- a/Modules/Articles/Sources/Articles/ArticleStatus.swift +++ b/Modules/Articles/Sources/Articles/ArticleStatus.swift @@ -93,7 +93,7 @@ public extension Set where Element == ArticleStatus { public extension Array where Element == ArticleStatus { - func articleIDs() -> [String] { + func articleIDs() -> [String] { return map { $0.articleID } } } diff --git a/Modules/ArticlesDatabase/Package.swift b/Modules/ArticlesDatabase/Package.swift index c7f451c39..56837b4b3 100644 --- a/Modules/ArticlesDatabase/Package.swift +++ b/Modules/ArticlesDatabase/Package.swift @@ -8,13 +8,13 @@ let package = Package( .library( name: "ArticlesDatabase", type: .dynamic, - targets: ["ArticlesDatabase"]), + targets: ["ArticlesDatabase"]) ], dependencies: [ .package(path: "../Articles"), .package(path: "../RSCore"), .package(path: "../RSParser"), - .package(path: "../RSDatabase"), + .package(path: "../RSDatabase") ], targets: [ .target( @@ -23,12 +23,12 @@ let package = Package( "RSCore", "RSDatabase", "RSParser", - "Articles", + "Articles" ], swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), - .enableUpcomingFeature("InferIsolatedConformances"), + .enableUpcomingFeature("InferIsolatedConformances") ] - ), + ) ] ) diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift index 388058ca4..5f3bcc493 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift @@ -36,7 +36,7 @@ public struct ArticleChanges: Sendable { } } -@MainActor public final class ArticlesDatabase: Sendable { +@MainActor public final class ArticlesDatabase { public enum RetentionStyle: Sendable { case feedBased // Local and iCloud: article retention is defined by contents of feed case syncSystem // Feedbin, Feedly, etc.: article retention is defined by external system diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift index ef48b4412..0e4fe4f98 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift @@ -48,7 +48,7 @@ final class ArticlesTable: DatabaseTable, Sendable { // MARK: - Fetching Articles for Feed func fetchArticles(_ feedID: String) throws -> Set
{ - return try fetchArticles{ self.fetchArticlesForFeedID(feedID, $0) } + return try fetchArticles { self.fetchArticlesForFeedID(feedID, $0) } } func fetchArticlesAsync(_ feedID: String, _ completion: @escaping ArticleSetResultBlock) { @@ -56,7 +56,7 @@ final class ArticlesTable: DatabaseTable, Sendable { } func fetchArticles(_ feedIDs: Set) throws -> Set
{ - return try fetchArticles{ self.fetchArticles(feedIDs, $0) } + return try fetchArticles { self.fetchArticles(feedIDs, $0) } } func fetchArticlesAsync(_ feedIDs: Set, _ completion: @escaping ArticleSetResultBlock) { @@ -66,7 +66,7 @@ final class ArticlesTable: DatabaseTable, Sendable { // MARK: - Fetching Articles by articleID func fetchArticles(articleIDs: Set) throws -> Set
{ - return try fetchArticles{ self.fetchArticles(articleIDs: articleIDs, $0) } + return try fetchArticles { self.fetchArticles(articleIDs: articleIDs, $0) } } func fetchArticlesAsync(articleIDs: Set, _ completion: @escaping ArticleSetResultBlock) { @@ -76,7 +76,7 @@ final class ArticlesTable: DatabaseTable, Sendable { // MARK: - Fetching Unread Articles func fetchUnreadArticles(_ feedIDs: Set, _ limit: Int?) throws -> Set
{ - return try fetchArticles{ self.fetchUnreadArticles(feedIDs, limit, $0) } + return try fetchArticles { self.fetchUnreadArticles(feedIDs, limit, $0) } } func fetchUnreadArticlesAsync(_ feedIDs: Set, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) { @@ -86,7 +86,7 @@ final class ArticlesTable: DatabaseTable, Sendable { // MARK: - Fetching Today Articles func fetchArticlesSince(_ feedIDs: Set, _ cutoffDate: Date, _ limit: Int?) throws -> Set
{ - return try fetchArticles{ self.fetchArticlesSince(feedIDs, cutoffDate, limit, $0) } + return try fetchArticles { self.fetchArticlesSince(feedIDs, cutoffDate, limit, $0) } } func fetchArticlesSinceAsync(_ feedIDs: Set, _ cutoffDate: Date, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) { @@ -96,7 +96,7 @@ final class ArticlesTable: DatabaseTable, Sendable { // MARK: - Fetching Starred Articles func fetchStarredArticles(_ feedIDs: Set, _ limit: Int?) throws -> Set
{ - return try fetchArticles{ self.fetchStarredArticles(feedIDs, limit, $0) } + return try fetchArticles { self.fetchStarredArticles(feedIDs, limit, $0) } } func fetchStarredArticlesAsync(_ feedIDs: Set, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) { @@ -104,7 +104,7 @@ final class ArticlesTable: DatabaseTable, Sendable { } func fetchStarredArticlesCount(_ feedIDs: Set) throws -> Int { - return try fetchArticlesCount{ self.fetchStarredArticlesCount(feedIDs, $0) } + return try fetchArticlesCount { self.fetchStarredArticlesCount(feedIDs, $0) } } // MARK: - Fetching Search Articles @@ -130,13 +130,13 @@ final class ArticlesTable: DatabaseTable, Sendable { func fetchArticlesMatching(_ searchString: String, _ feedIDs: Set) throws -> Set
{ var articles = try fetchArticlesMatching(searchString) - articles = articles.filter{ feedIDs.contains($0.feedID) } + articles = articles.filter { feedIDs.contains($0.feedID) } return articles } func fetchArticlesMatchingWithArticleIDs(_ searchString: String, _ articleIDs: Set) throws -> Set
{ var articles = try fetchArticlesMatching(searchString) - articles = articles.filter{ articleIDs.contains($0.articleID) } + articles = articles.filter { articleIDs.contains($0.articleID) } return articles } @@ -543,7 +543,7 @@ final class ArticlesTable: DatabaseTable, Sendable { completion(nil) return } - + queue.runInTransaction { databaseResult in switch databaseResult { case .success(let database): @@ -569,7 +569,7 @@ final class ArticlesTable: DatabaseTable, Sendable { guard let resultSet = database.executeQuery(sql, withArgumentsIn: nil) else { return } - let articleIDs = resultSet.mapToSet{ $0.string(forColumn: DatabaseKey.articleID) } + let articleIDs = resultSet.mapToSet { $0.string(forColumn: DatabaseKey.articleID) } if articleIDs.isEmpty { return } @@ -677,7 +677,7 @@ final class ArticlesTable: DatabaseTable, Sendable { guard let resultSet = database.executeQuery(sql, withArgumentsIn: parameters) else { return } - let articleIDs = resultSet.mapToSet{ $0.string(forColumn: DatabaseKey.articleID) } + let articleIDs = resultSet.mapToSet { $0.string(forColumn: DatabaseKey.articleID) } if articleIDs.isEmpty { return } @@ -734,7 +734,7 @@ nonisolated private extension ArticlesTable { private func fetchArticlesCount(_ fetchMethod: @escaping ArticlesCountFetchMethod) throws -> Int { nonisolated(unsafe) var articlesCount = 0 - nonisolated(unsafe) var error: DatabaseError? = nil + nonisolated(unsafe) var error: DatabaseError? queue.runInDatabaseSync { databaseResult in switch databaseResult { @@ -859,7 +859,7 @@ nonisolated private extension ArticlesTable { func sqliteSearchString(with searchString: String) -> String { var s = "" - searchString.enumerateSubstrings(in: searchString.startIndex.., _ database: FMDatabase) -> Set
{ let articles = fetchArticlesMatching(searchString, database) // TODO: include the feedIDs in the SQL rather than filtering here. - return articles.filter{ feedIDs.contains($0.feedID) } + return articles.filter { feedIDs.contains($0.feedID) } } func fetchArticlesMatchingWithArticleIDs(_ searchString: String, _ articleIDs: Set, _ database: FMDatabase) -> Set
{ let articles = fetchArticlesMatching(searchString, database) // TODO: include the articleIDs in the SQL rather than filtering here. - return articles.filter{ articleIDs.contains($0.articleID) } + return articles.filter { articleIDs.contains($0.articleID) } } // MARK: - Saving Parsed Items @@ -1011,7 +1011,7 @@ nonisolated private extension ArticlesTable { // MARK: - Updating Existing Articles func articlesWithRelatedObjectChanges(_ comparisonKeyPath: KeyPath?>, _ updatedArticles: Set
, _ fetchedArticles: [String: Article]) -> Set
{ - return updatedArticles.filter{ (updatedArticle) -> Bool in + return updatedArticles.filter { (updatedArticle) -> Bool in if let fetchedArticle = fetchedArticles[updatedArticle.articleID] { return updatedArticle[keyPath: comparisonKeyPath] != fetchedArticle[keyPath: comparisonKeyPath] } @@ -1032,7 +1032,7 @@ nonisolated private extension ArticlesTable { } func findUpdatedArticles(_ incomingArticles: Set
, _ fetchedArticlesDictionary: [String: Article]) -> Set
? { - let updatedArticles = incomingArticles.filter{ (incomingArticle) -> Bool in // 6 + let updatedArticles = incomingArticles.filter { (incomingArticle) -> Bool in // 6 if let existingArticle = fetchedArticlesDictionary[incomingArticle.articleID] { if existingArticle != incomingArticle { return true @@ -1106,7 +1106,7 @@ nonisolated private extension ArticlesTable { func filterIncomingArticles(_ articles: Set
) -> Set
{ // Drop Articles that we can ignore. precondition(retentionStyle == .syncSystem) - return Set(articles.filter{ !articleIsIgnorable($0) }) + return Set(articles.filter { !articleIsIgnorable($0) }) } func removeArticles(_ articleIDs: Set, _ database: FMDatabase) { diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Article+Database.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Article+Database.swift index ff045c7a6..2e21df005 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Article+Database.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/Extensions/Article+Database.swift @@ -62,7 +62,7 @@ extension Article { self.init(accountID: accountID, articleID: parsedItem.syncServiceID, feedID: feedID, uniqueID: parsedItem.uniqueID, title: parsedItem.title, contentHTML: parsedItem.contentHTML, contentText: parsedItem.contentText, markdown: parsedItem.markdown, url: parsedItem.url, externalURL: parsedItem.externalURL, summary: parsedItem.summary, imageURL: parsedItem.imageURL, datePublished: datePublished, dateModified: dateModified, authors: authors, status: status) } - private func addPossibleStringChangeWithKeyPath(_ comparisonKeyPath: KeyPath, _ otherArticle: Article, _ key: String, _ dictionary: inout DatabaseDictionary) { + private func addPossibleStringChangeWithKeyPath(_ comparisonKeyPath: KeyPath, _ otherArticle: Article, _ key: String, _ dictionary: inout DatabaseDictionary) { if self[keyPath: comparisonKeyPath] != otherArticle[keyPath: comparisonKeyPath] { dictionary[key] = self[keyPath: comparisonKeyPath] ?? "" } @@ -133,7 +133,7 @@ extension Article { static func articlesWithParsedItems(_ parsedItems: Set, _ feedID: String, _ accountID: String, _ statusesDictionary: [String: ArticleStatus]) -> Set
{ let maximumDateAllowed = _maximumDateAllowed() - return Set(parsedItems.map{ Article(parsedItem: $0, maximumDateAllowed: maximumDateAllowed, accountID: accountID, feedID: feedID, status: statusesDictionary[$0.articleID]!) }) + return Set(parsedItems.map { Article(parsedItem: $0, maximumDateAllowed: maximumDateAllowed, accountID: accountID, feedID: feedID, status: statusesDictionary[$0.articleID]!) }) } } @@ -215,7 +215,7 @@ extension Set where Element == Article { } func databaseObjects() -> [DatabaseObject] { - return self.map{ $0 as DatabaseObject } + return self.map { $0 as DatabaseObject } } func databaseDictionaries() -> [DatabaseDictionary]? { diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/SearchTable.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/SearchTable.swift index 0a3b8d4c5..931cddbdd 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/SearchTable.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/SearchTable.swift @@ -116,7 +116,7 @@ final class SearchTable: DatabaseTable, @unchecked Sendable { /// Index new articles. func indexNewArticles(_ articles: Set
, _ database: FMDatabase) { - let articleSearchInfos = Set(articles.map{ ArticleSearchInfo(article: $0) }) + let articleSearchInfos = Set(articles.map { ArticleSearchInfo(article: $0) }) performInitialIndexForArticles(articleSearchInfos, database) } diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/StatusesTable.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/StatusesTable.swift index 3d156a08a..bc15d5c6b 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/StatusesTable.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/StatusesTable.swift @@ -190,7 +190,7 @@ final class StatusesTable: DatabaseTable, Sendable { return statusWithRow(row, articleID: articleID) } - func statusWithRow(_ row: FMResultSet, articleID: String) ->ArticleStatus? { + func statusWithRow(_ row: FMResultSet, articleID: String) -> ArticleStatus? { if let cachedStatus = cache[articleID] { return cachedStatus } diff --git a/Modules/CloudKitSync/Package.swift b/Modules/CloudKitSync/Package.swift index d05f882c8..09281319a 100644 --- a/Modules/CloudKitSync/Package.swift +++ b/Modules/CloudKitSync/Package.swift @@ -8,7 +8,7 @@ let package = Package( .library( name: "CloudKitSync", targets: ["CloudKitSync"] - ), + ) ], dependencies: [ .package(path: "../RSCore") @@ -21,12 +21,12 @@ let package = Package( ], swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), - .enableUpcomingFeature("InferIsolatedConformances"), + .enableUpcomingFeature("InferIsolatedConformances") ] ), .testTarget( name: "CloudKitSyncTests", dependencies: ["CloudKitSync"] - ), + ) ] ) diff --git a/Modules/CloudKitSync/Sources/CloudKitSync/CloudKitZone.swift b/Modules/CloudKitSync/Sources/CloudKitSync/CloudKitZone.swift index 5ef5fc670..8e097b258 100644 --- a/Modules/CloudKitSync/Sources/CloudKitSync/CloudKitZone.swift +++ b/Modules/CloudKitSync/Sources/CloudKitSync/CloudKitZone.swift @@ -29,7 +29,7 @@ public enum CloudKitZoneError: LocalizedError, Sendable { // Wrapper to safely transfer non-Sendable values in @Sendable closures // Generic over the Success type of the Result -fileprivate struct CloudKitZoneCaptures: @unchecked Sendable { +private struct CloudKitZoneCaptures: @unchecked Sendable { weak var zone: (any CloudKitZone)? let completion: (Result) -> Void } @@ -119,7 +119,7 @@ public extension CloudKitZone { return CKRecord.ID(recordName: UUID().uuidString, zoneID: zoneID) } - func retryIfPossible(after: Double, block: @escaping @MainActor () -> ()) { + func retryIfPossible(after: Double, block: @escaping @MainActor () -> Void) { let delayTime = DispatchTime.now() + after DispatchQueue.main.asyncAfter(deadline: delayTime, execute: { block() @@ -148,7 +148,7 @@ public extension CloudKitZone { return } - database.save(CKRecordZone(zoneID: zoneID)) { (recordZone, error) in + database.save(CKRecordZone(zoneID: zoneID)) { (_, error) in Task { @MainActor in if let error { completion(.failure(CloudKitError(error))) @@ -185,7 +185,7 @@ public extension CloudKitZone { op.desiredKeys = desiredKeys } - op.recordMatchedBlock = { recordID, result in + op.recordMatchedBlock = { _, result in if let record = try? result.get() { records.append(record) } @@ -213,7 +213,7 @@ public extension CloudKitZone { completion(.success(records)) } case .zoneNotFound: - self.createZoneRecord() { result in + self.createZoneRecord { result in switch result { case .success: self.query(ckQuery, desiredKeys: desiredKeys, completion: completion) @@ -254,7 +254,7 @@ public extension CloudKitZone { op.desiredKeys = desiredKeys } - op.recordMatchedBlock = { recordID, result in + op.recordMatchedBlock = { _, result in if let record = try? result.get() { records.append(record) } @@ -282,7 +282,7 @@ public extension CloudKitZone { completion(.success(records)) } case .zoneNotFound: - self.createZoneRecord() { result in + self.createZoneRecord { result in switch result { case .success: self.query(cursor: cursor, desiredKeys: desiredKeys, carriedRecords: records, completion: completion) @@ -341,7 +341,7 @@ public extension CloudKitZone { } } case .zoneNotFound: - self.createZoneRecord() { result in + self.createZoneRecord { result in switch result { case .success: self.fetch(externalID: externalID, completion: captures.completion) @@ -403,7 +403,7 @@ public extension CloudKitZone { } case .zoneNotFound: - self.createZoneRecord() { result in + self.createZoneRecord { result in switch result { case .success: self.saveIfNew(records, completion: completion) @@ -475,7 +475,7 @@ public extension CloudKitZone { captures.completion(.success((savedSubscription!))) } case .zoneNotFound: - self.createZoneRecord() { result in + self.createZoneRecord { result in switch result { case .success: self.save(subscription, completion: captures.completion) @@ -506,7 +506,7 @@ public extension CloudKitZone { let op = CKQueryOperation(query: ckQuery) op.qualityOfService = Self.qualityOfService - op.recordMatchedBlock = { recordID, result in + op.recordMatchedBlock = { _, result in if let record = try? result.get() { records.append(record) } @@ -550,7 +550,7 @@ public extension CloudKitZone { let op = CKQueryOperation(cursor: cursor) op.qualityOfService = Self.qualityOfService - op.recordMatchedBlock = { recordID, result in + op.recordMatchedBlock = { _, result in if let record = try? result.get() { records.append(record) } @@ -667,7 +667,7 @@ public extension CloudKitZone { completion(.success(())) } case .zoneNotFound: - self.createZoneRecord() { result in + self.createZoneRecord { result in switch result { case .success: self.modify(recordsToSave: recordsToSave, recordIDsToDelete: recordIDsToDelete, completion: completion) @@ -728,7 +728,7 @@ public extension CloudKitZone { } } - saveChunks() { result in + saveChunks { result in switch result { case .success: deleteChunks() @@ -764,11 +764,11 @@ public extension CloudKitZone { op.fetchAllChanges = true op.qualityOfService = Self.qualityOfService - op.recordZoneChangeTokensUpdatedBlock = { zoneID, token, _ in + op.recordZoneChangeTokensUpdatedBlock = { _, token, _ in savedChangeToken = token } - op.recordWasChangedBlock = { recordID, result in + op.recordWasChangedBlock = { _, result in if let record = try? result.get() { changedRecords.append(record) } @@ -779,7 +779,7 @@ public extension CloudKitZone { deletedRecordKeys.append(recordKey) } - op.recordZoneFetchResultBlock = { zoneID, result in + op.recordZoneFetchResultBlock = { _, result in if case .success(let (serverChangeToken, _, _)) = result { savedChangeToken = serverChangeToken } @@ -815,7 +815,7 @@ public extension CloudKitZone { } } case .zoneNotFound: - self.createZoneRecord() { result in + self.createZoneRecord { result in switch result { case .success: self.fetchChangesInZone(completion: completion) diff --git a/Modules/CloudKitSync/Sources/CloudKitSync/CloudKitZoneResult.swift b/Modules/CloudKitSync/Sources/CloudKitSync/CloudKitZoneResult.swift index 9f9354a55..c763b1c70 100644 --- a/Modules/CloudKitSync/Sources/CloudKitSync/CloudKitZoneResult.swift +++ b/Modules/CloudKitSync/Sources/CloudKitSync/CloudKitZoneResult.swift @@ -63,13 +63,13 @@ public enum CloudKitZoneResult { private extension CloudKitZoneResult { static func anyRequestErrors(_ errors: [AnyHashable: CKError]) -> CloudKitZoneResult? { - if errors.values.contains(where: { $0.code == .changeTokenExpired } ) { + if errors.values.contains(where: { $0.code == .changeTokenExpired }) { return .changeTokenExpired } - if errors.values.contains(where: { $0.code == .zoneNotFound } ) { + if errors.values.contains(where: { $0.code == .zoneNotFound }) { return .zoneNotFound } - if errors.values.contains(where: { $0.code == .userDeletedZone } ) { + if errors.values.contains(where: { $0.code == .userDeletedZone }) { return .userDeletedZone } return nil diff --git a/Modules/RSCore/Package.swift b/Modules/RSCore/Package.swift index 9a2d3927f..613504059 100644 --- a/Modules/RSCore/Package.swift +++ b/Modules/RSCore/Package.swift @@ -15,7 +15,7 @@ let package = Package( dependencies: ["RSCoreObjC"], swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), - .enableUpcomingFeature("InferIsolatedConformances"), + .enableUpcomingFeature("InferIsolatedConformances") ] ), .target( @@ -33,7 +33,7 @@ let package = Package( ], swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), - .enableUpcomingFeature("InferIsolatedConformances"), + .enableUpcomingFeature("InferIsolatedConformances") ] ), .testTarget( @@ -41,6 +41,6 @@ let package = Package( dependencies: ["RSCore"], resources: [.copy("Resources")], swiftSettings: [.swiftLanguageMode(.v5)] - ), + ) ] ) diff --git a/Modules/RSCore/Sources/RSCore/AppKit/Keyboard.swift b/Modules/RSCore/Sources/RSCore/AppKit/Keyboard.swift index bcbcc1d5c..d6721aa75 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/Keyboard.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/Keyboard.swift @@ -102,7 +102,7 @@ public struct KeyboardKey: Hashable, Sendable { var integerValue = 0 - switch(s) { + switch s { case "[space]": integerValue = " ".keyboardIntegerValue! case "[uparrow]": diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSOutlineView+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSOutlineView+RSCore.swift index f417c6def..c41f09349 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSOutlineView+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSOutlineView+RSCore.swift @@ -64,7 +64,7 @@ public extension NSOutlineView { while true { row += 1 - if let _ = item(atRow: row) { + if item(atRow: row) != nil { if canSelect(row) { selectRowAndScrollToVisible(row) return diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSResponder+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSResponder+RSCore.swift index e63c3ba90..fa1ce7913 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSResponder+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSResponder+RSCore.swift @@ -13,12 +13,12 @@ public extension NSResponder { func hasAncestor(_ ancestor: NSResponder) -> Bool { var nomad: NSResponder = self - while(true) { + while true { if nomad === ancestor { return true } - if let _ = nomad.nextResponder { - nomad = nomad.nextResponder! + if let next = nomad.nextResponder { + nomad = next } else { break } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift index c027ec340..0fb4e7ac4 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift @@ -40,11 +40,11 @@ public extension NSTableView { let documentVisibleRect = scrollView.documentVisibleRect let r = rect(ofRow: row) - if NSContainsRect(documentVisibleRect, r) { + if documentVisibleRect.contains(r) { return } - let rMidY = NSMidY(r) + let rMidY = r.midY var scrollPoint = NSPoint.zero scrollPoint.y = floor(rMidY - (documentVisibleRect.size.height / 2.0)) + CGFloat(extraHeight) scrollPoint.y = max(scrollPoint.y, 0) @@ -54,7 +54,7 @@ public extension NSTableView { let clipView = scrollView.contentView - let rClipView = NSRect(x: scrollPoint.x, y: scrollPoint.y, width: NSWidth(clipView.bounds), height: NSHeight(clipView.bounds)) + let rClipView = NSRect(x: scrollPoint.x, y: scrollPoint.y, width: clipView.bounds.width, height: clipView.bounds.height) clipView.animator().bounds = rClipView } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/RSAppMovementMonitor.swift b/Modules/RSCore/Sources/RSCore/AppKit/RSAppMovementMonitor.swift index ddeb22f11..a9b4a5cf0 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/RSAppMovementMonitor.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/RSAppMovementMonitor.swift @@ -78,7 +78,7 @@ import Cocoa // every time the app becomes active. This catches a good number of edge-case // changes to the app bundle's path, such as when a containing folder or the // volume name changes. - NotificationCenter.default.addObserver(forName: NSApplication.didBecomeActiveNotification, object: nil, queue: nil) { notification in + NotificationCenter.default.addObserver(forName: NSApplication.didBecomeActiveNotification, object: nil, queue: nil) { _ in Task { @MainActor in // Removing observer in invalidate doesn't seem to prevent this getting called? Maybe // because it's on the same invocation of the runloop? diff --git a/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift b/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift index 1da6e5253..556d76845 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift @@ -12,7 +12,7 @@ import AppKit public class RSToolbarItem: NSToolbarItem { override public func validate() { - guard let view = view, let _ = view.window else { + guard let view = view, view.window != nil else { isEnabled = false return } @@ -34,7 +34,7 @@ private extension RSToolbarItem { return false } - while(true) { + while true { if let validated = validateWithResponder(responder!) { return validated } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift b/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift index 150100ab5..dbb4de1e7 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/URLPasteboardWriter.swift @@ -18,11 +18,11 @@ import AppKit self.urlString = urlString } - public class func write(urlString: String, to pasteboard: NSPasteboard) { + public static func write(urlString: String, to pasteboard: NSPasteboard) { write(urlStrings: [urlString], to: pasteboard) } - public class func write(urlStrings: [String], to pasteboard: NSPasteboard) { + public static func write(urlStrings: [String], to pasteboard: NSPasteboard) { assert(!urlStrings.isEmpty) guard !urlStrings.isEmpty else { return @@ -36,7 +36,7 @@ import AppKit // MARK: - NSPasteboardWriting public func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] { - if let _ = URL(string: urlString) { + if URL(string: urlString) != nil { return [.URL, .string] } return [.string] diff --git a/Modules/RSCore/Sources/RSCore/BatchUpdate.swift b/Modules/RSCore/Sources/RSCore/BatchUpdate.swift index ebb631786..f948cad65 100644 --- a/Modules/RSCore/Sources/RSCore/BatchUpdate.swift +++ b/Modules/RSCore/Sources/RSCore/BatchUpdate.swift @@ -49,7 +49,7 @@ public extension Notification.Name { public func end() { precondition(Thread.isMainThread) decrementCount() - } + } } private extension BatchUpdate { diff --git a/Modules/RSCore/Sources/RSCore/MainThreadOperationQueue.swift b/Modules/RSCore/Sources/RSCore/MainThreadOperationQueue.swift index 0e909fce8..cc02dff35 100644 --- a/Modules/RSCore/Sources/RSCore/MainThreadOperationQueue.swift +++ b/Modules/RSCore/Sources/RSCore/MainThreadOperationQueue.swift @@ -112,7 +112,7 @@ import Foundation operation.callCompletionBlock() operation.noteDidComplete() - + pendingOperations.removeAll { $0 == operation } if currentOperation == operation { currentOperation = nil @@ -155,7 +155,7 @@ private extension MainThreadOperationQueue { return } hasPendingRunScheduled = true - + Task { hasPendingRunScheduled = false guard !isSuspended && currentOperation == nil else { @@ -173,7 +173,7 @@ private extension MainThreadOperationQueue { guard let index = pendingOperations.firstIndex(where: { operationIsAvailable($0) }) else { return nil } - + let operation = pendingOperations[index] pendingOperations.remove(at: index) assert(!pendingOperations.contains(where: { $0 == operation })) diff --git a/Modules/RSCore/Sources/RSCore/UIKit/InteractiveLabel.swift b/Modules/RSCore/Sources/RSCore/UIKit/InteractiveLabel.swift index 0be7db9fe..4e06f7b19 100644 --- a/Modules/RSCore/Sources/RSCore/UIKit/InteractiveLabel.swift +++ b/Modules/RSCore/Sources/RSCore/UIKit/InteractiveLabel.swift @@ -61,7 +61,7 @@ public final class InteractiveLabel: UILabel, @preconcurrency UIEditMenuInteract public func editMenuInteraction(_ interaction: UIEditMenuInteraction, menuFor configuration: UIEditMenuConfiguration, suggestedActions: [UIMenuElement]) -> UIMenu? { - let copyAction = UIAction(title: "Copy", image: nil) { [weak self] action in + let copyAction = UIAction(title: "Copy", image: nil) { [weak self] _ in self?.copy(nil) } return UIMenu(title: "", children: [copyAction]) diff --git a/Modules/RSCore/Sources/RSCore/UIKit/UICollectionView+RSCore.swift b/Modules/RSCore/Sources/RSCore/UIKit/UICollectionView+RSCore.swift index d406c5972..e3ab8d830 100644 --- a/Modules/RSCore/Sources/RSCore/UIKit/UICollectionView+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/UIKit/UICollectionView+RSCore.swift @@ -12,7 +12,7 @@ import Foundation import UIKit extension UICollectionView { - + /// Selects an item and scrolls it to the middle if it is not visible public func selectItemAndScrollIfNotVisible(at indexPath: IndexPath, animations: Animations) { guard let dataSource = dataSource, diff --git a/Modules/RSCore/Sources/RSCoreResources/AppKit/WebViewWindowController.swift b/Modules/RSCore/Sources/RSCoreResources/AppKit/WebViewWindowController.swift index 576ce7d18..b743944d4 100644 --- a/Modules/RSCore/Sources/RSCoreResources/AppKit/WebViewWindowController.swift +++ b/Modules/RSCore/Sources/RSCoreResources/AppKit/WebViewWindowController.swift @@ -27,7 +27,7 @@ public final class WebViewWindowController: NSWindowController { public func displayContents(of path: String) { // We assume there might be images, style sheets, etc. contained by the folder that the file appears in, so we get read access to the parent folder. - let _ = self.window + _ = self.window let fileURL = URL(fileURLWithPath: path) let folderURL = fileURL.deletingLastPathComponent() diff --git a/Modules/RSDatabase/Package.swift b/Modules/RSDatabase/Package.swift index ceb5b9fc8..d4204ddda 100644 --- a/Modules/RSDatabase/Package.swift +++ b/Modules/RSDatabase/Package.swift @@ -12,7 +12,7 @@ let package = Package( .library( name: "RSDatabaseObjC", type: .dynamic, - targets: ["RSDatabaseObjC"]), + targets: ["RSDatabaseObjC"]) ], dependencies: [ ], @@ -22,7 +22,7 @@ let package = Package( dependencies: ["RSDatabaseObjC"], swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), - .enableUpcomingFeature("InferIsolatedConformances"), + .enableUpcomingFeature("InferIsolatedConformances") ] ), .target( @@ -31,6 +31,6 @@ let package = Package( ), .testTarget( name: "RSDatabaseTests", - dependencies: ["RSDatabase"]), + dependencies: ["RSDatabase"]) ] ) diff --git a/Modules/RSDatabase/Sources/RSDatabase/DatabaseObject.swift b/Modules/RSDatabase/Sources/RSDatabase/DatabaseObject.swift index aa5f166db..fcf63f452 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/DatabaseObject.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/DatabaseObject.swift @@ -55,7 +55,7 @@ extension Array where Element == DatabaseObject { func databaseDictionaries() -> [DatabaseDictionary]? { - let dictionaries = self.compactMap{ $0.databaseDictionary() } + let dictionaries = self.compactMap { $0.databaseDictionary() } return dictionaries.isEmpty ? nil : dictionaries } } diff --git a/Modules/RSDatabase/Sources/RSDatabase/DatabaseTable.swift b/Modules/RSDatabase/Sources/RSDatabase/DatabaseTable.swift index 464ea3ab8..0bb191d2c 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/DatabaseTable.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/DatabaseTable.swift @@ -58,7 +58,7 @@ public extension DatabaseTable { func insertRows(_ dictionaries: [DatabaseDictionary], insertType: RSDatabaseInsertType, in database: FMDatabase) { dictionaries.forEach { (oneDictionary) in - let _ = database.rs_insertRow(with: oneDictionary, insertType: insertType, tableName: self.name) + _ = database.rs_insertRow(with: oneDictionary, insertType: insertType, tableName: self.name) } } @@ -101,7 +101,7 @@ public extension DatabaseTable { func containsColumn(_ columnName: String, in database: FMDatabase) -> Bool { if let resultSet = database.executeQuery("select * from \(name) limit 1;", withArgumentsIn: nil) { if let columnMap = resultSet.columnNameToIndexMap { - if let _ = columnMap[columnName.lowercased()] { + if columnMap[columnName.lowercased()] != nil { return true } } diff --git a/Modules/RSDatabase/Sources/RSDatabase/FMDatabase+Extras.swift b/Modules/RSDatabase/Sources/RSDatabase/FMDatabase+Extras.swift index 9cbe53b8b..37b07f688 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/FMDatabase+Extras.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/FMDatabase+Extras.swift @@ -97,7 +97,7 @@ public extension FMDatabase { guard let resultSet = executeQuery(sql, withArgumentsIn: parameters) else { return nil } - + let count = resultSet.intWithCountResult() return count } diff --git a/Modules/RSDatabase/Sources/RSDatabase/FMResultSet+Extras.swift b/Modules/RSDatabase/Sources/RSDatabase/FMResultSet+Extras.swift index b87e905e5..9d53ff5d7 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/FMResultSet+Extras.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/FMResultSet+Extras.swift @@ -17,7 +17,7 @@ public extension FMResultSet { let count = Int(long(forColumnIndex: 0)) close() - + return count } diff --git a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseRelatedObjectsTable.swift b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseRelatedObjectsTable.swift index ec8cce4d3..e239588db 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseRelatedObjectsTable.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/DatabaseRelatedObjectsTable.swift @@ -67,7 +67,7 @@ public extension DatabaseRelatedObjectsTable { // Objects in cache must already exist in database. Filter them out. let objectsToSave = objects.filter { (object) -> Bool in - if let _ = cache[object.databaseID] { + if cache[object.databaseID] != nil { return false } return true diff --git a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectsMap.swift b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectsMap.swift index 1c7abbb8c..5add6539e 100644 --- a/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectsMap.swift +++ b/Modules/RSDatabase/Sources/RSDatabase/Related Objects/RelatedObjectsMap.swift @@ -22,7 +22,7 @@ public struct RelatedObjectsMap: Sendable { for objectID in relatedObjectIDsMap.objectIDs() { if let relatedObjectIDs = relatedObjectIDsMap[objectID] { - let relatedObjects = relatedObjectIDs.compactMap{ relatedObjectsDictionary[$0] } + let relatedObjects = relatedObjectIDs.compactMap { relatedObjectsDictionary[$0] } if !relatedObjects.isEmpty { d[objectID] = relatedObjects } diff --git a/Modules/RSParser/Package.swift b/Modules/RSParser/Package.swift index d3c384d0c..57b81f16e 100644 --- a/Modules/RSParser/Package.swift +++ b/Modules/RSParser/Package.swift @@ -12,7 +12,7 @@ let package = Package( .library( name: "RSParserObjC", type: .dynamic, - targets: ["RSParserObjC"]), + targets: ["RSParserObjC"]) ], dependencies: [ .package(path: "../RSMarkdown") @@ -24,7 +24,7 @@ let package = Package( path: "Sources/Swift", swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), - .enableUpcomingFeature("InferIsolatedConformances"), + .enableUpcomingFeature("InferIsolatedConformances") ]), .target( name: "RSParserObjC", @@ -41,8 +41,8 @@ let package = Package( resources: [.copy("Resources")], swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), - .enableUpcomingFeature("InferIsolatedConformances"), + .enableUpcomingFeature("InferIsolatedConformances") ] - ), + ) ] ) diff --git a/Modules/RSParser/Sources/Swift/Feeds/JSON/JSONFeedParser.swift b/Modules/RSParser/Sources/Swift/Feeds/JSON/JSONFeedParser.swift index d5007e054..2b9800859 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/JSON/JSONFeedParser.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/JSON/JSONFeedParser.swift @@ -58,7 +58,7 @@ public struct JSONFeedParser { throw FeedParserError.invalidJSON } - guard let version = d[Key.version] as? String, let _ = version.range(of: JSONFeedParser.jsonFeedVersionMarker) else { + guard let version = d[Key.version] as? String, version.range(of: JSONFeedParser.jsonFeedVersionMarker) != nil else { throw FeedParserError.jsonFeedVersionNotFound } guard let itemsArray = d[Key.items] as? JSONArray else { diff --git a/Modules/RSParser/Sources/Swift/Feeds/JSON/RSSInJSONParser.swift b/Modules/RSParser/Sources/Swift/Feeds/JSON/RSSInJSONParser.swift index 8d0b01953..7865c27b4 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/JSON/RSSInJSONParser.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/JSON/RSSInJSONParser.swift @@ -116,11 +116,11 @@ private extension RSSInJSONParser { } if s.isEmpty { // Sheesh. Tough case. - if let _ = contentHTML { - s = contentHTML! + if let html = contentHTML { + s = html } - if let _ = contentText { - s = contentText! + if let text = contentText { + s = text } } uniqueID = (s as NSString).rsparser_md5Hash() @@ -149,7 +149,7 @@ private extension RSSInJSONParser { } return nil } else if let categoryArray = itemDictionary["category"] as? JSONArray { - return Set(categoryArray.compactMap{ $0["#value"] as? String }) + return Set(categoryArray.compactMap { $0["#value"] as? String }) } return nil } diff --git a/Modules/RSParser/Sources/Swift/Feeds/ParsedItem.swift b/Modules/RSParser/Sources/Swift/Feeds/ParsedItem.swift index 4fc521e35..c88cabb7c 100644 --- a/Modules/RSParser/Sources/Swift/Feeds/ParsedItem.swift +++ b/Modules/RSParser/Sources/Swift/Feeds/ParsedItem.swift @@ -30,23 +30,23 @@ public struct ParsedItem: Hashable, Sendable { public let attachments: Set? public init(syncServiceID: String?, - uniqueID: String, - feedURL: String, - url: String?, - externalURL: String?, - title: String?, - language: String?, - contentHTML: String?, - contentText: String?, - markdown: String?, - summary: String?, - imageURL: String?, - bannerImageURL: String?, - datePublished: Date?, - dateModified: Date?, - authors: Set?, - tags: Set?, - attachments: Set?) { + uniqueID: String, + feedURL: String, + url: String?, + externalURL: String?, + title: String?, + language: String?, + contentHTML: String?, + contentText: String?, + markdown: String?, + summary: String?, + imageURL: String?, + bannerImageURL: String?, + datePublished: Date?, + dateModified: Date?, + authors: Set?, + tags: Set?, + attachments: Set?) { self.syncServiceID = syncServiceID self.uniqueID = uniqueID self.feedURL = feedURL diff --git a/Modules/RSParser/Tests/RSParserTests/HTMLMetadataTests.swift b/Modules/RSParser/Tests/RSParserTests/HTMLMetadataTests.swift index 484ba2bff..3245e7706 100644 --- a/Modules/RSParser/Tests/RSParserTests/HTMLMetadataTests.swift +++ b/Modules/RSParser/Tests/RSParserTests/HTMLMetadataTests.swift @@ -118,7 +118,7 @@ final class HTMLMetadataTests: XCTestCase { // 0.002 sec on my 2012 iMac let d = parserData("sixcolors", "html", "http://sixcolors.com/") self.measure { - let _ = RSHTMLMetadataParser.htmlMetadata(with: d) + _ = RSHTMLMetadataParser.htmlMetadata(with: d) } } diff --git a/Modules/RSTree/Package.swift b/Modules/RSTree/Package.swift index b570f1cec..ddee8ba52 100644 --- a/Modules/RSTree/Package.swift +++ b/Modules/RSTree/Package.swift @@ -8,7 +8,7 @@ let package = Package( .library( name: "RSTree", type: .dynamic, - targets: ["RSTree"]), + targets: ["RSTree"]) ], targets: [ .target( @@ -16,7 +16,7 @@ let package = Package( dependencies: [], swiftSettings: [ .enableUpcomingFeature("NonisolatedNonsendingByDefault"), - .enableUpcomingFeature("InferIsolatedConformances"), - ]), + .enableUpcomingFeature("InferIsolatedConformances") + ]) ] ) diff --git a/Modules/RSTree/Sources/RSTree/TreeController.swift b/Modules/RSTree/Sources/RSTree/TreeController.swift index d2e51091e..ac967b8aa 100644 --- a/Modules/RSTree/Sources/RSTree/TreeController.swift +++ b/Modules/RSTree/Sources/RSTree/TreeController.swift @@ -80,7 +80,7 @@ private extension TreeController { func visitNode(_ node: Node, _ visitBlock: NodeVisitBlock) { visitBlock(node) - node.childNodes.forEach{ (oneChildNode) in + node.childNodes.forEach { (oneChildNode) in visitNode(oneChildNode, visitBlock) } } diff --git a/Modules/RSWeb/Package.swift b/Modules/RSWeb/Package.swift index db1db76db..fe04b4be1 100644 --- a/Modules/RSWeb/Package.swift +++ b/Modules/RSWeb/Package.swift @@ -24,7 +24,7 @@ let package = Package( swiftSettings: [ .unsafeFlags(["-warnings-as-errors"]), .enableUpcomingFeature("NonisolatedNonsendingByDefault"), - .enableUpcomingFeature("InferIsolatedConformances"), + .enableUpcomingFeature("InferIsolatedConformances") ] ), .testTarget( diff --git a/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift b/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift index 75953b7ce..ef3d28a3a 100755 --- a/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift +++ b/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift @@ -199,7 +199,7 @@ extension DownloadSession: @preconcurrency URLSessionDataDelegate { return } info.addData(data) - + if !delegate.downloadSession(self, shouldContinueAfterReceivingData: info.data as Data, url: info.url) { dataTask.cancel() removeTask(dataTask) diff --git a/Modules/RSWeb/Sources/RSWeb/URL+RSWeb.swift b/Modules/RSWeb/Sources/RSWeb/URL+RSWeb.swift index b69abe1a6..867f128ef 100755 --- a/Modules/RSWeb/Sources/RSWeb/URL+RSWeb.swift +++ b/Modules/RSWeb/Sources/RSWeb/URL+RSWeb.swift @@ -75,7 +75,7 @@ private extension String { let lowerPrefix = prefix.lowercased() let lowerSelf = self.lowercased() - if (lowerSelf == lowerPrefix) { + if lowerSelf == lowerPrefix { return "" } if !lowerSelf.hasPrefix(lowerPrefix) { diff --git a/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift b/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift index a338245e1..06299efd6 100644 --- a/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift +++ b/Modules/RSWeb/Sources/RSWeb/WebServices/Transport.swift @@ -193,7 +193,7 @@ nonisolated extension URLSession: Transport { var sendRequest = request sendRequest.httpMethod = method - let task = self.dataTask(with: sendRequest) { (data, response, error) in + let task = self.dataTask(with: sendRequest) { (_, response, error) in DispatchQueue.main.async { if let error = error { return completion(.failure(error)) diff --git a/Shared/Commands/DeleteCommand.swift b/Shared/Commands/DeleteCommand.swift index 956d19c7e..c1b81771b 100644 --- a/Shared/Commands/DeleteCommand.swift +++ b/Shared/Commands/DeleteCommand.swift @@ -254,9 +254,9 @@ private struct DeleteActionName { var numberOfFolders = 0 for node in nodes { - if node.representedObject as? Feed != nil { + if node.representedObject is Feed { numberOfFeeds += 1 - } else if node.representedObject as? Folder != nil { + } else if node.representedObject is Folder { numberOfFolders += 1 } else { return nil // Delete only Feeds and Folders. diff --git a/iOS/Account/FeedbinAccountViewController.swift b/iOS/Account/FeedbinAccountViewController.swift index 968d82666..687bf8bf5 100644 --- a/iOS/Account/FeedbinAccountViewController.swift +++ b/iOS/Account/FeedbinAccountViewController.swift @@ -161,7 +161,7 @@ final class FeedbinAccountViewController: UITableViewController { actionButton.isEnabled = value } - private func toggleActivityIndicatorAnimation(visible value: Bool){ + private func toggleActivityIndicatorAnimation(visible value: Bool) { activityIndicator.isHidden = !value if value { activityIndicator.startAnimating() diff --git a/iOS/Account/ReaderAPIAccountViewController.swift b/iOS/Account/ReaderAPIAccountViewController.swift index ae3606673..8a3589f94 100644 --- a/iOS/Account/ReaderAPIAccountViewController.swift +++ b/iOS/Account/ReaderAPIAccountViewController.swift @@ -230,7 +230,7 @@ final class ReaderAPIAccountViewController: UITableViewController { showError(NSLocalizedString("Username, password, and API URL are required.", comment: "Credentials Error")) return false } - guard let _ = URL(string: apiURLTextField.text!) else { + guard URL(string: apiURLTextField.text!) != nil else { showError(NSLocalizedString("Invalid API URL.", comment: "Invalid API URL")) return false } diff --git a/iOS/AppDefaults.swift b/iOS/AppDefaults.swift index 498167acf..aa66773e7 100644 --- a/iOS/AppDefaults.swift +++ b/iOS/AppDefaults.swift @@ -84,7 +84,7 @@ final class AppDefaults: Sendable { }() let isFirstRun: Bool = { - if AppDefaults.store.object(forKey: Key.firstRunDate) as? Date != nil { + if AppDefaults.store.object(forKey: Key.firstRunDate) is Date { return false } firstRunDate = Date() diff --git a/iOS/AppDelegate.swift b/iOS/AppDelegate.swift index bbe5a517a..583b0868f 100644 --- a/iOS/AppDelegate.swift +++ b/iOS/AppDelegate.swift @@ -82,7 +82,7 @@ import Secrets self.updateBadge() } - UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in + UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, _) in if granted { DispatchQueue.main.async { UIApplication.shared.registerForRemoteNotifications() @@ -143,8 +143,8 @@ import Secrets // MARK: - API - func manualRefresh(errorHandler: @escaping @Sendable (Error) -> ()) { - UIApplication.shared.connectedScenes.compactMap( { $0.delegate as? SceneDelegate } ).forEach { + func manualRefresh(errorHandler: @escaping @Sendable (Error) -> Void) { + UIApplication.shared.connectedScenes.compactMap( { $0.delegate as? SceneDelegate }).forEach { $0.cleanUp(conditional: true) } AccountManager.shared.refreshAllWithoutWaiting(errorHandler: errorHandler) @@ -264,7 +264,7 @@ private extension AppDelegate { } DispatchQueue.main.async { [weak self] in - self?.waitToComplete() { [weak self] suspend in + self?.waitToComplete { [weak self] suspend in self?.completeProcessing(suspend) } } diff --git a/iOS/Article/ArticleViewController.swift b/iOS/Article/ArticleViewController.swift index 254b8ac56..3830daf46 100644 --- a/iOS/Article/ArticleViewController.swift +++ b/iOS/Article/ArticleViewController.swift @@ -364,8 +364,7 @@ public extension Notification.Name { extension ArticleViewController: SearchBarDelegate { func searchBar(_ searchBar: ArticleSearchBar, textDidChange searchText: String) { - currentWebViewController?.searchText(searchText) { - found in + currentWebViewController?.searchText(searchText) { found in searchBar.resultsCount = found.count if let index = found.index { diff --git a/iOS/Article/FindInArticleActivity.swift b/iOS/Article/FindInArticleActivity.swift index c915432d4..6c9e7668f 100644 --- a/iOS/Article/FindInArticleActivity.swift +++ b/iOS/Article/FindInArticleActivity.swift @@ -21,7 +21,7 @@ final class FindInArticleActivity: UIActivity { UIImage(systemName: "magnifyingglass", withConfiguration: UIImage.SymbolConfiguration(pointSize: 20, weight: .regular)) } - override class var activityCategory: UIActivity.Category { + override static var activityCategory: UIActivity.Category { .action } diff --git a/iOS/Article/ImageTransition.swift b/iOS/Article/ImageTransition.swift index a4a861c02..941af5459 100644 --- a/iOS/Article/ImageTransition.swift +++ b/iOS/Article/ImageTransition.swift @@ -94,7 +94,7 @@ final class ImageTransition: NSObject, UIViewControllerAnimatedTransitioning { imageView.frame = self.originFrame }, completion: { _ in if let controller = self.webViewController { - controller.showClickedImage() { + controller.showClickedImage { DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { imageView.removeFromSuperview() transitionContext.completeTransition(true) diff --git a/iOS/Article/ImageViewController.swift b/iOS/Article/ImageViewController.swift index 16e95c206..1d4ad685d 100644 --- a/iOS/Article/ImageViewController.swift +++ b/iOS/Article/ImageViewController.swift @@ -58,7 +58,7 @@ final class ImageViewController: UIViewController { override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) - coordinator.animate(alongsideTransition: { [weak self] context in + coordinator.animate(alongsideTransition: { [weak self] _ in self?.imageScrollView.resize() }) } @@ -75,7 +75,7 @@ final class ImageViewController: UIViewController { dismiss(animated: true) } - private func layoutTitleLabel(){ + private func layoutTitleLabel() { let width = view.frame.width let multiplier = traitCollection.userInterfaceIdiom == .pad ? CGFloat(0.1) : CGFloat(0.04) titleLeading.constant += width * multiplier diff --git a/iOS/Article/OpenInSafariActivity.swift b/iOS/Article/OpenInSafariActivity.swift index 272347be8..6e456be8a 100644 --- a/iOS/Article/OpenInSafariActivity.swift +++ b/iOS/Article/OpenInSafariActivity.swift @@ -24,7 +24,7 @@ final class OpenInBrowserActivity: UIActivity { return UIActivity.ActivityType(rawValue: "com.rancharo.NetNewsWire-Evergreen.safari") } - override class var activityCategory: UIActivity.Category { + override static var activityCategory: UIActivity.Category { return .action } diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index 7e14c501c..9f819c666 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -321,7 +321,7 @@ extension WebViewController: ArticleExtractorDelegate { extension WebViewController: UIContextMenuInteractionDelegate { func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? { - return UIContextMenuConfiguration(identifier: nil, previewProvider: contextMenuPreviewProvider) { [weak self] suggestedActions in + return UIContextMenuConfiguration(identifier: nil, previewProvider: contextMenuPreviewProvider) { [weak self] _ in guard let self = self else { return nil } var menus = [UIMenu]() @@ -530,7 +530,7 @@ private extension WebViewController { return } - coordinator.webViewProvider.dequeueWebView() { webView in + coordinator.webViewProvider.dequeueWebView { webView in webView.ready { @@ -658,7 +658,7 @@ private extension WebViewController { guard let imageURL = URL(string: clickMessage.imageURL) else { return } - Downloader.shared.download(imageURL) { [weak self] data, response, error in + Downloader.shared.download(imageURL) { [weak self] data, _, error in guard let self, let data, error == nil, !data.isEmpty, let image = UIImage(data: data) else { return @@ -751,7 +751,7 @@ private extension WebViewController { func prevArticleAction() -> UIAction? { guard coordinator.isPrevArticleAvailable else { return nil } let title = NSLocalizedString("Previous Article", comment: "Previous Article") - return UIAction(title: title, image: Assets.Images.prevArticle) { [weak self] action in + return UIAction(title: title, image: Assets.Images.prevArticle) { [weak self] _ in self?.coordinator.selectPrevArticle() } } @@ -759,7 +759,7 @@ private extension WebViewController { func nextArticleAction() -> UIAction? { guard coordinator.isNextArticleAvailable else { return nil } let title = NSLocalizedString("Next Article", comment: "Next Article") - return UIAction(title: title, image: Assets.Images.nextArticle) { [weak self] action in + return UIAction(title: title, image: Assets.Images.nextArticle) { [weak self] _ in self?.coordinator.selectNextArticle() } } @@ -769,7 +769,7 @@ private extension WebViewController { let title = article.status.read ? NSLocalizedString("Mark as Unread", comment: "Mark as Unread") : NSLocalizedString("Mark as Read", comment: "Mark as Read") let readImage = article.status.read ? Assets.Images.circleClosed : Assets.Images.circleOpen - return UIAction(title: title, image: readImage) { [weak self] action in + return UIAction(title: title, image: readImage) { [weak self] _ in self?.coordinator.toggleReadForCurrentArticle() } } @@ -778,7 +778,7 @@ private extension WebViewController { let starred = article?.status.starred ?? false let title = starred ? NSLocalizedString("Mark as Unstarred", comment: "Mark as Unstarred") : NSLocalizedString("Mark as Starred", comment: "Mark as Starred") let starredImage = starred ? Assets.Images.starOpen : Assets.Images.starClosed - return UIAction(title: title, image: starredImage) { [weak self] action in + return UIAction(title: title, image: starredImage) { [weak self] _ in self?.coordinator.toggleStarredForCurrentArticle() } } @@ -786,7 +786,7 @@ private extension WebViewController { func nextUnreadArticleAction() -> UIAction? { guard coordinator.isAnyUnreadAvailable else { return nil } let title = NSLocalizedString("Next Unread Article", comment: "Next Unread Article") - return UIAction(title: title, image: Assets.Images.nextUnread) { [weak self] action in + return UIAction(title: title, image: Assets.Images.nextUnread) { [weak self] _ in self?.coordinator.selectNextUnread() } } @@ -795,14 +795,14 @@ private extension WebViewController { let extracted = articleExtractorButtonState == .on let title = extracted ? NSLocalizedString("Show Feed Article", comment: "Show Feed Article") : NSLocalizedString("Show Reader View", comment: "Show Reader View") let extractorImage = extracted ? Assets.Images.articleExtractorOffSF : Assets.Images.articleExtractorOnSF - return UIAction(title: title, image: extractorImage) { [weak self] action in + return UIAction(title: title, image: extractorImage) { [weak self] _ in self?.toggleArticleExtractor() } } func shareAction() -> UIAction { let title = NSLocalizedString("Share", comment: "Share") - return UIAction(title: title, image: Assets.Images.share) { [weak self] action in + return UIAction(title: title, image: Assets.Images.share) { [weak self] _ in self?.showActivityDialog() } } @@ -862,8 +862,7 @@ extension WebViewController { } let encoded = json.base64EncodedString() - webView?.evaluateJavaScript("updateFind(\"\(encoded)\")") { - (result, error) in + webView?.evaluateJavaScript("updateFind(\"\(encoded)\")") { (result, error) in guard error == nil, let b64 = result as? String, let rawData = Data(base64Encoded: b64), diff --git a/iOS/Article/WebViewProvider.swift b/iOS/Article/WebViewProvider.swift index 5e038fbbf..25b5eab92 100644 --- a/iOS/Article/WebViewProvider.swift +++ b/iOS/Article/WebViewProvider.swift @@ -27,7 +27,7 @@ import WebKit operationQueue.add(WebViewProviderReplenishQueueOperation(queue: queue, articleIconSchemeHandler: articleIconSchemeHandler)) } - func dequeueWebView(completion: @escaping (PreloadedWebView) -> ()) { + func dequeueWebView(completion: @escaping (PreloadedWebView) -> Void) { operationQueue.add(WebViewProviderDequeueOperation(queue: queue, articleIconSchemeHandler: articleIconSchemeHandler, completion: completion)) operationQueue.add(WebViewProviderReplenishQueueOperation(queue: queue, articleIconSchemeHandler: articleIconSchemeHandler)) } @@ -58,9 +58,9 @@ final class WebViewProviderReplenishQueueOperation: MainThreadOperation, @unchec final class WebViewProviderDequeueOperation: MainThreadOperation, @unchecked Sendable { private var queue: NSMutableArray private var articleIconSchemeHandler: ArticleIconSchemeHandler - private var completion: (PreloadedWebView) -> () + private var completion: (PreloadedWebView) -> Void - init(queue: NSMutableArray, articleIconSchemeHandler: ArticleIconSchemeHandler, completion: @escaping (PreloadedWebView) -> ()) { + init(queue: NSMutableArray, articleIconSchemeHandler: ArticleIconSchemeHandler, completion: @escaping (PreloadedWebView) -> Void) { self.queue = queue self.articleIconSchemeHandler = articleIconSchemeHandler self.completion = completion diff --git a/iOS/HidingReadArticlesState.swift b/iOS/HidingReadArticlesState.swift index 7587203c5..67a0b1aad 100644 --- a/iOS/HidingReadArticlesState.swift +++ b/iOS/HidingReadArticlesState.swift @@ -28,7 +28,7 @@ import Account func toggleHidingReadArticles(for sidebarItemID: SidebarItemIdentifier) { assert(canToggleHidingReadArticles(for: sidebarItemID)) - if (!canToggleHidingReadArticles(for: sidebarItemID)) { + if !canToggleHidingReadArticles(for: sidebarItemID) { return } diff --git a/iOS/KeyboardManager.swift b/iOS/KeyboardManager.swift index 5c507f0ad..96bbbdd6a 100644 --- a/iOS/KeyboardManager.swift +++ b/iOS/KeyboardManager.swift @@ -74,9 +74,11 @@ private extension KeyboardManager { } static func createKeyCommandInput(keyEntry: [String: Any]) -> String? { - guard let key = keyEntry["key"] as? String else { return nil } + guard let key = keyEntry["key"] as? String else { + return nil + } - switch(key) { + switch key { case "[space]": return "\u{0020}" case "[uparrow]": diff --git a/iOS/MainFeed/Collection View Cells/MainFeedCollectionHeaderReusableView.swift b/iOS/MainFeed/Collection View Cells/MainFeedCollectionHeaderReusableView.swift index 6dba0814b..14b360fab 100644 --- a/iOS/MainFeed/Collection View Cells/MainFeedCollectionHeaderReusableView.swift +++ b/iOS/MainFeed/Collection View Cells/MainFeedCollectionHeaderReusableView.swift @@ -22,7 +22,6 @@ final class MainFeedCollectionHeaderReusableView: UICollectionReusableView { private var unreadLabelWidthConstraint: NSLayoutConstraint? override var accessibilityLabel: String? { - set {} get { if unreadCount > 0 { let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessibility") @@ -31,16 +30,14 @@ final class MainFeedCollectionHeaderReusableView: UICollectionReusableView { return "\(headerTitle.text ?? "") \(expandedStateMessage) " } } + set {} } private var expandedStateMessage: String { - set {} - get { - if disclosureExpanded { - return NSLocalizedString("Expanded", comment: "Disclosure button expanded state for accessibility") - } - return NSLocalizedString("Collapsed", comment: "Disclosure button collapsed state for accessibility") + if disclosureExpanded { + return NSLocalizedString("Expanded", comment: "Disclosure button expanded state for accessibility") } + return NSLocalizedString("Collapsed", comment: "Disclosure button collapsed state for accessibility") } private var _unreadCount: Int = 0 diff --git a/iOS/MainFeed/Collection View Cells/MainFeedCollectionViewCell.swift b/iOS/MainFeed/Collection View Cells/MainFeedCollectionViewCell.swift index 9793b7f76..9f1612774 100644 --- a/iOS/MainFeed/Collection View Cells/MainFeedCollectionViewCell.swift +++ b/iOS/MainFeed/Collection View Cells/MainFeedCollectionViewCell.swift @@ -61,7 +61,6 @@ final class MainFeedCollectionViewCell: UICollectionViewCell { } override var accessibilityLabel: String? { - set {} get { if unreadCount > 0 { let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessibility") @@ -70,6 +69,7 @@ final class MainFeedCollectionViewCell: UICollectionViewCell { return (String(describing: feedTitle.text)) } } + set {} } override func awakeFromNib() { diff --git a/iOS/MainFeed/Collection View Cells/MainFeedCollectionViewFolderCell.swift b/iOS/MainFeed/Collection View Cells/MainFeedCollectionViewFolderCell.swift index 7db3bb55e..2e5d8bab7 100644 --- a/iOS/MainFeed/Collection View Cells/MainFeedCollectionViewFolderCell.swift +++ b/iOS/MainFeed/Collection View Cells/MainFeedCollectionViewFolderCell.swift @@ -98,7 +98,6 @@ class MainFeedCollectionViewFolderCell: UICollectionViewCell { } override var accessibilityLabel: String? { - set {} get { if unreadCount > 0 { let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessibility") @@ -107,6 +106,7 @@ class MainFeedCollectionViewFolderCell: UICollectionViewCell { return (String(describing: folderTitle.text)) } } + set {} } override func updateConfiguration(using state: UICellConfigurationState) { diff --git a/iOS/MainFeed/MainFeedCollectionViewController+Drop.swift b/iOS/MainFeed/MainFeedCollectionViewController+Drop.swift index 72e51d2d9..24d9fa219 100644 --- a/iOS/MainFeed/MainFeedCollectionViewController+Drop.swift +++ b/iOS/MainFeed/MainFeedCollectionViewController+Drop.swift @@ -71,7 +71,7 @@ extension MainFeedCollectionViewController: UICollectionViewDropDelegate { func collectionView(_ collectionView: UICollectionView, dropSessionDidUpdate session: any UIDropSession, withDestinationIndexPath destinationIndexPath: IndexPath?) -> UICollectionViewDropProposal { - guard let destIndexPath = destinationIndexPath, destIndexPath.section > 0, collectionView.hasActiveDrag else { + guard let destIndexPath = destinationIndexPath, destIndexPath.section > 0, collectionView.hasActiveDrag else { return UICollectionViewDropProposal(operation: .forbidden) } diff --git a/iOS/MainFeed/MainFeedCollectionViewController.swift b/iOS/MainFeed/MainFeedCollectionViewController.swift index 5082fd89a..42e853946 100644 --- a/iOS/MainFeed/MainFeedCollectionViewController.swift +++ b/iOS/MainFeed/MainFeedCollectionViewController.swift @@ -83,7 +83,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab /// /// `shouldSelectItemAt()` will not allow selection when `isAnimating` /// is `true.` - if let _ = collectionView.indexPathsForSelectedItems { + if collectionView.indexPathsForSelectedItems != nil { isAnimating = true } } @@ -95,7 +95,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab /// On iPhone, once the deselection animation has completed, set `isAnimating` /// to false and this will allow selection. if traitCollection.userInterfaceIdiom == .phone { - if let _ = collectionView.indexPathsForSelectedItems { + if collectionView.indexPathsForSelectedItems != nil { coordinator.selectFeed(indexPath: nil, animations: [.select]) DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: { self.isAnimating = false @@ -130,7 +130,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab // Set up the delete action let deleteTitle = NSLocalizedString("Delete", comment: "Delete") - let deleteAction = UIContextualAction(style: .destructive, title: nil) { [weak self] (action, view, completion) in + let deleteAction = UIContextualAction(style: .destructive, title: nil) { [weak self] _, _, completion in self?.delete(indexPath: indexPath) completion(true) } @@ -141,7 +141,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab // Set up the rename action let renameTitle = NSLocalizedString("Rename", comment: "Rename") - let renameAction = UIContextualAction(style: .normal, title: nil) { [weak self] (action, view, completion) in + let renameAction = UIContextualAction(style: .normal, title: nil) { [weak self] _, _, completion in self?.rename(indexPath: indexPath) completion(true) } @@ -233,7 +233,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab } override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let node = coordinator.nodeFor(indexPath), let _ = node.representedObject as? Folder else { + guard let node = coordinator.nodeFor(indexPath), node.representedObject is Folder else { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as? MainFeedCollectionViewCell configure(cell!, indexPath: indexPath) return cell! @@ -324,7 +324,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab return makeFeedContextMenu(indexPath: indexPath, includeDeleteRename: true) } else if sidebarItem is Folder { return makeFolderContextMenu(indexPath: indexPath) - } else if sidebarItem is PseudoFeed { + } else if sidebarItem is PseudoFeed { return makePseudoFeedContextMenu(indexPath: indexPath) } else { return nil @@ -546,7 +546,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab func configure(_ cell: MainFeedCollectionViewCell, indexPath: IndexPath) { guard let node = coordinator.nodeFor(indexPath) else { return } var indentationLevel = 0 - if let _ = node.parent?.representedObject as? Folder { + if node.parent?.representedObject is Folder { indentationLevel = 1 } @@ -779,7 +779,7 @@ extension MainFeedCollectionViewController: UIContextMenuInteractionDelegate { return nil } - return UIContextMenuConfiguration(identifier: sectionIndex as NSCopying, previewProvider: nil) { suggestedActions in + return UIContextMenuConfiguration(identifier: sectionIndex as NSCopying, previewProvider: nil) { _ in var menuElements = [UIMenuElement]() menuElements.append(UIMenu(title: "", options: .displayInline, children: [self.getAccountInfoAction(account: account)])) @@ -806,7 +806,7 @@ extension MainFeedCollectionViewController: UIContextMenuInteractionDelegate { extension MainFeedCollectionViewController { func makeFeedContextMenu(indexPath: IndexPath, includeDeleteRename: Bool) -> UIContextMenuConfiguration { - return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { [ weak self] suggestedActions in + return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { [ weak self] _ in guard let self = self else { return nil } @@ -849,7 +849,7 @@ extension MainFeedCollectionViewController { } func makeFolderContextMenu(indexPath: IndexPath) -> UIContextMenuConfiguration { - return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { [weak self] suggestedActions in + return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { [weak self] _ in guard let self = self else { return nil } @@ -876,7 +876,7 @@ extension MainFeedCollectionViewController { return nil } - return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { suggestedActions in + return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { _ in return UIMenu(title: "", children: [markAllAction]) }) } @@ -887,7 +887,7 @@ extension MainFeedCollectionViewController { } let title = NSLocalizedString("Open Home Page", comment: "Open Home Page") - let action = UIAction(title: title, image: Assets.Images.safari) { [weak self] action in + let action = UIAction(title: title, image: Assets.Images.safari) { [weak self] _ in self?.coordinator.showBrowserForFeed(indexPath) } return action @@ -899,7 +899,7 @@ extension MainFeedCollectionViewController { } let title = NSLocalizedString("Open Home Page", comment: "Open Home Page") - let action = UIAlertAction(title: title, style: .default) { [weak self] action in + let action = UIAlertAction(title: title, style: .default) { [weak self] _ in self?.coordinator.showBrowserForFeed(indexPath) completion(true) } @@ -913,7 +913,7 @@ extension MainFeedCollectionViewController { } let title = NSLocalizedString("Copy Feed URL", comment: "Copy Feed URL") - let action = UIAction(title: title, image: Assets.Images.copy) { action in + let action = UIAction(title: title, image: Assets.Images.copy) { _ in UIPasteboard.general.url = url } return action @@ -926,7 +926,7 @@ extension MainFeedCollectionViewController { } let title = NSLocalizedString("Copy Feed URL", comment: "Copy Feed URL") - let action = UIAlertAction(title: title, style: .default) { action in + let action = UIAlertAction(title: title, style: .default) { _ in UIPasteboard.general.url = url completion(true) } @@ -941,7 +941,7 @@ extension MainFeedCollectionViewController { } let title = NSLocalizedString("Copy Home Page URL", comment: "Copy Home Page URL") - let action = UIAction(title: title, image: Assets.Images.copy) { action in + let action = UIAction(title: title, image: Assets.Images.copy) { _ in UIPasteboard.general.url = url } return action @@ -955,7 +955,7 @@ extension MainFeedCollectionViewController { } let title = NSLocalizedString("Copy Home Page URL", comment: "Copy Home Page URL") - let action = UIAlertAction(title: title, style: .default) { action in + let action = UIAlertAction(title: title, style: .default) { _ in UIPasteboard.general.url = url completion(true) } @@ -975,7 +975,7 @@ extension MainFeedCollectionViewController { completion(true) } - let action = UIAlertAction(title: title, style: .default) { [weak self] action in + let action = UIAlertAction(title: title, style: .default) { [weak self] _ in MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView, cancelCompletion: cancel) { [weak self] in self?.coordinator.markAllAsRead(Array(articles)) completion(true) @@ -987,7 +987,7 @@ extension MainFeedCollectionViewController { func deleteAction(indexPath: IndexPath) -> UIAction { let title = NSLocalizedString("Delete", comment: "Delete") - let action = UIAction(title: title, image: Assets.Images.trash, attributes: .destructive) { [weak self] action in + let action = UIAction(title: title, image: Assets.Images.trash, attributes: .destructive) { [weak self] _ in self?.delete(indexPath: indexPath) } return action @@ -995,7 +995,7 @@ extension MainFeedCollectionViewController { func renameAction(indexPath: IndexPath) -> UIAction { let title = NSLocalizedString("Rename", comment: "Rename") - let action = UIAction(title: title, image: Assets.Images.edit) { [weak self] action in + let action = UIAction(title: title, image: Assets.Images.edit) { [weak self] _ in self?.rename(indexPath: indexPath) } return action @@ -1007,7 +1007,7 @@ extension MainFeedCollectionViewController { } let title = NSLocalizedString("Get Info", comment: "Get Info") - let action = UIAction(title: title, image: Assets.Images.info) { [weak self] action in + let action = UIAction(title: title, image: Assets.Images.info) { [weak self] _ in self?.coordinator.showFeedInspector(for: feed) } return action @@ -1015,7 +1015,7 @@ extension MainFeedCollectionViewController { func getAccountInfoAction(account: Account) -> UIAction { let title = NSLocalizedString("Get Info", comment: "Get Info") - let action = UIAction(title: title, image: Assets.Images.info) { [weak self] action in + let action = UIAction(title: title, image: Assets.Images.info) { [weak self] _ in self?.coordinator.showAccountInspector(for: account) } return action @@ -1023,7 +1023,7 @@ extension MainFeedCollectionViewController { func deactivateAccountAction(account: Account) -> UIAction { let title = NSLocalizedString("Deactivate", comment: "Deactivate") - let action = UIAction(title: title, image: Assets.Images.deactivate) { action in + let action = UIAction(title: title, image: Assets.Images.deactivate) { _ in account.isActive = false } return action @@ -1035,7 +1035,7 @@ extension MainFeedCollectionViewController { } let title = NSLocalizedString("Get Info", comment: "Get Info") - let action = UIAlertAction(title: title, style: .default) { [weak self] action in + let action = UIAlertAction(title: title, style: .default) { [weak self] _ in self?.coordinator.showFeedInspector(for: feed) completion(true) } @@ -1051,7 +1051,7 @@ extension MainFeedCollectionViewController { let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command") let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, sidebarItem.nameForDisplay) as String - let action = UIAction(title: title, image: Assets.Images.markAllAsRead) { [weak self] action in + let action = UIAction(title: title, image: Assets.Images.markAllAsRead) { [weak self] _ in MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in if let articles = try? sidebarItem.fetchUnreadArticles() { self?.coordinator.markAllAsRead(Array(articles)) @@ -1063,13 +1063,13 @@ extension MainFeedCollectionViewController { } func markAllAsReadAction(account: Account, contentView: UIView?) -> UIAction? { - guard account.unreadCount > 0, let contentView = contentView else { + guard account.unreadCount > 0, let contentView else { return nil } let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command") let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, account.nameForDisplay) as String - let action = UIAction(title: title, image: Assets.Images.markAllAsRead) { [weak self] action in + let action = UIAction(title: title, image: Assets.Images.markAllAsRead) { [weak self] _ in MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in // If you don't have this delay the screen flashes when it executes this code DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { @@ -1095,7 +1095,7 @@ extension MainFeedCollectionViewController { alertController.addAction(UIAlertAction(title: cancelTitle, style: .cancel)) let renameTitle = NSLocalizedString("Rename", comment: "Rename") - let renameAction = UIAlertAction(title: renameTitle, style: .default) { [weak self] action in + let renameAction = UIAlertAction(title: renameTitle, style: .default) { [weak self] _ in guard let name = alertController.textFields?[0].text, !name.isEmpty else { return @@ -1126,7 +1126,7 @@ extension MainFeedCollectionViewController { alertController.addAction(renameAction) alertController.preferredAction = renameAction - alertController.addTextField() { textField in + alertController.addTextField { textField in textField.text = sidebarItem.nameForDisplay textField.placeholder = NSLocalizedString("Name", comment: "Name") textField.clearButtonMode = .always @@ -1147,7 +1147,7 @@ extension MainFeedCollectionViewController { title = NSLocalizedString("Delete Folder", comment: "Delete folder") let localizedInformativeText = NSLocalizedString("Are you sure you want to delete the “%@” folder?", comment: "Folder delete text") message = NSString.localizedStringWithFormat(localizedInformativeText as NSString, sidebarItem.nameForDisplay) as String - } else { + } else { title = NSLocalizedString("Delete Feed", comment: "Delete feed") let localizedInformativeText = NSLocalizedString("Are you sure you want to delete the “%@” feed?", comment: "Feed delete text") message = NSString.localizedStringWithFormat(localizedInformativeText as NSString, sidebarItem.nameForDisplay) as String @@ -1159,7 +1159,7 @@ extension MainFeedCollectionViewController { alertController.addAction(UIAlertAction(title: cancelTitle, style: .cancel)) let deleteTitle = NSLocalizedString("Delete", comment: "Delete") - let deleteAction = UIAlertAction(title: deleteTitle, style: .destructive) { [weak self] action in + let deleteAction = UIAlertAction(title: deleteTitle, style: .destructive) { [weak self] _ in self?.performDelete(indexPath: indexPath) } alertController.addAction(deleteAction) diff --git a/iOS/MainFeed/RefreshProgressView.swift b/iOS/MainFeed/RefreshProgressView.swift index 00fdb1553..716820b16 100644 --- a/iOS/MainFeed/RefreshProgressView.swift +++ b/iOS/MainFeed/RefreshProgressView.swift @@ -24,7 +24,7 @@ final class RefreshProgressView: UIView { accessibilityTraits = [.updatesFrequently, .notEnabled] } } - + func update() { if !AccountManager.shared.combinedRefreshProgress.isComplete { progressChanged(animated: false) diff --git a/iOS/MainFeed/ShadowTableChanges.swift b/iOS/MainFeed/ShadowTableChanges.swift index ad5e9a73f..eb42aa4f4 100644 --- a/iOS/MainFeed/ShadowTableChanges.swift +++ b/iOS/MainFeed/ShadowTableChanges.swift @@ -66,10 +66,4 @@ struct ShadowTableChanges { var moves: Set? var rowChanges: [RowChanges]? - init(deletes: Set?, inserts: Set?, moves: Set?, rowChanges: [RowChanges]?) { - self.deletes = deletes - self.inserts = inserts - self.moves = moves - self.rowChanges = rowChanges - } } diff --git a/iOS/MainTimeline/MainTimelineViewController.swift b/iOS/MainTimeline/MainTimelineViewController.swift index 08b7758f2..3f540b61e 100644 --- a/iOS/MainTimeline/MainTimelineViewController.swift +++ b/iOS/MainTimeline/MainTimelineViewController.swift @@ -271,7 +271,7 @@ final class MainTimelineViewController: UITableViewController, UndoableCommandRu } } - if sender as? UIKeyCommand != nil { + if sender is UIKeyCommand { guard let indexPath = tableView.indexPathForSelectedRow, let contentView = tableView.cellForRow(at: indexPath)?.contentView else { return } @@ -1079,7 +1079,9 @@ private extension MainTimelineViewController { } func openInBrowserAction(_ article: Article) -> UIAction? { - guard let _ = article.preferredURL else { return nil } + guard article.preferredURL != nil else { + return nil + } let title = NSLocalizedString("Open in Browser", comment: "Open in Browser") let action = UIAction(title: title, image: Assets.Images.safari) { [weak self] _ in self?.showBrowserForArticle(article) @@ -1088,7 +1090,9 @@ private extension MainTimelineViewController { } func openInBrowserAlertAction(_ article: Article, completion: @escaping (Bool) -> Void) -> UIAlertAction? { - guard let _ = article.preferredURL else { return nil } + guard article.preferredURL != nil else { + return nil + } let title = NSLocalizedString("Open in Browser", comment: "Open in Browser") let action = UIAlertAction(title: title, style: .default) { [weak self] _ in diff --git a/iOS/MainTimeline/MarkAsReadAlertController.swift b/iOS/MainTimeline/MarkAsReadAlertController.swift index 2d89a8fb8..c6107c4da 100644 --- a/iOS/MainTimeline/MarkAsReadAlertController.swift +++ b/iOS/MainTimeline/MarkAsReadAlertController.swift @@ -17,13 +17,13 @@ extension UIBarButtonItem: MarkAsReadAlertControllerSourceType {} @MainActor struct MarkAsReadAlertController { static func confirm(_ controller: UIViewController?, - coordinator: SceneCoordinator?, - confirmTitle: String, - sourceType: T, - cancelCompletion: (() -> Void)? = nil, - completion: @escaping () -> Void) where T: MarkAsReadAlertControllerSourceType { + coordinator: SceneCoordinator?, + confirmTitle: String, + sourceType: T, + cancelCompletion: (() -> Void)? = nil, + completion: @escaping () -> Void) where T: MarkAsReadAlertControllerSourceType { - guard let controller = controller, let coordinator = coordinator else { + guard let controller, let coordinator else { completion() return } @@ -39,10 +39,10 @@ extension UIBarButtonItem: MarkAsReadAlertControllerSourceType {} } private static func alert(coordinator: SceneCoordinator, - confirmTitle: String, - cancelCompletion: (() -> Void)?, - sourceType: T, - completion: @escaping (UIAlertAction) -> Void) -> UIAlertController where T: MarkAsReadAlertControllerSourceType { + confirmTitle: String, + cancelCompletion: (() -> Void)?, + sourceType: T, + completion: @escaping (UIAlertAction) -> Void) -> UIAlertController where T: MarkAsReadAlertControllerSourceType { let title = NSLocalizedString("Mark As Read", comment: "Mark As Read") let message = NSLocalizedString("You can turn this confirmation off in Settings.", diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 3d7c8f5cd..257060226 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -454,7 +454,7 @@ struct FeedNode: Hashable, Sendable { @objc func unreadCountDidChange(_ note: Notification) { // We will handle the filtering of unread feeds in unreadCountDidInitialize after they have all be calculated guard AccountManager.shared.areUnreadCountsInitialized else { - return + return } queueRebuildBackingStores() @@ -616,7 +616,7 @@ struct FeedNode: Hashable, Sendable { self.mainFeedCollectionViewController?.navigationItem.subtitle = refreshText // If unread count > 0, add unread string to timeline - if let _ = timelineFeed, timelineUnreadCount > 0 { + if timelineFeed != nil, timelineUnreadCount > 0 { let localizedUnreadCount = NSLocalizedString("%i Unread", comment: "14 Unread") let unreadCount = NSString.localizedStringWithFormat(localizedUnreadCount as NSString, timelineUnreadCount) as String self.mainTimelineViewController?.updateNavigationBarSubtitle(unreadCount) @@ -633,7 +633,7 @@ struct FeedNode: Hashable, Sendable { self.mainFeedCollectionViewController?.navigationItem.subtitle = NSLocalizedString("Updated Just Now", comment: "Updated Just Now") // If unread count > 0, add unread string to timeline - if let _ = timelineFeed, timelineUnreadCount > 0 { + if timelineFeed != nil, timelineUnreadCount > 0 { let localizedUnreadCount = NSLocalizedString("%i Unread", comment: "14 Unread") let refreshTextWithUnreadCount = NSString.localizedStringWithFormat(localizedUnreadCount as NSString, timelineUnreadCount) as String self.mainTimelineViewController?.updateNavigationBarSubtitle(refreshTextWithUnreadCount) @@ -649,7 +649,7 @@ struct FeedNode: Hashable, Sendable { } else { self.mainFeedCollectionViewController?.navigationItem.subtitle = "" // If unread count > 0, add unread string to timeline - if let _ = timelineFeed, timelineUnreadCount > 0 { + if timelineFeed != nil, timelineUnreadCount > 0 { let localizedUnreadCount = NSLocalizedString("%i Unread", comment: "14 Unread") let refreshTextWithUnreadCount = NSString.localizedStringWithFormat(localizedUnreadCount as NSString, timelineUnreadCount) as String self.mainTimelineViewController?.updateNavigationBarSubtitle(refreshTextWithUnreadCount) @@ -1121,7 +1121,7 @@ struct FeedNode: Hashable, Sendable { self.mainTimelineViewController?.hideSearch() } - selectNextUnreadFeed() { + selectNextUnreadFeed { self.selectNextUnreadArticleInTimeline() } } diff --git a/iOS/SceneDelegate.swift b/iOS/SceneDelegate.swift index 36bf3b906..02e44b09f 100644 --- a/iOS/SceneDelegate.swift +++ b/iOS/SceneDelegate.swift @@ -43,7 +43,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate { NotificationCenter.default.addObserver(self, selector: #selector(handleUserInterfaceColorPaletteDidUpdate(_:)), name: .userInterfaceColorPaletteDidUpdate, object: AppDefaults.self) - if let _ = connectionOptions.urlContexts.first?.url { + if connectionOptions.urlContexts.first?.url != nil { self.scene(scene, openURLContexts: connectionOptions.urlContexts) return } @@ -136,7 +136,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate { if AccountManager.shared.isSuspended { AccountManager.shared.resumeAll() } - self.coordinator.selectAllUnreadFeed() { + self.coordinator.selectAllUnreadFeed { self.coordinator.selectArticleInCurrentFeed(id!) } } else { @@ -152,7 +152,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate { if AccountManager.shared.isSuspended { AccountManager.shared.resumeAll() } - self.coordinator.selectTodayFeed() { + self.coordinator.selectTodayFeed { self.coordinator.selectArticleInCurrentFeed(id!) } } else { @@ -168,7 +168,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate { if AccountManager.shared.isSuspended { AccountManager.shared.resumeAll() } - self.coordinator.selectStarredFeed() { + self.coordinator.selectStarredFeed { self.coordinator.selectArticleInCurrentFeed(id!) } } else { @@ -196,7 +196,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate { DispatchQueue.main.async { NotificationCenter.default.post(name: .didBeginDownloadingTheme, object: nil) } - let task = URLSession.shared.downloadTask(with: request) { location, response, error in + let task = URLSession.shared.downloadTask(with: request) { location, _, error in guard let location = location else { return }