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
|
||||
|
@ -65,7 +65,7 @@ struct TimelineCellAppearance: 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
|
||||
}
|
||||
}
|
||||
|
@ -153,28 +153,28 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
}
|
||||
|
||||
@objc(accountType)
|
||||
var accountType: OSType {
|
||||
var osType: String = ""
|
||||
switch self.account.type {
|
||||
case .onMyMac:
|
||||
osType = "Locl"
|
||||
var accountType: OSType {
|
||||
var osType: String = ""
|
||||
switch self.account.type {
|
||||
case .onMyMac:
|
||||
osType = "Locl"
|
||||
case .cloudKit:
|
||||
osType = "Clkt"
|
||||
case .feedly:
|
||||
osType = "Fdly"
|
||||
case .feedbin:
|
||||
osType = "Fdbn"
|
||||
case .newsBlur:
|
||||
osType = "NBlr"
|
||||
osType = "Clkt"
|
||||
case .feedly:
|
||||
osType = "Fdly"
|
||||
case .feedbin:
|
||||
osType = "Fdbn"
|
||||
case .newsBlur:
|
||||
osType = "NBlr"
|
||||
case .freshRSS:
|
||||
osType = "Frsh"
|
||||
osType = "Frsh"
|
||||
case .inoreader:
|
||||
osType = "Inrd"
|
||||
osType = "Inrd"
|
||||
case .bazQux:
|
||||
osType = "Bzqx"
|
||||
osType = "Bzqx"
|
||||
case .theOldReader:
|
||||
osType = "Tord"
|
||||
}
|
||||
return osType.fourCharCode
|
||||
}
|
||||
osType = "Tord"
|
||||
}
|
||||
return osType.fourCharCode
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
client: OAuthAuthorizationClient,
|
||||
accountType: AccountType,
|
||||
transport: Transport = URLSession.webserviceTransport(),
|
||||
completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> Void) {
|
||||
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()
|
||||
|
@ -60,13 +60,13 @@ extension ContainerIdentifier: Encodable {
|
||||
enum CodingKeys: CodingKey {
|
||||
case type
|
||||
case accountID
|
||||
case folderName
|
||||
}
|
||||
case folderName
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
switch self {
|
||||
case .smartFeedController:
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
switch self {
|
||||
case .smartFeedController:
|
||||
try container.encode("smartFeedController", forKey: .type)
|
||||
case .account(let accountID):
|
||||
try container.encode("account", forKey: .type)
|
||||
@ -75,8 +75,8 @@ extension ContainerIdentifier: Encodable {
|
||||
try container.encode("folder", forKey: .type)
|
||||
try container.encode(accountID, forKey: .accountID)
|
||||
try container.encode(folderName, forKey: .folderName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ContainerIdentifier: Decodable {
|
||||
|
@ -32,7 +32,7 @@ struct FeedbinSubscription: Hashable, Codable {
|
||||
hasher.combine(subscriptionID)
|
||||
}
|
||||
|
||||
static func == (lhs: FeedbinSubscription, rhs: FeedbinSubscription) -> Bool {
|
||||
static func ==(lhs: FeedbinSubscription, rhs: FeedbinSubscription) -> Bool {
|
||||
return lhs.subscriptionID == rhs.subscriptionID
|
||||
}
|
||||
|
||||
|
@ -277,10 +277,12 @@ extension NewsBlurAccountDelegate {
|
||||
return Set(parsedItems)
|
||||
}
|
||||
|
||||
func sendStoryStatuses(_ statuses: [SyncStatus],
|
||||
throttle: Bool,
|
||||
apiCall: ([String], @escaping (Result<Void, Error>) -> Void) -> Void,
|
||||
completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
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,16 +64,14 @@ final class ReaderAPICaller: NSObject {
|
||||
}
|
||||
|
||||
private var apiBaseURL: URL? {
|
||||
get {
|
||||
switch variant {
|
||||
case .generic, .freshRSS:
|
||||
guard let accountMetadata = accountMetadata else {
|
||||
return nil
|
||||
}
|
||||
return accountMetadata.endpointURL
|
||||
default:
|
||||
return URL(string: variant.host)
|
||||
switch variant {
|
||||
case .generic, .freshRSS:
|
||||
guard let accountMetadata = accountMetadata else {
|
||||
return nil
|
||||
}
|
||||
return accountMetadata.endpointURL
|
||||
default:
|
||||
return URL(string: variant.host)
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,13 +232,14 @@ 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(()))
|
||||
case .failure(let error):
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
})
|
||||
@ -270,13 +269,14 @@ 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(()))
|
||||
case .failure(let error):
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
})
|
||||
@ -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,13 +413,14 @@ 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(()))
|
||||
case .failure(let error):
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
})
|
||||
@ -480,7 +482,7 @@ final class ReaderAPICaller: NSObject {
|
||||
completion(.failure(error))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
@ -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(()))
|
||||
|
@ -72,7 +72,7 @@ final class ArticleSearchInfo: Hashable {
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
@ -131,8 +131,8 @@ public struct KeyboardKey: Hashable {
|
||||
integerValue = KeyboardKey.deleteKeyCode
|
||||
case "[deletefunction]":
|
||||
integerValue = NSDeleteFunctionKey
|
||||
case "[tab]":
|
||||
integerValue = NSTabCharacter
|
||||
case "[tab]":
|
||||
integerValue = NSTabCharacter
|
||||
default:
|
||||
guard let unwrappedIntegerValue = s.keyboardIntegerValue else {
|
||||
return nil
|
||||
|
@ -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