diff --git a/Intents/AddWebFeedIntentHandler.swift b/Intents/AddWebFeedIntentHandler.swift index 401434cc6..f87259ea5 100644 --- a/Intents/AddWebFeedIntentHandler.swift +++ b/Intents/AddWebFeedIntentHandler.swift @@ -37,7 +37,7 @@ public class AddWebFeedIntentHandler: NSObject, AddWebFeedIntentHandling { guard let extensionContainers = await ExtensionContainersFile.read() else { throw AddWebFeedIntentHandlerError.communicationFailure } - + let accountNames = extensionContainers.accounts.map { $0.name } return accountNames } @@ -46,7 +46,7 @@ public class AddWebFeedIntentHandler: NSObject, AddWebFeedIntentHandling { guard let accountName = intent.accountName else { return .notRequired() } - + guard let extensionContainers = await ExtensionContainersFile.read() else { return .unsupported(forReason: .communication) } diff --git a/Mac/AppDefaults.swift b/Mac/AppDefaults.swift index d66319609..7315294be 100644 --- a/Mac/AppDefaults.swift +++ b/Mac/AppDefaults.swift @@ -65,7 +65,7 @@ final class AppDefaults: Sendable { }() let isFirstRun: Bool = { - if let _ = UserDefaults.standard.object(forKey: Key.firstRunDate) as? Date { + if UserDefaults.standard.object(forKey: Key.firstRunDate) as? Date != nil { return false } firstRunDate = Date() diff --git a/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift b/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift index 90876796a..71d3a9243 100644 --- a/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift +++ b/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift @@ -31,7 +31,7 @@ final class BuiltinSmartFeedInspectorViewController: NSViewController, Inspector func canInspect(_ objects: [Any]) -> Bool { - guard let _ = singleSmartFeed(from: objects) else { + guard singleSmartFeed(from: objects) != nil else { return false } return true diff --git a/Mac/Inspector/FeedInspectorViewController.swift b/Mac/Inspector/FeedInspectorViewController.swift index bc369450e..d7181182d 100644 --- a/Mac/Inspector/FeedInspectorViewController.swift +++ b/Mac/Inspector/FeedInspectorViewController.swift @@ -63,7 +63,7 @@ final class FeedInspectorViewController: NSViewController, Inspector { // MARK: Actions @IBAction func isNotifyAboutNewArticlesChanged(_ sender: Any) { - guard authorizationStatus != nil else { + guard authorizationStatus != nil else { DispatchQueue.main.async { self.isNotifyAboutNewArticlesCheckBox.setNextState() } @@ -85,7 +85,7 @@ final class FeedInspectorViewController: NSViewController, Inspector { self.feed?.isNotifyAboutNewArticles = (self.isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false } } else { - UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in + UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { granted, _ in Task { @MainActor in self.updateNotificationSettings() if granted { diff --git a/Mac/Inspector/FolderInspectorViewController.swift b/Mac/Inspector/FolderInspectorViewController.swift index 840e4896d..d7d50bbd9 100644 --- a/Mac/Inspector/FolderInspectorViewController.swift +++ b/Mac/Inspector/FolderInspectorViewController.swift @@ -35,8 +35,7 @@ final class FolderInspectorViewController: NSViewController, Inspector { var windowTitle: String = NSLocalizedString("Folder Inspector", comment: "Folder Inspector window title") func canInspect(_ objects: [Any]) -> Bool { - - guard let _ = singleFolder(from: objects) else { + guard singleFolder(from: objects) != nil else { return false } return true diff --git a/Mac/Inspector/InspectorWindowController.swift b/Mac/Inspector/InspectorWindowController.swift index 7665b0910..1ebbd6fa0 100644 --- a/Mac/Inspector/InspectorWindowController.swift +++ b/Mac/Inspector/InspectorWindowController.swift @@ -108,7 +108,7 @@ private extension InspectorWindowController { DispatchQueue.main.async { window.title = inspector.windowTitle - } + } let flippedOrigin = window.flippedOrigin diff --git a/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift b/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift index 71bdf0dcb..83637d2bb 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift @@ -119,7 +119,7 @@ extension SidebarViewController { NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu)) } } else { - UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in + UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { granted, _ in if granted { DispatchQueue.main.async { if feed.isNotifyAboutNewArticles == nil { feed.isNotifyAboutNewArticles = false } @@ -215,7 +215,7 @@ private extension SidebarViewController { menu.addItem(NSMenuItem.separator()) } - if let homePageURL = feed.homePageURL, let _ = URL(string: homePageURL) { + if let homePageURL = feed.homePageURL, URL(string: homePageURL) != nil { let item = menuItem(NSLocalizedString("Open Home Page", comment: "Command"), #selector(openHomePageFromContextualMenu(_:)), homePageURL, image: Assets.Images.openInBrowser) menu.addItem(item) menu.addItem(NSMenuItem.separator()) diff --git a/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift b/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift index 4de29692e..a9e3ca095 100644 --- a/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift +++ b/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift @@ -38,7 +38,7 @@ extension Article: @retroactive PasteboardWriterOwner { func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] { var types = [ArticlePasteboardWriter.articleUTIType] - if article.preferredURL != nil{ + if article.preferredURL != nil { types += [.URL] } types += [.string, .html, ArticlePasteboardWriter.articleUTIInternalType] @@ -182,6 +182,6 @@ private extension ArticlePasteboardWriter { guard let authors = article.authors, !authors.isEmpty else { return nil } - return authors.map{ authorDictionary($0) } + return authors.map { authorDictionary($0) } } } diff --git a/Mac/SafariExtension/SafariExtensionHandler.swift b/Mac/SafariExtension/SafariExtensionHandler.swift index f2c17a056..fc0944b11 100644 --- a/Mac/SafariExtension/SafariExtensionHandler.swift +++ b/Mac/SafariExtension/SafariExtensionHandler.swift @@ -41,7 +41,7 @@ final class SafariExtensionHandler: SFSafariExtensionHandler { } override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String: Any]?) { - if (messageName == "subscribeToFeed") { + if messageName == "subscribeToFeed" { if var feedURLString = userInfo?["url"] as? String { var openInDefaultBrowser = false @@ -61,7 +61,7 @@ final class SafariExtensionHandler: SFSafariExtensionHandler { NSWorkspace.shared.open(feedURL) } } - } else if (messageName == "pong") { + } else if messageName == "pong" { if let validationIDString = userInfo?["validationID"] as? String { // Should we validate the button? let shouldValidate = userInfo?["shouldValidate"] as? Bool ?? false diff --git a/Mac/Scripting/Folder+Scriptability.swift b/Mac/Scripting/Folder+Scriptability.swift index 1b4898e12..58e1cb5b3 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"} */ - class func handleCreateElement(command: NSCreateCommand) -> Any? { + static func handleCreateElement(command: NSCreateCommand) -> Any? { guard command.isCreateCommand(forClass: "fold") else { return nil } @@ -147,7 +147,7 @@ import RSCore } @objc(opmlRepresentation) - var opmlRepresentation: String { + var opmlRepresentation: String { folder.OPMLString(indentLevel: 0) } } diff --git a/Mac/ShareExtension/ShareViewController.swift b/Mac/ShareExtension/ShareViewController.swift index 14f7fa293..e2050f2a1 100644 --- a/Mac/ShareExtension/ShareViewController.swift +++ b/Mac/ShareExtension/ShareViewController.swift @@ -39,7 +39,7 @@ final class ShareViewController: NSViewController { extensionContainers = ExtensionContainersFile.read() buildFolderPopupMenu() - var provider: NSItemProvider? = nil + var provider: NSItemProvider? // Try to get any HTML that is maybe passed in for item in self.extensionContext!.inputItems as! [NSExtensionItem] { @@ -50,7 +50,7 @@ final class ShareViewController: NSViewController { } } - if provider != nil { + if provider != nil { provider!.loadItem(forTypeIdentifier: UTType.propertyList.identifier, options: nil, completionHandler: { [weak self] (pList, error) in if error != nil { return @@ -77,7 +77,7 @@ final class ShareViewController: NSViewController { } } - if provider != nil { + if provider != nil { provider!.loadItem(forTypeIdentifier: UTType.url.identifier, options: nil, completionHandler: { [weak self] (urlCoded, error) in if error != nil { return @@ -126,7 +126,7 @@ private extension ShareViewController { } let defaultContainer = ShareDefaultContainer.defaultContainer(containers: extensionContainers) - var defaultMenuItem: NSMenuItem? = nil + var defaultMenuItem: NSMenuItem? for account in extensionContainers.accounts { diff --git a/Modules/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift b/Modules/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift index e6b0c6bc8..2246e4fda 100644 --- a/Modules/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift +++ b/Modules/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift @@ -32,7 +32,7 @@ public struct FeedSpecifier: Hashable, Sendable { self.source = source self.orderFound = orderFound } - + /// Some feed URLs are known in advance. Save time/bandwidth by special-casing those. static func knownFeedSpecifier(url: URL) -> FeedSpecifier? { if url.isRachelByTheBayURL { diff --git a/Modules/FeedFinder/Sources/FeedFinder/HTMLFeedFinder.swift b/Modules/FeedFinder/Sources/FeedFinder/HTMLFeedFinder.swift index f2747d2ca..980a23d7b 100644 --- a/Modules/FeedFinder/Sources/FeedFinder/HTMLFeedFinder.swift +++ b/Modules/FeedFinder/Sources/FeedFinder/HTMLFeedFinder.swift @@ -25,7 +25,7 @@ final class HTMLFeedFinder { for oneFeedLink in metadata.feedLinks { if let oneURLString = oneFeedLink.urlString?.normalizedURL { - orderFound = orderFound + 1 + orderFound += 1 let oneFeedSpecifier = FeedSpecifier(title: oneFeedLink.title, urlString: oneURLString, source: .HTMLHead, orderFound: orderFound) addFeedSpecifier(oneFeedSpecifier) } @@ -34,7 +34,7 @@ final class HTMLFeedFinder { let bodyLinks = RSHTMLLinkParser.htmlLinks(with: parserData) for oneBodyLink in bodyLinks { if linkMightBeFeed(oneBodyLink), let normalizedURL = oneBodyLink.urlString?.normalizedURL { - orderFound = orderFound + 1 + orderFound += 1 let oneFeedSpecifier = FeedSpecifier(title: oneBodyLink.text, urlString: normalizedURL, source: .HTMLLink, orderFound: orderFound) addFeedSpecifier(oneFeedSpecifier) } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift b/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift index 7ebe03223..c027ec340 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/NSTableView+RSCore.swift @@ -45,7 +45,7 @@ public extension NSTableView { } let rMidY = NSMidY(r) - var scrollPoint = NSZeroPoint + 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 = NSMakeRect(scrollPoint.x, scrollPoint.y, NSWidth(clipView.bounds), NSHeight(clipView.bounds)) + let rClipView = NSRect(x: scrollPoint.x, y: scrollPoint.y, width: NSWidth(clipView.bounds), height: NSHeight(clipView.bounds)) clipView.animator().bounds = rClipView } diff --git a/Modules/RSCore/Sources/RSCore/CoalescingQueue.swift b/Modules/RSCore/Sources/RSCore/CoalescingQueue.swift index 1945efd0f..e7840f27c 100644 --- a/Modules/RSCore/Sources/RSCore/CoalescingQueue.swift +++ b/Modules/RSCore/Sources/RSCore/CoalescingQueue.swift @@ -71,7 +71,7 @@ private extension CoalescingQueue { func add(_ call: QueueCall) { restartTimer() - + if !calls.contains(call) { calls.append(call) } diff --git a/Modules/RSCore/Sources/RSCore/String+RSCore.swift b/Modules/RSCore/Sources/RSCore/String+RSCore.swift index f096f63f3..4dd63287e 100644 --- a/Modules/RSCore/Sources/RSCore/String+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/String+RSCore.swift @@ -82,7 +82,7 @@ public extension String { let s = self.trimmingWhitespace - if (s.isEmpty || (!s.contains(".") && !s.mayBeIPv6URL && !s.hostMayBeLocalhost)) { + if s.isEmpty || (!s.contains(".") && !s.mayBeIPv6URL && !s.hostMayBeLocalhost) { return false } @@ -274,7 +274,7 @@ public extension String { escaped.append(char) } } - + return escaped } diff --git a/Modules/RSTree/Sources/RSTree/Node.swift b/Modules/RSTree/Sources/RSTree/Node.swift index 5a15e7e5a..fc1ee9ae6 100644 --- a/Modules/RSTree/Sources/RSTree/Node.swift +++ b/Modules/RSTree/Sources/RSTree/Node.swift @@ -159,7 +159,7 @@ import Foundation // MARK: - Equatable - nonisolated public class func ==(lhs: Node, rhs: Node) -> Bool { + nonisolated public static func ==(lhs: Node, rhs: Node) -> Bool { lhs === rhs } } diff --git a/Modules/RSTree/Sources/RSTree/TreeController.swift b/Modules/RSTree/Sources/RSTree/TreeController.swift index f8b275b97..d2e51091e 100644 --- a/Modules/RSTree/Sources/RSTree/TreeController.swift +++ b/Modules/RSTree/Sources/RSTree/TreeController.swift @@ -109,12 +109,12 @@ private extension TreeController { let childNodes = delegate?.treeController(treeController: self, childNodesFor: node) ?? [Node]() childNodesDidChange = !nodeArraysAreEqual(childNodes, node.childNodes) - if (childNodesDidChange) { + if childNodesDidChange { node.childNodes = childNodes } - childNodes.forEach{ (oneChildNode) in - if rebuildChildNodes(node: oneChildNode) { + for childNode in childNodes { + if rebuildChildNodes(node: childNode) { childNodesDidChange = true } }