Fix lint issues.
This commit is contained in:
parent
cc4914a7ef
commit
cc34209738
@ -25,11 +25,14 @@ disabled_rules:
|
||||
- type_body_length
|
||||
- function_parameter_count
|
||||
- line_length
|
||||
- operator_whitespace
|
||||
|
||||
excluded:
|
||||
- Modules/Secrets/Sources/Secrets/SecretKey.swift
|
||||
- Modules/Account/Tests/AccountTests/Feedly/
|
||||
- Modules/Account/Sources/Account/Feedly/
|
||||
- Widget/Resources/Localized.swift
|
||||
- Shared/Extensions/NSAttributedString+NetNewsWire.swift
|
||||
- buildscripts/
|
||||
|
||||
|
||||
|
@ -35,11 +35,7 @@ final class FolderInspectorViewController: NSViewController, Inspector {
|
||||
var windowTitle: String = NSLocalizedString("Folder Inspector", comment: "Folder Inspector window title")
|
||||
|
||||
func canInspect(_ objects: [Any]) -> Bool {
|
||||
|
||||
guard let _ = singleFolder(from: objects) else {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
singleFolder(from: objects) != nil
|
||||
}
|
||||
|
||||
// MARK: NSViewController
|
||||
|
@ -24,7 +24,7 @@ protocol AppDelegateAppleEvents {
|
||||
func getURL(_ event: NSAppleEventDescriptor, _ withReplyEvent: NSAppleEventDescriptor)
|
||||
}
|
||||
|
||||
protocol ScriptingAppDelegate {
|
||||
protocol ScriptingAppDelegate: AnyObject {
|
||||
var scriptingCurrentArticle: Article? {get}
|
||||
var scriptingSelectedArticles: [Article] {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
|
||||
// <property> of <property> of <top level object>
|
||||
// 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
|
||||
// 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
|
||||
// handle that case as well
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -388,11 +388,13 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
return grantingType.oauthAuthorizationCodeGrantRequest()
|
||||
}
|
||||
|
||||
public static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse,
|
||||
public static func requestOAuthAccessToken(
|
||||
with response: OAuthAuthorizationResponse,
|
||||
client: OAuthAuthorizationClient,
|
||||
accountType: AccountType,
|
||||
transport: Transport = URLSession.webserviceTransport(),
|
||||
completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> Void) {
|
||||
|
||||
let grantingType: OAuthAuthorizationGranting.Type
|
||||
|
||||
switch accountType {
|
||||
@ -994,7 +996,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
|
||||
// MARK: - Equatable
|
||||
|
||||
public class func ==(lhs: Account, rhs: Account) -> Bool {
|
||||
public static func ==(lhs: Account, rhs: Account) -> Bool {
|
||||
return lhs === rhs
|
||||
}
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ public final class AccountManager: UnreadCountProvider {
|
||||
// MARK: - Notifications
|
||||
|
||||
@objc func unreadCountDidInitialize(_ notification: Notification) {
|
||||
guard let _ = notification.object as? Account else {
|
||||
guard notification.object is Account else {
|
||||
return
|
||||
}
|
||||
if isUnreadCountsInitialized {
|
||||
@ -419,7 +419,7 @@ public final class AccountManager: UnreadCountProvider {
|
||||
}
|
||||
|
||||
@objc dynamic func unreadCountDidChange(_ notification: Notification) {
|
||||
guard let _ = notification.object as? Account else {
|
||||
guard notification.object is Account else {
|
||||
return
|
||||
}
|
||||
updateUnreadCount()
|
||||
|
@ -277,10 +277,12 @@ extension NewsBlurAccountDelegate {
|
||||
return Set(parsedItems)
|
||||
}
|
||||
|
||||
func sendStoryStatuses(_ statuses: [SyncStatus],
|
||||
func sendStoryStatuses(
|
||||
_ statuses: [SyncStatus],
|
||||
throttle: Bool,
|
||||
apiCall: ([String], @escaping (Result<Void, Error>) -> Void) -> Void,
|
||||
completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
|
||||
guard !statuses.isEmpty else {
|
||||
completion(.success(()))
|
||||
return
|
||||
|
@ -616,7 +616,7 @@ final class NewsBlurAccountDelegate: AccountDelegate {
|
||||
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)
|
||||
caller.credentials = credentials
|
||||
caller.validateCredentials { result in
|
||||
|
@ -64,7 +64,6 @@ final class ReaderAPICaller: NSObject {
|
||||
}
|
||||
|
||||
private var apiBaseURL: URL? {
|
||||
get {
|
||||
switch variant {
|
||||
case .generic, .freshRSS:
|
||||
guard let accountMetadata = accountMetadata else {
|
||||
@ -75,7 +74,6 @@ final class ReaderAPICaller: NSObject {
|
||||
return URL(string: variant.host)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(transport: Transport) {
|
||||
self.transport = transport
|
||||
@ -234,9 +232,10 @@ final class ReaderAPICaller: NSObject {
|
||||
|
||||
let oldTagName = "user/-/label/\(encodedOldName)"
|
||||
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 {
|
||||
case .success:
|
||||
completion(.success(()))
|
||||
@ -270,9 +269,10 @@ final class ReaderAPICaller: NSObject {
|
||||
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
|
||||
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 {
|
||||
case .success:
|
||||
completion(.success(()))
|
||||
@ -362,9 +362,10 @@ final class ReaderAPICaller: NSObject {
|
||||
completion(.failure(ReaderAPIAccountDelegateError.invalidParameter))
|
||||
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 {
|
||||
case .success(let (_, subResult)):
|
||||
|
||||
@ -412,9 +413,10 @@ final class ReaderAPICaller: NSObject {
|
||||
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
|
||||
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 {
|
||||
case .success:
|
||||
completion(.success(()))
|
||||
@ -518,9 +520,10 @@ final class ReaderAPICaller: NSObject {
|
||||
}
|
||||
}).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 {
|
||||
case .success(let (_, entryWrapper)):
|
||||
guard let entryWrapper = entryWrapper else {
|
||||
@ -713,9 +716,10 @@ private extension ReaderAPICaller {
|
||||
|
||||
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 {
|
||||
case .success:
|
||||
completion(.success(()))
|
||||
|
@ -64,7 +64,7 @@ public extension NSOutlineView {
|
||||
|
||||
while true {
|
||||
row += 1
|
||||
if let _ = item(atRow: row) {
|
||||
if item(atRow: row) != nil {
|
||||
if canSelect(row) {
|
||||
selectRowAndScrollToVisible(row)
|
||||
return
|
||||
|
@ -17,7 +17,7 @@ public extension NSResponder {
|
||||
if nomad === ancestor {
|
||||
return true
|
||||
}
|
||||
if let _ = nomad.nextResponder {
|
||||
if nomad.nextResponder != nil {
|
||||
nomad = nomad.nextResponder!
|
||||
} else {
|
||||
break
|
||||
|
@ -342,7 +342,7 @@ private extension MainThreadOperationQueue {
|
||||
func allOperationIDsAreInStorage(_ operationIDs: [Int]) -> Bool {
|
||||
// Used by an assert.
|
||||
for operationID in operationIDs {
|
||||
guard let _ = operations[operationID] else {
|
||||
if operations[operationID] == nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user