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

@ -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(
with response: OAuthAuthorizationResponse,
client: OAuthAuthorizationClient, client: OAuthAuthorizationClient,
accountType: AccountType, accountType: AccountType,
transport: Transport = URLSession.webserviceTransport(), transport: Transport = URLSession.webserviceTransport(),
completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> Void) { 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

@ -277,10 +277,12 @@ extension NewsBlurAccountDelegate {
return Set(parsedItems) return Set(parsedItems)
} }
func sendStoryStatuses(_ statuses: [SyncStatus], func sendStoryStatuses(
_ statuses: [SyncStatus],
throttle: Bool, throttle: Bool,
apiCall: ([String], @escaping (Result<Void, Error>) -> Void) -> Void, apiCall: ([String], @escaping (Result<Void, Error>) -> Void) -> Void,
completion: @escaping (Result<Void, Error>) -> 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,7 +64,6 @@ 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 {
@ -75,7 +74,6 @@ final class ReaderAPICaller: NSObject {
return URL(string: variant.host) return URL(string: variant.host)
} }
} }
}
init(transport: Transport) { init(transport: Transport) {
self.transport = transport self.transport = transport
@ -234,9 +232,10 @@ 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(()))
@ -270,9 +269,10 @@ 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(()))
@ -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,9 +413,10 @@ 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(()))
@ -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

@ -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
} }
} }