diff --git a/.swiftlint.yml b/.swiftlint.yml index 2603ac3f1..6b3c7db59 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -23,6 +23,8 @@ disabled_rules: - generic_type_name - function_body_length - type_body_length + - function_parameter_count + - line_length excluded: - Modules/Secrets/Sources/Secrets/SecretKey.swift diff --git a/Mac/MainWindow/Sidebar/Renaming/RenameWindowController.swift b/Mac/MainWindow/Sidebar/Renaming/RenameWindowController.swift index 229a791ad..113154024 100644 --- a/Mac/MainWindow/Sidebar/Renaming/RenameWindowController.swift +++ b/Mac/MainWindow/Sidebar/Renaming/RenameWindowController.swift @@ -8,7 +8,7 @@ import AppKit -protocol RenameWindowControllerDelegate { +protocol RenameWindowControllerDelegate: AnyObject { func renameWindowController(_ windowController: RenameWindowController, didRenameObject: Any, withNewName: String) } @@ -21,7 +21,7 @@ final class RenameWindowController: NSWindowController { private var originalTitle: String? private var representedObject: Any? - private var delegate: RenameWindowControllerDelegate? + private weak var delegate: RenameWindowControllerDelegate? convenience init(originalTitle: String, representedObject: Any, delegate: RenameWindowControllerDelegate) { diff --git a/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift b/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift index 435577c0e..2d7a13e35 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift @@ -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) menu.addItem(item) menu.addItem(NSMenuItem.separator()) diff --git a/iOS/Account/ReaderAPIAccountViewController.swift b/iOS/Account/ReaderAPIAccountViewController.swift index ce16b6607..2bc9ab7b9 100644 --- a/iOS/Account/ReaderAPIAccountViewController.swift +++ b/iOS/Account/ReaderAPIAccountViewController.swift @@ -71,20 +71,20 @@ class ReaderAPIAccountViewController: UITableViewController { private func setupFooter() { switch accountType { - case .bazQux: - footerLabel.text = NSLocalizedString("Sign in to your BazQux account and sync your feeds across your devices. Your username and password will be encrypted and stored in Keychain.\n\nDon’t have a BazQux account?", comment: "BazQux") - signUpButton.setTitle(NSLocalizedString("Sign Up Here", comment: "BazQux SignUp"), for: .normal) - case .inoreader: - footerLabel.text = NSLocalizedString("Sign in to your InoReader account and sync your feeds across your devices. Your username and password will be encrypted and stored in Keychain.\n\nDon’t have an InoReader account?", comment: "InoReader") - signUpButton.setTitle(NSLocalizedString("Sign Up Here", comment: "InoReader SignUp"), for: .normal) - case .theOldReader: - footerLabel.text = NSLocalizedString("Sign in to your The Old Reader account and sync your feeds across your devices. Your username and password will be encrypted and stored in Keychain.\n\nDon’t have a The Old Reader account?", comment: "TOR") - signUpButton.setTitle(NSLocalizedString("Sign Up Here", comment: "TOR SignUp"), for: .normal) - case .freshRSS: - footerLabel.text = NSLocalizedString("Sign in to your FreshRSS instance and sync your feeds across your devices. Your username and password will be encrypted and stored in Keychain.\n\nDon’t have an FreshRSS instance?", comment: "FreshRSS") - signUpButton.setTitle(NSLocalizedString("Find Out More", comment: "FreshRSS SignUp"), for: .normal) - default: - return + case .bazQux: + footerLabel.text = NSLocalizedString("Sign in to your BazQux account and sync your feeds across your devices. Your username and password will be encrypted and stored in Keychain.\n\nDon’t have a BazQux account?", comment: "BazQux") + signUpButton.setTitle(NSLocalizedString("Sign Up Here", comment: "BazQux SignUp"), for: .normal) + case .inoreader: + footerLabel.text = NSLocalizedString("Sign in to your InoReader account and sync your feeds across your devices. Your username and password will be encrypted and stored in Keychain.\n\nDon’t have an InoReader account?", comment: "InoReader") + signUpButton.setTitle(NSLocalizedString("Sign Up Here", comment: "InoReader SignUp"), for: .normal) + case .theOldReader: + footerLabel.text = NSLocalizedString("Sign in to your The Old Reader account and sync your feeds across your devices. Your username and password will be encrypted and stored in Keychain.\n\nDon’t have a The Old Reader account?", comment: "TOR") + signUpButton.setTitle(NSLocalizedString("Sign Up Here", comment: "TOR SignUp"), for: .normal) + case .freshRSS: + footerLabel.text = NSLocalizedString("Sign in to your FreshRSS instance and sync your feeds across your devices. Your username and password will be encrypted and stored in Keychain.\n\nDon’t have an FreshRSS instance?", comment: "FreshRSS") + signUpButton.setTitle(NSLocalizedString("Find Out More", comment: "FreshRSS SignUp"), for: .normal) + default: + return } } @@ -209,16 +209,16 @@ class ReaderAPIAccountViewController: UITableViewController { private func headerViewImage() -> UIImage? { if let accountType = accountType { switch accountType { - case .bazQux: - return AppAssets.accountBazQuxImage - case .inoreader: - return AppAssets.accountInoreaderImage - case .theOldReader: - return AppAssets.accountTheOldReaderImage - case .freshRSS: - return AppAssets.accountFreshRSSImage - default: - return nil + case .bazQux: + return AppAssets.accountBazQuxImage + case .inoreader: + return AppAssets.accountInoreaderImage + case .theOldReader: + return AppAssets.accountTheOldReaderImage + case .freshRSS: + return AppAssets.accountFreshRSSImage + default: + return nil } } return nil @@ -231,7 +231,7 @@ 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 } @@ -247,16 +247,16 @@ class ReaderAPIAccountViewController: UITableViewController { @IBAction func signUpWithProvider(_ sender: Any) { var url: URL! switch accountType { - case .bazQux: - url = URL(string: "https://bazqux.com")! - case .inoreader: - url = URL(string: "https://www.inoreader.com")! - case .theOldReader: - url = URL(string: "https://theoldreader.com")! - case .freshRSS: - url = URL(string: "https://freshrss.org")! - default: - return + case .bazQux: + url = URL(string: "https://bazqux.com")! + case .inoreader: + url = URL(string: "https://www.inoreader.com")! + case .theOldReader: + url = URL(string: "https://theoldreader.com")! + case .freshRSS: + url = URL(string: "https://freshrss.org")! + default: + return } let safari = SFSafariViewController(url: url) safari.modalPresentationStyle = .currentContext diff --git a/iOS/Article/ArticleViewController.swift b/iOS/Article/ArticleViewController.swift index a07da9d21..7bb1730b0 100644 --- a/iOS/Article/ArticleViewController.swift +++ b/iOS/Article/ArticleViewController.swift @@ -14,10 +14,12 @@ import SafariServices class ArticleViewController: UIViewController { - typealias State = (extractedArticle: ExtractedArticle?, - isShowingExtractedArticle: Bool, - articleExtractorButtonState: ArticleExtractorButtonState, - windowScrollY: Int) + struct State { + let extractedArticle: ExtractedArticle? + let isShowingExtractedArticle: Bool + let articleExtractorButtonState: ArticleExtractorButtonState + let windowScrollY: Int + } @IBOutlet private weak var nextUnreadBarButtonItem: UIBarButtonItem! @IBOutlet private weak var prevArticleBarButtonItem: UIBarButtonItem! @@ -360,8 +362,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/WebViewController.swift b/iOS/Article/WebViewController.swift index d2f0e5f09..4fc481288 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -835,8 +835,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/SceneDelegate.swift b/iOS/SceneDelegate.swift index b5db0d04d..decfffd1b 100644 --- a/iOS/SceneDelegate.swift +++ b/iOS/SceneDelegate.swift @@ -43,7 +43,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange), name: UserDefaults.didChangeNotification, object: nil) - if let _ = connectionOptions.urlContexts.first?.url { + if connectionOptions.urlContexts.first?.url != nil { self.scene(scene, openURLContexts: connectionOptions.urlContexts) return }