From d60c2f6b60cc3ff3c31f1ebf8d0b2ce200057a87 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 9 Jul 2023 22:20:58 -0700 Subject: [PATCH] Replace uses of forEach with for-in loops. --- .../Sources/Account/Feedbin/FeedbinAccountDelegate.swift | 2 +- .../Internals/NewsBlurAccountDelegate+Internal.swift | 8 ++++---- .../Timeline/TimelineViewController+ContextualMenus.swift | 2 +- Shared/Commands/DeleteCommand.swift | 8 +++++--- Shared/ExtensionPoints/SendToMarsEditCommand.swift | 4 +++- Shared/SmartFeeds/SmartFeed.swift | 4 +++- .../NewArticleNotificationsView.swift | 2 +- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift b/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift index 025382447..6724a7f1d 100644 --- a/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift @@ -759,7 +759,7 @@ private extension FeedbinAccountDelegate { // Feedbin has a tag that we don't have a folder for. We might not get a new // taggings response for it if it is a folder rename. Force expire the tagging // so that we will for sure get the new tagging information. - tags.forEach { tag in + for tag in tags { if !folderNames.contains(tag.name) { accountMetadata?.conditionalGetInfo[FeedbinAPICaller.ConditionalGetKeys.taggings] = nil } diff --git a/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift b/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift index 4377f4b74..ef35dffb3 100644 --- a/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift +++ b/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift @@ -45,7 +45,7 @@ extension NewsBlurAccountDelegate { // Delete any folders not at NewsBlur if let folders = account.folders { - folders.forEach { folder in + for folder in folders { if !folderNames.contains(folder.name ?? "") { for feed in folder.topLevelFeeds { account.addFeed(feed) @@ -66,7 +66,7 @@ extension NewsBlurAccountDelegate { // Make any folders NewsBlur has, but we don't // Ignore account-level folder - folderNames.forEach { folderName in + for folderName in folderNames { if !accountFolderNames.contains(folderName) && folderName != " " { _ = account.ensureFolder(with: folderName) } @@ -100,7 +100,7 @@ extension NewsBlurAccountDelegate { // Add any feeds we don't have and update any we do var feedsToAdd = Set() - feeds.forEach { newsBlurFeed in + for newsBlurFeed in feeds { let subFeedID = String(newsBlurFeed.feedID) if let feed = account.existingFeed(withFeedID: subFeedID) { @@ -117,7 +117,7 @@ extension NewsBlurAccountDelegate { } // Actually add feeds all in one go, so we don’t trigger various rebuilding things that Account does. - feedsToAdd.forEach { newsBlurFeed in + for newsBlurFeed in feedsToAdd { let feed = account.createFeed(with: newsBlurFeed.name, url: newsBlurFeed.feedURL, feedID: String(newsBlurFeed.feedID), homePageURL: newsBlurFeed.homePageURL) feed.externalID = String(newsBlurFeed.feedID) account.addFeed(feed) diff --git a/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift b/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift index 9717d056a..ba7904a6f 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift @@ -228,7 +228,7 @@ private extension TimelineViewController { } let menu = NSMenu(title: NSLocalizedString("button.title.share", comment: "Share menu name")) - services.forEach { (service) in + for service in services { service.delegate = sharingServiceDelegate let menuItem = NSMenuItem(title: service.menuItemTitle, action: #selector(performShareServiceFromContextualMenu(_:)), keyEquivalent: "") menuItem.image = service.image diff --git a/Shared/Commands/DeleteCommand.swift b/Shared/Commands/DeleteCommand.swift index 9aaf24386..d952c9e0f 100644 --- a/Shared/Commands/DeleteCommand.swift +++ b/Shared/Commands/DeleteCommand.swift @@ -48,9 +48,9 @@ import Articles func perform() { let group = DispatchGroup() - itemSpecifiers.forEach { + for itemSpecifier in itemSpecifiers { group.enter() - $0.delete() { + itemSpecifier.delete() { group.leave() } } @@ -63,7 +63,9 @@ import Articles } func undo() { - itemSpecifiers.forEach { $0.restore() } + for itemSpecifier in itemSpecifiers { + itemSpecifier.restore() + } registerRedo() } diff --git a/Shared/ExtensionPoints/SendToMarsEditCommand.swift b/Shared/ExtensionPoints/SendToMarsEditCommand.swift index 71b778a89..03f535c80 100644 --- a/Shared/ExtensionPoints/SendToMarsEditCommand.swift +++ b/Shared/ExtensionPoints/SendToMarsEditCommand.swift @@ -58,7 +58,9 @@ private extension SendToMarsEditCommand { func appToUse() -> UserApp? { - marsEditApps.forEach{ $0.updateStatus() } + for app in marsEditApps { + app.updateStatus() + } for app in marsEditApps { if app.isRunning { diff --git a/Shared/SmartFeeds/SmartFeed.swift b/Shared/SmartFeeds/SmartFeed.swift index d72f9a375..8a1ddd59f 100644 --- a/Shared/SmartFeeds/SmartFeed.swift +++ b/Shared/SmartFeeds/SmartFeed.swift @@ -75,7 +75,9 @@ final class SmartFeed: PseudoFeed { if activeAccounts.isEmpty { updateUnreadCount() } else { - activeAccounts.forEach { self.fetchUnreadCount(for: $0) } + for account in activeAccounts { + fetchUnreadCount(for: account) + } } } diff --git a/iOS/Settings/New Article Notifications/NewArticleNotificationsView.swift b/iOS/Settings/New Article Notifications/NewArticleNotificationsView.swift index eafa217d9..ccbf09ad3 100644 --- a/iOS/Settings/New Article Notifications/NewArticleNotificationsView.swift +++ b/iOS/Settings/New Article Notifications/NewArticleNotificationsView.swift @@ -33,7 +33,7 @@ import RSCore let faviconHost = URL(string: faviconURLString)?.host else { return } - activeAccounts.forEach { account in + for account in activeAccounts { for feed in Array(account.flattenedFeeds()) { if let feedURLHost = URL(string: feed.url)?.host { if faviconHost == feedURLHost {