Fix lint issues.

This commit is contained in:
Brent Simmons 2025-01-24 22:55:39 -08:00
parent cc4914a7ef
commit cc34209738
17 changed files with 88 additions and 81 deletions

View File

@ -25,11 +25,14 @@ disabled_rules:
- type_body_length - type_body_length
- function_parameter_count - function_parameter_count
- line_length - line_length
- operator_whitespace
excluded: excluded:
- Modules/Secrets/Sources/Secrets/SecretKey.swift - Modules/Secrets/Sources/Secrets/SecretKey.swift
- Modules/Account/Tests/AccountTests/Feedly/ - Modules/Account/Tests/AccountTests/Feedly/
- Modules/Account/Sources/Account/Feedly/
- Widget/Resources/Localized.swift - Widget/Resources/Localized.swift
- Shared/Extensions/NSAttributedString+NetNewsWire.swift - Shared/Extensions/NSAttributedString+NetNewsWire.swift
- buildscripts/

View File

@ -35,11 +35,7 @@ final class FolderInspectorViewController: NSViewController, Inspector {
var windowTitle: String = NSLocalizedString("Folder Inspector", comment: "Folder Inspector window title") var windowTitle: String = NSLocalizedString("Folder Inspector", comment: "Folder Inspector window title")
func canInspect(_ objects: [Any]) -> Bool { func canInspect(_ objects: [Any]) -> Bool {
singleFolder(from: objects) != nil
guard let _ = singleFolder(from: objects) else {
return false
}
return true
} }
// MARK: NSViewController // MARK: NSViewController

View File

@ -65,7 +65,7 @@ struct TimelineCellAppearance: Equatable {
extension NSEdgeInsets: @retroactive 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 return lhs.left == rhs.left && lhs.top == rhs.top && lhs.right == rhs.right && lhs.bottom == rhs.bottom
} }
} }

View File

@ -153,28 +153,28 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
} }
@objc(accountType) @objc(accountType)
var accountType: OSType { var accountType: OSType {
var osType: String = "" var osType: String = ""
switch self.account.type { switch self.account.type {
case .onMyMac: case .onMyMac:
osType = "Locl" osType = "Locl"
case .cloudKit: case .cloudKit:
osType = "Clkt" osType = "Clkt"
case .feedly: case .feedly:
osType = "Fdly" osType = "Fdly"
case .feedbin: case .feedbin:
osType = "Fdbn" osType = "Fdbn"
case .newsBlur: case .newsBlur:
osType = "NBlr" osType = "NBlr"
case .freshRSS: case .freshRSS:
osType = "Frsh" osType = "Frsh"
case .inoreader: case .inoreader:
osType = "Inrd" osType = "Inrd"
case .bazQux: case .bazQux:
osType = "Bzqx" osType = "Bzqx"
case .theOldReader: case .theOldReader:
osType = "Tord" osType = "Tord"
} }
return osType.fourCharCode return osType.fourCharCode
} }
} }

View File

@ -24,7 +24,7 @@ protocol AppDelegateAppleEvents {
func getURL(_ event: NSAppleEventDescriptor, _ withReplyEvent: NSAppleEventDescriptor) func getURL(_ event: NSAppleEventDescriptor, _ withReplyEvent: NSAppleEventDescriptor)
} }
protocol ScriptingAppDelegate { protocol ScriptingAppDelegate: AnyObject {
var scriptingCurrentArticle: Article? {get} var scriptingCurrentArticle: Article? {get}
var scriptingSelectedArticles: [Article] {get} var scriptingSelectedArticles: [Article] {get}
var scriptingMainWindowController: ScriptingMainWindowController? {get} var scriptingMainWindowController: ScriptingMainWindowController? {get}
@ -171,14 +171,14 @@ class NetNewsWireExistsCommand: NSExistsCommand {
// to be another object type. e.g., 'permalink of the current article' parses as // to be another object type. e.g., 'permalink of the current article' parses as
// <property> of <property> of <top level object> // <property> of <property> of <top level object>
// cocoa would send the top level object (the app) a doesExist message for a nested property, and // cocoa would send the top level object (the app) a doesExist message for a nested property, and
// it errors out because it doesn't know how to handle that // it errors out because it doesn't know how to handle that`
// What we do instead is simply see if the defaultImplementation errors, and if it does, the object // What we do instead is simply see if the defaultImplementation errors, and if it does, the object
// must not exist. Otherwise, we return the result of the defaultImplementation // must not exist. Otherwise, we return the result of the defaultImplementation
// The wrinkle is that it is possible that the direct object is a list, so we need to // The wrinkle is that it is possible that the direct object is a list, so we need to
// handle that case as well // handle that case as well
override func performDefaultImplementation() -> Any? { override func performDefaultImplementation() -> Any? {
guard let result = super.performDefaultImplementation() else { return NSNumber(booleanLiteral: false) } guard let result = super.performDefaultImplementation() else { return NSNumber(value: false) }
return result return result
} }
} }

View File

@ -388,11 +388,13 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
return grantingType.oauthAuthorizationCodeGrantRequest() return grantingType.oauthAuthorizationCodeGrantRequest()
} }
public static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse, public static func requestOAuthAccessToken(
client: OAuthAuthorizationClient, with response: OAuthAuthorizationResponse,
accountType: AccountType, client: OAuthAuthorizationClient,
transport: Transport = URLSession.webserviceTransport(), accountType: AccountType,
completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> Void) { transport: Transport = URLSession.webserviceTransport(),
completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> Void) {
let grantingType: OAuthAuthorizationGranting.Type let grantingType: OAuthAuthorizationGranting.Type
switch accountType { switch accountType {
@ -994,7 +996,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
// MARK: - Equatable // MARK: - Equatable
public class func ==(lhs: Account, rhs: Account) -> Bool { public static func ==(lhs: Account, rhs: Account) -> Bool {
return lhs === rhs return lhs === rhs
} }
} }

View File

@ -410,7 +410,7 @@ public final class AccountManager: UnreadCountProvider {
// MARK: - Notifications // MARK: - Notifications
@objc func unreadCountDidInitialize(_ notification: Notification) { @objc func unreadCountDidInitialize(_ notification: Notification) {
guard let _ = notification.object as? Account else { guard notification.object is Account else {
return return
} }
if isUnreadCountsInitialized { if isUnreadCountsInitialized {
@ -419,7 +419,7 @@ public final class AccountManager: UnreadCountProvider {
} }
@objc dynamic func unreadCountDidChange(_ notification: Notification) { @objc dynamic func unreadCountDidChange(_ notification: Notification) {
guard let _ = notification.object as? Account else { guard notification.object is Account else {
return return
} }
updateUnreadCount() updateUnreadCount()

View File

@ -60,13 +60,13 @@ extension ContainerIdentifier: Encodable {
enum CodingKeys: CodingKey { enum CodingKeys: CodingKey {
case type case type
case accountID case accountID
case folderName case folderName
} }
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
switch self { switch self {
case .smartFeedController: case .smartFeedController:
try container.encode("smartFeedController", forKey: .type) try container.encode("smartFeedController", forKey: .type)
case .account(let accountID): case .account(let accountID):
try container.encode("account", forKey: .type) try container.encode("account", forKey: .type)
@ -75,8 +75,8 @@ extension ContainerIdentifier: Encodable {
try container.encode("folder", forKey: .type) try container.encode("folder", forKey: .type)
try container.encode(accountID, forKey: .accountID) try container.encode(accountID, forKey: .accountID)
try container.encode(folderName, forKey: .folderName) try container.encode(folderName, forKey: .folderName)
} }
} }
} }
extension ContainerIdentifier: Decodable { extension ContainerIdentifier: Decodable {

View File

@ -32,7 +32,7 @@ struct FeedbinSubscription: Hashable, Codable {
hasher.combine(subscriptionID) hasher.combine(subscriptionID)
} }
static func == (lhs: FeedbinSubscription, rhs: FeedbinSubscription) -> Bool { static func ==(lhs: FeedbinSubscription, rhs: FeedbinSubscription) -> Bool {
return lhs.subscriptionID == rhs.subscriptionID return lhs.subscriptionID == rhs.subscriptionID
} }

View File

@ -277,10 +277,12 @@ extension NewsBlurAccountDelegate {
return Set(parsedItems) return Set(parsedItems)
} }
func sendStoryStatuses(_ statuses: [SyncStatus], func sendStoryStatuses(
throttle: Bool, _ statuses: [SyncStatus],
apiCall: ([String], @escaping (Result<Void, Error>) -> Void) -> Void, throttle: Bool,
completion: @escaping (Result<Void, Error>) -> Void) { apiCall: ([String], @escaping (Result<Void, Error>) -> Void) -> Void,
completion: @escaping (Result<Void, Error>) -> Void) {
guard !statuses.isEmpty else { guard !statuses.isEmpty else {
completion(.success(())) completion(.success(()))
return return

View File

@ -616,7 +616,7 @@ final class NewsBlurAccountDelegate: AccountDelegate {
caller.logout { _ in } caller.logout { _ in }
} }
class func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL? = nil, completion: @escaping (Result<Credentials?, Error>) -> Void) { static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL? = nil, completion: @escaping (Result<Credentials?, Error>) -> Void) {
let caller = NewsBlurAPICaller(transport: transport) let caller = NewsBlurAPICaller(transport: transport)
caller.credentials = credentials caller.credentials = credentials
caller.validateCredentials { result in caller.validateCredentials { result in

View File

@ -64,16 +64,14 @@ final class ReaderAPICaller: NSObject {
} }
private var apiBaseURL: URL? { private var apiBaseURL: URL? {
get { switch variant {
switch variant { case .generic, .freshRSS:
case .generic, .freshRSS: guard let accountMetadata = accountMetadata else {
guard let accountMetadata = accountMetadata else { return nil
return nil
}
return accountMetadata.endpointURL
default:
return URL(string: variant.host)
} }
return accountMetadata.endpointURL
default:
return URL(string: variant.host)
} }
} }
@ -234,13 +232,14 @@ final class ReaderAPICaller: NSObject {
let oldTagName = "user/-/label/\(encodedOldName)" let oldTagName = "user/-/label/\(encodedOldName)"
let newTagName = "user/-/label/\(encodedNewName)" let newTagName = "user/-/label/\(encodedNewName)"
let postData = "T=\(token)&s=\(oldTagName)&dest=\(newTagName)".data(using: String.Encoding.utf8) let postDataString = "T=\(token)&s=\(oldTagName)&dest=\(newTagName)"
let postData = Data(postDataString.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in self.transport.send(request: request, method: HTTPMethod.post, payload: postData, completion: { (result) in
switch result { switch result {
case .success: case .success:
completion(.success(())) completion(.success(()))
case .failure(let error): case .failure(let error):
completion(.failure(error)) completion(.failure(error))
} }
}) })
@ -270,13 +269,14 @@ final class ReaderAPICaller: NSObject {
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST" request.httpMethod = "POST"
let postData = "T=\(token)&s=\(folderExternalID)".data(using: String.Encoding.utf8) let postDataString = "T=\(token)&s=\(folderExternalID)"
let postData = Data(postDataString.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in self.transport.send(request: request, method: HTTPMethod.post, payload: postData, completion: { (result) in
switch result { switch result {
case .success: case .success:
completion(.success(())) completion(.success(()))
case .failure(let error): case .failure(let error):
completion(.failure(error)) completion(.failure(error))
} }
}) })
@ -362,9 +362,10 @@ final class ReaderAPICaller: NSObject {
completion(.failure(ReaderAPIAccountDelegateError.invalidParameter)) completion(.failure(ReaderAPIAccountDelegateError.invalidParameter))
return return
} }
let postData = "T=\(token)&quickadd=\(encodedFeedURL)".data(using: String.Encoding.utf8) let postDataString = "T=\(token)&quickadd=\(encodedFeedURL)"
let postData = Data(postDataString.utf8)
self.transport.send(request: request, method: HTTPMethod.post, data: postData!, resultType: ReaderAPIQuickAddResult.self, completion: { (result) in self.transport.send(request: request, method: HTTPMethod.post, data: postData, resultType: ReaderAPIQuickAddResult.self, completion: { (result) in
switch result { switch result {
case .success(let (_, subResult)): case .success(let (_, subResult)):
@ -412,13 +413,14 @@ final class ReaderAPICaller: NSObject {
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST" request.httpMethod = "POST"
let postData = "T=\(token)&s=\(subscriptionID)&ac=unsubscribe".data(using: String.Encoding.utf8) let postDataString = "T=\(token)&s=\(subscriptionID)&ac=unsubscribe"
let postData = Data(postDataString.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in self.transport.send(request: request, method: HTTPMethod.post, payload: postData, completion: { (result) in
switch result { switch result {
case .success: case .success:
completion(.success(())) completion(.success(()))
case .failure(let error): case .failure(let error):
completion(.failure(error)) completion(.failure(error))
} }
}) })
@ -518,9 +520,10 @@ final class ReaderAPICaller: NSObject {
} }
}).joined(separator: "&") }).joined(separator: "&")
let postData = "T=\(token)&output=json&\(idsToFetch)".data(using: String.Encoding.utf8) let postDataString = "T=\(token)&output=json&\(idsToFetch)"
let postData = Data(postDataString.utf8)
self.transport.send(request: request, method: HTTPMethod.post, data: postData!, resultType: ReaderAPIEntryWrapper.self, completion: { (result) in self.transport.send(request: request, method: HTTPMethod.post, data: postData, resultType: ReaderAPIEntryWrapper.self, completion: { (result) in
switch result { switch result {
case .success(let (_, entryWrapper)): case .success(let (_, entryWrapper)):
guard let entryWrapper = entryWrapper else { guard let entryWrapper = entryWrapper else {
@ -713,9 +716,10 @@ private extension ReaderAPICaller {
let actionIndicator = add ? "a" : "r" let actionIndicator = add ? "a" : "r"
let postData = "T=\(token)&\(idsToFetch)&\(actionIndicator)=\(state.rawValue)".data(using: String.Encoding.utf8) let postDataString = "T=\(token)&\(idsToFetch)&\(actionIndicator)=\(state.rawValue)"
let postData = Data(postDataString.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in self.transport.send(request: request, method: HTTPMethod.post, payload: postData, completion: { (result) in
switch result { switch result {
case .success: case .success:
completion(.success(())) completion(.success(()))

View File

@ -72,7 +72,7 @@ final class ArticleSearchInfo: Hashable {
// MARK: Equatable // MARK: Equatable
static func == (lhs: ArticleSearchInfo, rhs: ArticleSearchInfo) -> Bool { static func ==(lhs: ArticleSearchInfo, rhs: ArticleSearchInfo) -> Bool {
return lhs.articleID == rhs.articleID && lhs.title == rhs.title && lhs.contentHTML == rhs.contentHTML && lhs.contentText == rhs.contentText && lhs.summary == rhs.summary && lhs.authorsNames == rhs.authorsNames && lhs.searchRowID == rhs.searchRowID return lhs.articleID == rhs.articleID && lhs.title == rhs.title && lhs.contentHTML == rhs.contentHTML && lhs.contentText == rhs.contentText && lhs.summary == rhs.summary && lhs.authorsNames == rhs.authorsNames && lhs.searchRowID == rhs.searchRowID
} }
} }

View File

@ -131,8 +131,8 @@ public struct KeyboardKey: Hashable {
integerValue = KeyboardKey.deleteKeyCode integerValue = KeyboardKey.deleteKeyCode
case "[deletefunction]": case "[deletefunction]":
integerValue = NSDeleteFunctionKey integerValue = NSDeleteFunctionKey
case "[tab]": case "[tab]":
integerValue = NSTabCharacter integerValue = NSTabCharacter
default: default:
guard let unwrappedIntegerValue = s.keyboardIntegerValue else { guard let unwrappedIntegerValue = s.keyboardIntegerValue else {
return nil return nil

View File

@ -64,7 +64,7 @@ public extension NSOutlineView {
while true { while true {
row += 1 row += 1
if let _ = item(atRow: row) { if item(atRow: row) != nil {
if canSelect(row) { if canSelect(row) {
selectRowAndScrollToVisible(row) selectRowAndScrollToVisible(row)
return return

View File

@ -17,7 +17,7 @@ public extension NSResponder {
if nomad === ancestor { if nomad === ancestor {
return true return true
} }
if let _ = nomad.nextResponder { if nomad.nextResponder != nil {
nomad = nomad.nextResponder! nomad = nomad.nextResponder!
} else { } else {
break break

View File

@ -342,7 +342,7 @@ private extension MainThreadOperationQueue {
func allOperationIDsAreInStorage(_ operationIDs: [Int]) -> Bool { func allOperationIDsAreInStorage(_ operationIDs: [Int]) -> Bool {
// Used by an assert. // Used by an assert.
for operationID in operationIDs { for operationID in operationIDs {
guard let _ = operations[operationID] else { if operations[operationID] == nil {
return false return false
} }
} }