From dbaa8142e1897601756d82a699ba60c9aceea9ae Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Thu, 1 Jan 2026 18:07:54 -0800 Subject: [PATCH] Fix various SwiftLint warnings. --- Mac/MainWindow/AddFeed/AddFeedController.swift | 13 ++++--------- .../AddFolder/AddFolderWindowController.swift | 2 +- Mac/MainWindow/MainWindowController.swift | 10 ++++------ Mac/MainWindow/Sidebar/Cell/SidebarCell.swift | 2 +- .../Sidebar/SidebarOutlineDataSource.swift | 2 +- Mac/MainWindow/Sidebar/SidebarOutlineView.swift | 2 +- Mac/MainWindow/Sidebar/SidebarWindowState.swift | 3 +-- Mac/MainWindow/Sidebar/UnreadCountView.swift | 2 +- Mac/MainWindow/Timeline/TimelineTableRowView.swift | 2 +- Mac/MainWindow/Timeline/TimelineWindowState.swift | 2 +- iOS/Account/FeedbinAccountViewController.swift | 2 +- iOS/AppDefaults.swift | 4 ++-- iOS/AppDelegate.swift | 6 +++--- iOS/Article/ImageScrollView.swift | 2 +- iOS/Article/ImageTransition.swift | 4 ++-- iOS/ArticleActivityItemSource.swift | 2 +- iOS/Inspector/FeedInspectorViewController.swift | 4 ++-- iOS/MainTimeline/MainTimelineDataSource.swift | 6 ++---- iOS/MainTimeline/MainTimelineViewController.swift | 2 +- 19 files changed, 31 insertions(+), 41 deletions(-) diff --git a/Mac/MainWindow/AddFeed/AddFeedController.swift b/Mac/MainWindow/AddFeed/AddFeedController.swift index 90309da15..b8ad13046 100644 --- a/Mac/MainWindow/AddFeed/AddFeedController.swift +++ b/Mac/MainWindow/AddFeed/AddFeedController.swift @@ -23,7 +23,6 @@ import RSParser // display error sheet. @MainActor final class AddFeedController: AddFeedWindowControllerDelegate { - private let hostWindow: NSWindow private var addFeedWindowController: AddFeedWindowController? private var foundFeedURLString: String? @@ -47,7 +46,7 @@ import RSParser windowController.runSheetOnWindow(hostWindow) } - // MARK: AddFeedWindowControllerDelegate + // MARK: - AddFeedWindowControllerDelegate func addFeedWindowController(_: AddFeedWindowController, userEnteredURL url: URL, userEnteredTitle title: String?, container: Container) { closeAddFeedSheet(NSApplication.ModalResponse.OK) @@ -92,11 +91,9 @@ import RSParser func addFeedWindowControllerUserDidCancel(_: AddFeedWindowController) { closeAddFeedSheet(NSApplication.ModalResponse.cancel) } - } private extension AddFeedController { - var urlStringFromPasteboard: String? { if let urlString = NSPasteboard.urlString(from: NSPasteboard.general) { return urlString.normalizedURL @@ -125,7 +122,7 @@ private extension AddFeedController { } } - // MARK: Errors + // MARK: - Errors func showAlreadySubscribedError(_ urlString: String) { let alert = NSAlert() @@ -154,16 +151,14 @@ private extension AddFeedController { alert.beginSheetModal(for: hostWindow) } - // MARK: Progress + // MARK: - Progress func beginShowingProgress() { - IndeterminateProgressController.beginProgressWithMessage(NSLocalizedString("Finding feed…", comment:"Feed finder")) + IndeterminateProgressController.beginProgressWithMessage(NSLocalizedString("Finding feed…", comment: "Feed finder")) } func endShowingProgress() { IndeterminateProgressController.endProgress() hostWindow.makeKeyAndOrderFront(self) } - } - diff --git a/Mac/MainWindow/AddFolder/AddFolderWindowController.swift b/Mac/MainWindow/AddFolder/AddFolderWindowController.swift index c1bedf634..8cc7a3aba 100644 --- a/Mac/MainWindow/AddFolder/AddFolderWindowController.swift +++ b/Mac/MainWindow/AddFolder/AddFolderWindowController.swift @@ -10,7 +10,7 @@ import AppKit import Articles import Account -final class AddFolderWindowController : NSWindowController { +final class AddFolderWindowController: NSWindowController { @IBOutlet var folderNameTextField: NSTextField! @IBOutlet var accountPopupButton: NSPopUpButton! diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index a36bbacd7..c47b1f1ae 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -16,8 +16,7 @@ enum TimelineSourceMode { case regular, search } -final class MainWindowController : NSWindowController, NSUserInterfaceValidations { - +final class MainWindowController: NSWindowController, NSUserInterfaceValidations { @IBOutlet var articleThemePopUpButton: NSPopUpButton? private var activityManager = ActivityManager() @@ -118,14 +117,14 @@ final class MainWindowController : NSWindowController, NSUserInterfaceValidation func handle(_ response: UNNotificationResponse) { let userInfo = response.notification.request.content.userInfo - guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable : Any] else { return } + guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable: Any] else { return } sidebarViewController?.deepLinkRevealAndSelect(for: articlePathUserInfo) currentTimelineViewController?.goToDeepLink(for: articlePathUserInfo) } func handle(_ activity: NSUserActivity) { guard let userInfo = activity.userInfo else { return } - guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable : Any] else { return } + guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable: Any] else { return } sidebarViewController?.deepLinkRevealAndSelect(for: articlePathUserInfo) currentTimelineViewController?.goToDeepLink(for: articlePathUserInfo) } @@ -741,8 +740,7 @@ extension MainWindowController: ArticleExtractorDelegate { but for now, we'll keep the stratification of visibility */ -extension MainWindowController : ScriptingMainWindowController { - +extension MainWindowController: ScriptingMainWindowController { internal var scriptingCurrentArticle: Article? { return self.oneSelectedArticle } diff --git a/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift b/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift index dcaf1d927..d582caa99 100644 --- a/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift +++ b/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift @@ -11,7 +11,7 @@ import RSCore import Account import RSTree -final class SidebarCell : NSTableCellView { +final class SidebarCell: NSTableCellView { var iconImage: IconImage? { didSet { diff --git a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift index e52563ddd..33ad61f87 100644 --- a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift +++ b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift @@ -374,7 +374,7 @@ private extension SidebarOutlineDataSource { guard let sourceAccountID = pasteboardFeed.accountID, let sourceAccount = AccountManager.shared.existingAccount(accountID: sourceAccountID), let feedID = pasteboardFeed.feedID, - let feed = sourceAccount.existingFeed(withFeedID: feedID), + let feed = sourceAccount.existingFeed(withFeedID: feedID), let destinationContainer = parentNode.representedObject as? Container else { return diff --git a/Mac/MainWindow/Sidebar/SidebarOutlineView.swift b/Mac/MainWindow/Sidebar/SidebarOutlineView.swift index 00d1b1dd2..951efa868 100644 --- a/Mac/MainWindow/Sidebar/SidebarOutlineView.swift +++ b/Mac/MainWindow/Sidebar/SidebarOutlineView.swift @@ -10,7 +10,7 @@ import AppKit import RSCore import RSTree -final class SidebarOutlineView : NSOutlineView { +final class SidebarOutlineView: NSOutlineView { @IBOutlet var keyboardDelegate: KeyboardDelegate! diff --git a/Mac/MainWindow/Sidebar/SidebarWindowState.swift b/Mac/MainWindow/Sidebar/SidebarWindowState.swift index 074b350fc..12b434715 100644 --- a/Mac/MainWindow/Sidebar/SidebarWindowState.swift +++ b/Mac/MainWindow/Sidebar/SidebarWindowState.swift @@ -9,14 +9,13 @@ import Foundation final class SidebarWindowState: NSObject, NSSecureCoding { - static let supportsSecureCoding = true let isReadFiltered: Bool let expandedContainers: [[String: String]] let selectedFeeds: [[String: String]] - init(isReadFiltered: Bool, expandedContainers: [[String : String]], selectedFeeds: [[String : String]]) { + init(isReadFiltered: Bool, expandedContainers: [[String: String]], selectedFeeds: [[String: String]]) { self.isReadFiltered = isReadFiltered self.expandedContainers = expandedContainers self.selectedFeeds = selectedFeeds diff --git a/Mac/MainWindow/Sidebar/UnreadCountView.swift b/Mac/MainWindow/Sidebar/UnreadCountView.swift index 9005fc4a1..54a9d2957 100644 --- a/Mac/MainWindow/Sidebar/UnreadCountView.swift +++ b/Mac/MainWindow/Sidebar/UnreadCountView.swift @@ -8,7 +8,7 @@ import AppKit -final class UnreadCountView : NSView { +final class UnreadCountView: NSView { @MainActor struct Appearance { static let padding = NSEdgeInsets(top: 1.0, left: 7.0, bottom: 1.0, right: 7.0) static let cornerRadius: CGFloat = 8.0 diff --git a/Mac/MainWindow/Timeline/TimelineTableRowView.swift b/Mac/MainWindow/Timeline/TimelineTableRowView.swift index 0dffa9c71..3f7fb8cfa 100644 --- a/Mac/MainWindow/Timeline/TimelineTableRowView.swift +++ b/Mac/MainWindow/Timeline/TimelineTableRowView.swift @@ -8,7 +8,7 @@ import AppKit -final class TimelineTableRowView : NSTableRowView { +final class TimelineTableRowView: NSTableRowView { private var separator: NSView? diff --git a/Mac/MainWindow/Timeline/TimelineWindowState.swift b/Mac/MainWindow/Timeline/TimelineWindowState.swift index 3882d3dd1..720744f66 100644 --- a/Mac/MainWindow/Timeline/TimelineWindowState.swift +++ b/Mac/MainWindow/Timeline/TimelineWindowState.swift @@ -17,7 +17,7 @@ final class TimelineWindowState: NSObject, NSSecureCoding { let selectedAccountID: String? let selectedArticleID: String? - init(readArticlesFilterStateKeys: [[String : String]], readArticlesFilterStateValues: [Bool], selectedAccountID: String? = nil, selectedArticleID: String? = nil) { + init(readArticlesFilterStateKeys: [[String: String]], readArticlesFilterStateValues: [Bool], selectedAccountID: String? = nil, selectedArticleID: String? = nil) { self.readArticlesFilterStateKeys = readArticlesFilterStateKeys self.readArticlesFilterStateValues = readArticlesFilterStateValues self.selectedAccountID = selectedAccountID diff --git a/iOS/Account/FeedbinAccountViewController.swift b/iOS/Account/FeedbinAccountViewController.swift index 9e0d8a4f9..cecbdc553 100644 --- a/iOS/Account/FeedbinAccountViewController.swift +++ b/iOS/Account/FeedbinAccountViewController.swift @@ -156,7 +156,7 @@ final class FeedbinAccountViewController: UITableViewController { presentError(title: NSLocalizedString("Error", comment: "Credentials Error"), message: message) } - private func setNavigationEnabled(to value:Bool){ + private func setNavigationEnabled(to value: Bool) { cancelBarButtonItem.isEnabled = value actionButton.isEnabled = value } diff --git a/iOS/AppDefaults.swift b/iOS/AppDefaults.swift index 5a6ead901..ab85440af 100644 --- a/iOS/AppDefaults.swift +++ b/iOS/AppDefaults.swift @@ -374,7 +374,7 @@ final class AppDefaults: Sendable { } @MainActor static func registerDefaults() { - let defaults: [String : Any] = [Key.userInterfaceColorPalette: UserInterfaceColorPalette.automatic.rawValue, + let defaults: [String: Any] = [Key.userInterfaceColorPalette: UserInterfaceColorPalette.automatic.rawValue, Key.timelineGroupByFeed: false, Key.refreshClearsReadArticles: false, Key.timelineNumberOfLines: 2, @@ -432,7 +432,7 @@ private extension AppDefaults { AppDefaults.store.set(date, forKey: key) } - static func sortDirection(for key:String) -> ComparisonResult { + static func sortDirection(for key: String) -> ComparisonResult { let rawInt = int(for: key) if rawInt == ComparisonResult.orderedAscending.rawValue { return .orderedAscending diff --git a/iOS/AppDelegate.swift b/iOS/AppDelegate.swift index 410333d63..bbe5a517a 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, error) in if granted { DispatchQueue.main.async { UIApplication.shared.registerForRemoteNotifications() @@ -106,7 +106,7 @@ import Secrets } - func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { + func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { Task { @MainActor in self.resumeDatabaseProcessingIfNecessary() await AccountManager.shared.receiveRemoteNotification(userInfo: userInfo) @@ -410,7 +410,7 @@ private extension AppDelegate { } private func handleStatusNotification(userInfo: [AnyHashable: Any], statusKey: ArticleStatus.Key) { - guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable : Any], + guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable: Any], let accountID = articlePathUserInfo[ArticlePathKey.accountID] as? String, let articleID = articlePathUserInfo[ArticlePathKey.articleID] as? String else { return diff --git a/iOS/Article/ImageScrollView.swift b/iOS/Article/ImageScrollView.swift index 2ed5b3ed7..408757527 100644 --- a/iOS/Article/ImageScrollView.swift +++ b/iOS/Article/ImageScrollView.swift @@ -146,7 +146,7 @@ open class ImageScrollView: UIScrollView { } private func maximumContentOffset() -> CGPoint { - return CGPoint(x: contentSize.width - bounds.width,y:contentSize.height - bounds.height) + CGPoint(x: contentSize.width - bounds.width, y: contentSize.height - bounds.height) } private func minimumContentOffset() -> CGPoint { diff --git a/iOS/Article/ImageTransition.swift b/iOS/Article/ImageTransition.swift index 63f7f25d1..a4a861c02 100644 --- a/iOS/Article/ImageTransition.swift +++ b/iOS/Article/ImageTransition.swift @@ -48,7 +48,7 @@ final class ImageTransition: NSObject, UIViewControllerAnimatedTransitioning { UIView.animate( withDuration: duration, - delay:0.0, + delay: 0.0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.2, animations: { @@ -87,7 +87,7 @@ final class ImageTransition: NSObject, UIViewControllerAnimatedTransitioning { UIView.animate( withDuration: duration, - delay:0.0, + delay: 0.0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.2, animations: { diff --git a/iOS/ArticleActivityItemSource.swift b/iOS/ArticleActivityItemSource.swift index 2b3e10f01..5fd2a5240 100644 --- a/iOS/ArticleActivityItemSource.swift +++ b/iOS/ArticleActivityItemSource.swift @@ -18,7 +18,7 @@ final class ArticleActivityItemSource: NSObject, UIActivityItemSource { self.subject = subject } - func activityViewControllerPlaceholderItem(_ : UIActivityViewController) -> Any { + func activityViewControllerPlaceholderItem(_: UIActivityViewController) -> Any { return url } diff --git a/iOS/Inspector/FeedInspectorViewController.swift b/iOS/Inspector/FeedInspectorViewController.swift index 7c16d5835..47cb1cc58 100644 --- a/iOS/Inspector/FeedInspectorViewController.swift +++ b/iOS/Inspector/FeedInspectorViewController.swift @@ -84,7 +84,7 @@ final class FeedInspectorViewController: UITableViewController { } else if authorizationStatus == .authorized { feed.isNotifyAboutNewArticles = notifyAboutNewArticlesSwitch.isOn } else { - UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .sound, .alert]) { (granted, error) in + UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in Task { @MainActor in self.updateNotificationSettings() if granted { @@ -215,7 +215,7 @@ extension FeedInspectorViewController { let alert = UIAlertController(title: NSLocalizedString("Enable Notifications", comment: "Notifications"), message: NSLocalizedString("Notifications need to be enabled in the Settings app.", comment: "Notifications need to be enabled in the Settings app."), preferredStyle: .alert) let openSettings = UIAlertAction(title: NSLocalizedString("Open Settings", comment: "Open Settings"), style: .default) { (action) in - UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [UIApplication.OpenExternalURLOptionsKey.universalLinksOnly : false], completionHandler: nil) + UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [UIApplication.OpenExternalURLOptionsKey.universalLinksOnly: false], completionHandler: nil) } let dismiss = UIAlertAction(title: NSLocalizedString("Dismiss", comment: "Dismiss"), style: .cancel, handler: nil) alert.addAction(openSettings) diff --git a/iOS/MainTimeline/MainTimelineDataSource.swift b/iOS/MainTimeline/MainTimelineDataSource.swift index 6b6ed7692..9b3925fbe 100644 --- a/iOS/MainTimeline/MainTimelineDataSource.swift +++ b/iOS/MainTimeline/MainTimelineDataSource.swift @@ -8,11 +8,9 @@ import UIKit -final class MainTimelineDataSource: UITableViewDiffableDataSource where SectionIdentifierType : Hashable, ItemIdentifierType : Hashable { +final class MainTimelineDataSource: UITableViewDiffableDataSource where SectionIdentifierType: Hashable, ItemIdentifierType: Hashable { override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { - return true + true } - } - diff --git a/iOS/MainTimeline/MainTimelineViewController.swift b/iOS/MainTimeline/MainTimelineViewController.swift index 177e9fd9a..c24be2fa5 100644 --- a/iOS/MainTimeline/MainTimelineViewController.swift +++ b/iOS/MainTimeline/MainTimelineViewController.swift @@ -17,7 +17,7 @@ final class MainTimelineViewController: UITableViewController, UndoableCommandRu private var numberOfTextLines = 0 private var iconSize = IconSize.medium - private lazy var feedTapGestureRecognizer = UITapGestureRecognizer(target: self, action:#selector(showFeedInspector(_:))) + private lazy var feedTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(showFeedInspector(_:))) private var refreshProgressView: RefreshProgressView?