diff --git a/.swiftlint.yml b/.swiftlint.yml index 6b3c7db59..87b7f273d 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -3,11 +3,11 @@ identifier_name: max_length: 50 allowed_symbols: "_" -line_length: - warning: 200 - error: 300 - ignores_comments: true - ignores_urls: true +# line_length: +# warning: 200 +# error: 300 +# ignores_comments: true +# ignores_urls: true large_tuple: warning: 3 diff --git a/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift b/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift index 309fc646b..457234b5e 100644 --- a/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift +++ b/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift @@ -30,17 +30,12 @@ final class BuiltinSmartFeedInspectorViewController: NSViewController, Inspector var windowTitle: String = NSLocalizedString("Smart Feed Inspector", comment: "Smart Feed Inspector window title") func canInspect(_ objects: [Any]) -> Bool { - - guard let _ = singleSmartFeed(from: objects) else { - return false - } - return true + singleSmartFeed(from: objects) != nil } // MARK: NSViewController override func viewDidLoad() { - updateUI() } } @@ -57,7 +52,6 @@ private extension BuiltinSmartFeedInspectorViewController { } func updateSmartFeed() { - smartFeed = singleSmartFeed(from: objects) } diff --git a/Mac/Inspector/InspectorWindowController.swift b/Mac/Inspector/InspectorWindowController.swift index 8349f3eae..792726ca0 100644 --- a/Mac/Inspector/InspectorWindowController.swift +++ b/Mac/Inspector/InspectorWindowController.swift @@ -21,7 +21,7 @@ typealias InspectorViewController = Inspector & NSViewController final class InspectorWindowController: NSWindowController { - class var shouldOpenAtStartup: Bool { + static var shouldOpenAtStartup: Bool { return UserDefaults.standard.bool(forKey: DefaultsKey.windowIsOpen) } diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index 75be07446..ceb4824d8 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -272,9 +272,13 @@ class MainWindowController: NSWindowController, NSUserInterfaceValidations { guard let detailViewController = detailViewController else { return } - detailViewController.canScrollDown { (canScroll) in + detailViewController.canScrollDown { canScroll in NSCursor.setHiddenUntilMouseMoves(true) - canScroll ? detailViewController.scrollPageDown(sender) : self.nextUnread(sender) + if canScroll { + detailViewController.scrollPageDown(sender) + } else { + self.nextUnread(sender) + } } } diff --git a/Mac/MainWindow/Sidebar/SidebarViewController.swift b/Mac/MainWindow/Sidebar/SidebarViewController.swift index f1541bd8a..5a4c69e1d 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController.swift @@ -302,10 +302,7 @@ protocol SidebarDelegate: AnyObject { // MARK: - Navigation func canGoToNextUnread(wrappingToTop wrapping: Bool = false) -> Bool { - if let _ = nextSelectableRowWithUnreadArticle(wrappingToTop: wrapping) { - return true - } - return false + nextSelectableRowWithUnreadArticle(wrappingToTop: wrapping) != nil } func goToNextUnread(wrappingToTop wrapping: Bool = false) { diff --git a/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift b/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift index 28ffb6eaa..0c97a59eb 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 let _ = article.preferredURL { + if article.preferredURL != nil { types += [.URL] } types += [.string, .html, ArticlePasteboardWriter.articleUTIInternalType] diff --git a/Mac/MainWindow/Timeline/Cell/TimelineCellAppearance.swift b/Mac/MainWindow/Timeline/Cell/TimelineCellAppearance.swift index 457919e6c..dce4e3eea 100644 --- a/Mac/MainWindow/Timeline/Cell/TimelineCellAppearance.swift +++ b/Mac/MainWindow/Timeline/Cell/TimelineCellAppearance.swift @@ -65,7 +65,7 @@ struct TimelineCellAppearance: Equatable { extension NSEdgeInsets: @retroactive Equatable { - public static func ==(lhs: NSEdgeInsets, rhs: NSEdgeInsets) -> Bool { + public static func == (lhs: NSEdgeInsets, rhs: NSEdgeInsets) -> Bool { return lhs.left == rhs.left && lhs.top == rhs.top && lhs.right == rhs.right && lhs.bottom == rhs.bottom } } diff --git a/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift b/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift index 8c46687b8..8ded0f5a7 100644 --- a/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift +++ b/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift @@ -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 6e5021114..ff489a347 100644 --- a/Mac/MainWindow/Timeline/TimelineContainerViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineContainerViewController.swift @@ -107,7 +107,7 @@ final class TimelineContainerViewController: NSViewController { return false } for object in representedObjects { - guard let _ = currentObjects.firstIndex(where: { $0 === object }) else { + guard currentObjects.firstIndex(where: { $0 === object }) != nil else { return false } } diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index 6a20ed797..1241f2d40 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -557,10 +557,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr } func canGoToNextUnread(wrappingToTop wrapping: Bool = false) -> Bool { - guard let _ = indexOfNextUnreadArticle(wrappingToTop: wrapping) else { - return false - } - return true + indexOfNextUnreadArticle(wrappingToTop: wrapping) != nil } func indexOfNextUnreadArticle(wrappingToTop wrapping: Bool = false) -> Int? { @@ -913,25 +910,25 @@ extension TimelineViewController: NSTableViewDelegate { } switch edge { - case .leading: - let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (_, _) in - self.toggleArticleRead(article) - tableView.rowActionsVisible = false - } - action.image = article.status.read ? AppAssets.swipeMarkUnreadImage : AppAssets.swipeMarkReadImage - return [action] + case .leading: + let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (_, _) in + self.toggleArticleRead(article) + tableView.rowActionsVisible = false + } + action.image = article.status.read ? AppAssets.swipeMarkUnreadImage : AppAssets.swipeMarkReadImage + return [action] - case .trailing: - let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (_, _) in - self.toggleArticleStarred(article) - tableView.rowActionsVisible = false - } - action.backgroundColor = AppAssets.starColor - action.image = article.status.starred ? AppAssets.swipeMarkUnstarredImage : AppAssets.swipeMarkStarredImage - return [action] + case .trailing: + let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (_, _) in + self.toggleArticleStarred(article) + tableView.rowActionsVisible = false + } + action.backgroundColor = AppAssets.starColor + action.image = article.status.starred ? AppAssets.swipeMarkUnstarredImage : AppAssets.swipeMarkStarredImage + return [action] - @unknown default: - os_log(.error, "Unknown table row edge: %ld", edge.rawValue) + @unknown default: + os_log(.error, "Unknown table row edge: %ld", edge.rawValue) } return [] diff --git a/Mac/Preferences/Accounts/AccountsDetailViewController.swift b/Mac/Preferences/Accounts/AccountsDetailViewController.swift index 5ad088041..12dc5e1b0 100644 --- a/Mac/Preferences/Accounts/AccountsDetailViewController.swift +++ b/Mac/Preferences/Accounts/AccountsDetailViewController.swift @@ -82,7 +82,7 @@ final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate accountsFeedbinWindowController.account = account accountsFeedbinWindowController.runSheetOnWindow(self.view.window!) accountsWindowController = accountsFeedbinWindowController - case .inoreader, .bazQux, .theOldReader, .freshRSS: + case .inoreader, .bazQux, .theOldReader, .freshRSS: let accountsReaderAPIWindowController = AccountsReaderAPIWindowController() accountsReaderAPIWindowController.accountType = account.type accountsReaderAPIWindowController.account = account @@ -96,7 +96,5 @@ final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate default: break } - } - } diff --git a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift index 7c19e551e..377178a84 100644 --- a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift +++ b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift @@ -12,7 +12,7 @@ import SwiftUI import RSCore // MARK: - AccountsPreferencesAddAccountDelegate -protocol AccountsPreferencesAddAccountDelegate { +protocol AccountsPreferencesAddAccountDelegate: AnyObject { func presentSheetForAccount(_ accountType: AccountType) } @@ -22,7 +22,7 @@ final class AccountsPreferencesViewController: NSViewController { @IBOutlet weak var tableView: NSTableView! @IBOutlet weak var detailView: NSView! @IBOutlet weak var deleteButton: NSButton! - var addAccountDelegate: AccountsPreferencesAddAccountDelegate? + weak var addAccountDelegate: AccountsPreferencesAddAccountDelegate? var addAccountWindowController: NSWindowController? var addAccountsViewController: NSHostingController? diff --git a/Mac/Preferences/Accounts/AddAccountHelpView.swift b/Mac/Preferences/Accounts/AddAccountHelpView.swift index 3f520fd1f..138652a4d 100644 --- a/Mac/Preferences/Accounts/AddAccountHelpView.swift +++ b/Mac/Preferences/Accounts/AddAccountHelpView.swift @@ -12,7 +12,7 @@ import Account struct AddAccountHelpView: View { let accountTypes: [AccountType] = AddAccountSections.allOrdered.sectionContent - var delegate: AccountsPreferencesAddAccountDelegate? + weak var delegate: AccountsPreferencesAddAccountDelegate? var helpText: String @State private var iCloudUnavailableError: Bool = false diff --git a/Mac/Preferences/Accounts/AddAccountsView.swift b/Mac/Preferences/Accounts/AddAccountsView.swift index 33365bd7b..83da09de9 100644 --- a/Mac/Preferences/Accounts/AddAccountsView.swift +++ b/Mac/Preferences/Accounts/AddAccountsView.swift @@ -74,7 +74,7 @@ enum AddAccountSections: Int, CaseIterable { struct AddAccountsView: View { weak var parent: NSHostingController? // required because presentationMode.dismiss() doesn't work - var addAccountDelegate: AccountsPreferencesAddAccountDelegate? + weak var addAccountDelegate: AccountsPreferencesAddAccountDelegate? private let chunkLimit = 4 // use this to control number of accounts in each web account column @State private var selectedAccount: AccountType = .onMyMac diff --git a/Shared/Constants.swift b/Shared/Constants.swift index ea17e5d16..392e40b7a 100644 --- a/Shared/Constants.swift +++ b/Shared/Constants.swift @@ -10,6 +10,5 @@ import Foundation struct Constants { - // swiftlint:disable:next line_length static let prototypeText = "You are about to being reading Italo Calvino’s new novel, *If on a winter’s night a traveler*. Relax. Concentrate. Dispel every other thought. Let the world around you fade. Best to close the door; the TV is always on in the next room. Tell the others right away, “No, I don’t want to watch TV!” Raise your voice—they won’t hear you otherwise—“I’m reading! I don’t want to be disturbed!” Maybe they haven’t heard you, with all that racket; speak louder, yell: “I’m beginning to read Italo Calvino’s new novel!” Or if you prefer, don’t say anything; just hope they’ll leave you alone. Find the most comfortable position: seated, stretched out, curled up, or lying flat. Flat on your back, on your side, on your stomach. In an easy chair, on the sofa, in the rocker, the deck chair, on the hassock. In the hammock, if you have a hammock. On top of your bed, of course, or in the bed. You can even stand on your hands, head down, in the yoga position. With the book upside down, naturally." } diff --git a/Widget/Resources/Localized.swift b/Widget/Resources/Localized.swift index f8a05b221..6ea33ef0b 100644 --- a/Widget/Resources/Localized.swift +++ b/Widget/Resources/Localized.swift @@ -7,7 +7,7 @@ import Foundation // MARK: - Strings -// swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length +// swiftlint:disable explicit_type_interface function_parameter_count identifier_name // swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces internal enum L10n { /// Plural format key: "%#@localized_count@" @@ -61,7 +61,7 @@ internal enum L10n { return L10n.tr("Localizable", "UnreadCount", p1) } } -// swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length +// swiftlint:enable explicit_type_interface function_parameter_count identifier_name // swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces // MARK: - Implementation Details diff --git a/iOS/MainTimeline/MainTimelineDataSource.swift b/iOS/MainTimeline/MainTimelineDataSource.swift index f0822ee82..0c622842e 100644 --- a/iOS/MainTimeline/MainTimelineDataSource.swift +++ b/iOS/MainTimeline/MainTimelineDataSource.swift @@ -8,7 +8,6 @@ import UIKit -// swiftlint:disable:next line_length class MainTimelineDataSource: UITableViewDiffableDataSource where SectionIdentifierType: Hashable, ItemIdentifierType: Hashable { override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {