Fix various SwiftLint warnings.

This commit is contained in:
Brent Simmons committed 2026-01-02 11:42:12 -08:00
1 parent e96b92a4c3
commit fb1b901efe
20 files changed
+115 -119

No files matched your search

@@ -461,7 +461,7 @@ extension Notification.Name {
}
}
//MARK: - Node Manipulation
// MARK: - Node Manipulation
func deleteNodes(_ nodes: [Node]) {
let nodesToDelete = treeController.normalizedSelectedNodes(nodes)
@@ -537,7 +537,7 @@ extension SidebarViewController: NSUserInterfaceValidations {
}
}
//MARK: - Private
// MARK: - Private
private extension SidebarViewController {
@@ -60,7 +60,7 @@ import Articles
self.starred = article.status.starred
}
init() { //Empty
init() { // Empty
self.title = ""
self.text = ""
self.dateString = ""
@@ -996,27 +996,27 @@ extension TimelineViewController: NSTableViewDelegate {
}
switch edge {
case .leading:
let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (action, row) in
self.toggleArticleRead(article)
tableView.rowActionsVisible = false
}
action.image = article.status.read ? Assets.Images.swipeMarkUnread : Assets.Images.swipeMarkRead
return [action]
case .trailing:
let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (action, row) in
self.toggleArticleStarred(article)
tableView.rowActionsVisible = false
}
case .leading:
let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (action, row) in
self.toggleArticleRead(article)
tableView.rowActionsVisible = false
}
action.image = article.status.read ? Assets.Images.swipeMarkUnread : Assets.Images.swipeMarkRead
return [action]
case .trailing:
let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (action, row) in
self.toggleArticleStarred(article)
tableView.rowActionsVisible = false
}
action.backgroundColor = Assets.Colors.star
action.image = article.status.starred ? Assets.Images.swipeMarkUnstarred : Assets.Images.swipeMarkStarred
return [action]
@unknown default:
Self.logger.error("TimelineViewController: unknown edge \(edge.rawValue, privacy: .public)")
action.image = article.status.starred ? Assets.Images.swipeMarkUnstarred : Assets.Images.swipeMarkStarred
return [action]
@unknown default:
Self.logger.error("TimelineViewController: unknown edge \(edge.rawValue, privacy: .public)")
}
return []
}
}
@@ -175,7 +175,7 @@ private extension PreferencesWindowController {
var updatedWindowFrame = windowFrame
updatedWindowFrame.size.height = heightForWindow
updatedWindowFrame.origin.y = windowOriginY
updatedWindowFrame.size.width = windowWidth //NSWidth(viewFrame)
updatedWindowFrame.size.width = windowWidth // NSWidth(viewFrame)
var updatedViewFrame = viewFrame
updatedViewFrame.origin = NSZeroPoint
@@ -14,10 +14,9 @@ import Secrets
public extension URLRequest {
init(url: URL, credentials: Credentials?, conditionalGet: HTTPConditionalGetInfo? = nil) {
self.init(url: url)
guard let credentials = credentials else {
guard let credentials else {
return
}
@@ -33,15 +32,15 @@ public extension URLRequest {
var postData = URLComponents()
postData.queryItems = [
URLQueryItem(name: "username", value: credentials.username),
URLQueryItem(name: "password", value: credentials.secret),
URLQueryItem(name: "password", value: credentials.secret)
]
httpBody = postData.enhancedPercentEncodedQuery?.data(using: .utf8)
case .newsBlurSessionID:
setValue("\(NewsBlurAPICaller.sessionIDCookieKey)=\(credentials.secret)", forHTTPHeaderField: "Cookie")
httpShouldHandleCookies = true
case .readerBasic:
setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
httpMethod = "POST"
setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
httpMethod = "POST"
var postData = URLComponents()
postData.queryItems = [
URLQueryItem(name: "Email", value: credentials.username),
@@ -49,22 +48,22 @@ public extension URLRequest {
]
httpBody = postData.enhancedPercentEncodedQuery?.data(using: .utf8)
case .readerAPIKey:
let auth = "GoogleLogin auth=\(credentials.secret)"
setValue(auth, forHTTPHeaderField: HTTPRequestHeader.authorization)
let auth = "GoogleLogin auth=\(credentials.secret)"
setValue(auth, forHTTPHeaderField: HTTPRequestHeader.authorization)
case .oauthAccessToken:
let auth = "OAuth \(credentials.secret)"
setValue(auth, forHTTPHeaderField: "Authorization")
let auth = "OAuth \(credentials.secret)"
setValue(auth, forHTTPHeaderField: "Authorization")
case .oauthAccessTokenSecret:
assertionFailure("Token secrets are used by OAuth1. Did you mean to use `OAuthSwift` instead of a URLRequest?")
break
case .oauthRefreshToken:
// While both access and refresh tokens are credentials, it seems the `Credentials` cases
// enumerates how the identity of the user can be proved rather than
// credentials-in-general, such as in this refresh token case,
// the authority to prove an identity.
assertionFailure("Refresh tokens are used to replace expired access tokens. Did you mean to use `accessToken` instead?")
break
}
assertionFailure("Token secrets are used by OAuth1. Did you mean to use `OAuthSwift` instead of a URLRequest?")
break
case .oauthRefreshToken:
// While both access and refresh tokens are credentials, it seems the `Credentials` cases
// enumerates how the identity of the user can be proved rather than
// credentials-in-general, such as in this refresh token case,
// the authority to prove an identity.
assertionFailure("Refresh tokens are used to replace expired access tokens. Did you mean to use `accessToken` instead?")
break
}
guard let conditionalGet = conditionalGet else {
return
@@ -78,7 +77,5 @@ public extension URLRequest {
if let etag = conditionalGet.etag {
setValue(etag, forHTTPHeaderField: HTTPRequestHeader.ifNoneMatch)
}
}
}
@@ -242,7 +242,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
articlesToDelete = Set<Article>()
}
self.callUpdateArticlesCompletionBlock(newArticles, updatedArticles, articlesToDelete, completion) //7
self.callUpdateArticlesCompletionBlock(newArticles, updatedArticles, articlesToDelete, completion) // 7
self.addArticlesToCache(newArticles)
self.addArticlesToCache(updatedArticles)
@@ -298,29 +298,29 @@ final class ArticlesTable: DatabaseTable, Sendable {
articleIDs.formUnion(parsedItems.articleIDs())
}
let (statusesDictionary, _) = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, read, database) //1
let (statusesDictionary, _) = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, read, database) // 1
assert(statusesDictionary.count == articleIDs.count)
let allIncomingArticles = Article.articlesWithFeedIDsAndItems(feedIDsAndItems, self.accountID, statusesDictionary) //2
let allIncomingArticles = Article.articlesWithFeedIDsAndItems(feedIDsAndItems, self.accountID, statusesDictionary) // 2
if allIncomingArticles.isEmpty {
self.callUpdateArticlesCompletionBlock(nil, nil, nil, completion)
return
}
let incomingArticles = self.filterIncomingArticles(allIncomingArticles) //3
let incomingArticles = self.filterIncomingArticles(allIncomingArticles) // 3
if incomingArticles.isEmpty {
self.callUpdateArticlesCompletionBlock(nil, nil, nil, completion)
return
}
let incomingArticleIDs = incomingArticles.articleIDs()
let fetchedArticles = self.fetchArticles(articleIDs: incomingArticleIDs, database) //4
let fetchedArticles = self.fetchArticles(articleIDs: incomingArticleIDs, database) // 4
let fetchedArticlesDictionary = fetchedArticles.dictionary()
let newArticles = self.findAndSaveNewArticles(incomingArticles, fetchedArticlesDictionary, database) //5
let updatedArticles = self.findAndSaveUpdatedArticles(incomingArticles, fetchedArticlesDictionary, database) //6
let newArticles = self.findAndSaveNewArticles(incomingArticles, fetchedArticlesDictionary, database) //
let updatedArticles = self.findAndSaveUpdatedArticles(incomingArticles, fetchedArticlesDictionary, database) // 6
self.callUpdateArticlesCompletionBlock(newArticles, updatedArticles, nil, completion) //7
self.callUpdateArticlesCompletionBlock(newArticles, updatedArticles, nil, completion) // 7
self.addArticlesToCache(newArticles)
self.addArticlesToCache(updatedArticles)
@@ -987,7 +987,7 @@ nonisolated private extension ArticlesTable {
return newArticles.isEmpty ? nil : newArticles
}
func findAndSaveNewArticles(_ incomingArticles: Set<Article>, _ fetchedArticlesDictionary: [String: Article], _ database: FMDatabase) -> Set<Article>? { //5
func findAndSaveNewArticles(_ incomingArticles: Set<Article>, _ fetchedArticlesDictionary: [String: Article], _ database: FMDatabase) -> Set<Article>? { // 5
guard let newArticles = findNewArticles(incomingArticles, fetchedArticlesDictionary) else {
return nil
}
@@ -1032,7 +1032,7 @@ nonisolated private extension ArticlesTable {
}
func findUpdatedArticles(_ incomingArticles: Set<Article>, _ fetchedArticlesDictionary: [String: Article]) -> Set<Article>? {
let updatedArticles = incomingArticles.filter{ (incomingArticle) -> Bool in //6
let updatedArticles = incomingArticles.filter{ (incomingArticle) -> Bool in // 6
if let existingArticle = fetchedArticlesDictionary[incomingArticle.articleID] {
if existingArticle != incomingArticle {
return true
@@ -1044,7 +1044,7 @@ nonisolated private extension ArticlesTable {
return updatedArticles.isEmpty ? nil : updatedArticles
}
func findAndSaveUpdatedArticles(_ incomingArticles: Set<Article>, _ fetchedArticlesDictionary: [String: Article], _ database: FMDatabase) -> Set<Article>? { //6
func findAndSaveUpdatedArticles(_ incomingArticles: Set<Article>, _ fetchedArticlesDictionary: [String: Article], _ database: FMDatabase) -> Set<Article>? { // 6
guard let updatedArticles = findUpdatedArticles(incomingArticles, fetchedArticlesDictionary) else {
return nil
}
@@ -121,8 +121,8 @@ public struct KeyboardKey: Hashable, Sendable {
integerValue = KeyboardKey.deleteKeyCode
case "[deletefunction]":
integerValue = NSDeleteFunctionKey
case "[tab]":
integerValue = NSTabCharacter
case "[tab]":
integerValue = NSTabCharacter
default:
guard let unwrappedIntegerValue = s.keyboardIntegerValue else {
return nil
@@ -12,7 +12,7 @@ import Foundation
/// [send-to-blog-editor Apple Events API](http://ranchero.com/netnewswire/developers/externalinterface)\.
@MainActor public struct SendToBlogEditorApp {
///The target descriptor of the application.
/// The target descriptor of the application.
///
/// The easiest way to get this is probably `UserApp.targetDescriptor` or `NSAppleEventDescriptor(runningApplication:)`.
///
@@ -262,19 +262,19 @@ public extension String {
for char in self {
switch char {
case "&":
escaped.append("&amp;")
case "<":
escaped.append("&lt;")
case ">":
escaped.append("&gt;")
case "\"":
escaped.append("&quot;")
default:
escaped.append(char)
case "&":
escaped.append("&amp;")
case "<":
escaped.append("&lt;")
case ">":
escaped.append("&gt;")
case "\"":
escaped.append("&quot;")
default:
escaped.append(char)
}
}
return escaped
}
@@ -14,7 +14,7 @@ extension UIFont {
func withTraits(traits: UIFontDescriptor.SymbolicTraits) -> UIFont {
if let descriptor = fontDescriptor.withSymbolicTraits(traits) {
return UIFont(descriptor: descriptor, size: 0) //size 0 means keep the size as it is
return UIFont(descriptor: descriptor, size: 0) // size 0 means keep the size as it is
} else {
return self
}
@@ -10,7 +10,7 @@ import XCTest
import Foundation
@testable import RSCore
//final class Data_RSCoreTests: XCTestCase {
// final class Data_RSCoreTests: XCTestCase {
// var bigHTML: String!
//
// var pngData: Data!
@@ -125,10 +125,10 @@ import Foundation
//
// }
//
//}
// }
// Tests to compare the result of Data+RSCore with the old Objective-C versions.
//extension Data_RSCoreTests {
// extension Data_RSCoreTests {
//
// func testCompare_isProbablyHTML() {
// let noLT = "html body".data(using: .utf8)!
@@ -186,4 +186,4 @@ import Foundation
//
// }
//
//}
// }
@@ -3,7 +3,7 @@ import XCTest
#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(RSCoreTests.allTests),
testCase(RSCoreTests.allTests)
]
}
#endif
@@ -10,8 +10,8 @@ import Foundation
import RSMarkdown
public struct ParsedItem: Hashable, Sendable {
public let syncServiceID: String? //Nil when not syncing
public let uniqueID: String //RSS guid, for instance; may be calculated
public let syncServiceID: String? // Nil when not syncing
public let uniqueID: String // RSS guid, for instance; may be calculated
public let feedURL: String
public let url: String?
public let externalURL: String?
@@ -17,5 +17,5 @@ nonisolated public struct HTTPRequestHeader {
// Conditional GET
public static let ifModifiedSince = "If-Modified-Since"
public static let ifNoneMatch = "If-None-Match" //Etag
public static let ifNoneMatch = "If-None-Match" // Etag
}
@@ -13,7 +13,7 @@ public struct HTTPResponseCode {
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
// Not an enum because the main interest is the actual values.
public static let responseContinue = 100 //"continue" is a language keyword, hence the weird name
public static let responseContinue = 100 // "continue" is a language keyword, hence the weird name
public static let switchingProtocols = 101
public static let OK = 200
+12 -13
View File
@@ -18,22 +18,21 @@ nonisolated public extension String {
for char in self {
switch char {
case "&":
escaped.append("&amp;")
case "<":
escaped.append("&lt;")
case ">":
escaped.append("&gt;")
case "\"":
escaped.append("&quot;")
case "'":
escaped.append("&apos;")
default:
escaped.append(char)
case "&":
escaped.append("&amp;")
case "<":
escaped.append("&lt;")
case ">":
escaped.append("&gt;")
case "\"":
escaped.append("&quot;")
case "'":
escaped.append("&apos;")
default:
escaped.append(char)
}
}
return escaped
}
}
@@ -71,20 +71,20 @@ final 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
}
}
@@ -246,16 +246,16 @@ final 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
@@ -516,7 +516,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
}
func configureCellsForRepresentedObject(_ representedObject: AnyObject) {
//applyToCellsForRepresentedObject(representedObject, configure)
// applyToCellsForRepresentedObject(representedObject, configure)
}
func applyToCellsForRepresentedObject(_ representedObject: AnyObject, _ completion: (MainFeedCollectionViewCell, IndexPath) -> Void) {
@@ -66,7 +66,7 @@ import Articles
}
init() { //Empty
init() { // Empty
self.title = ""
self.attributedTitle = NSAttributedString()
self.summary = ""
@@ -217,7 +217,7 @@ final class MainTimelineViewController: UITableViewController, UndoableCommandRu
if navigationController?.navigationBar.isHidden ?? false {
navigationController?.navigationBar.alpha = 0
}
//navigationItem.subtitle = "" // don't inherit feeds subtitle on push
// navigationItem.subtitle = "" // don't inherit feeds subtitle on push
updateNavigationBarTitle(coordinator?.timelineFeed?.nameForDisplay ?? "")
coordinator?.updateNavigationBarSubtitles(nil)
}