Fix lint issues.

This commit is contained in:
Brent Simmons 2025-01-22 22:00:38 -08:00
parent 27500633ab
commit 6fc9e5c25e
47 changed files with 631 additions and 636 deletions

View File

@ -14,7 +14,7 @@ import Secrets
protocol FeedlyAPICallerDelegate: AnyObject {
/// Implemented by the `FeedlyAccountDelegate` reauthorize the client with a fresh OAuth token so the client can retry the unauthorized request.
/// Pass `true` to the completion handler if the failing request should be retried with a fresh token or `false` if the unauthorized request should complete with the original failure error.
func reauthorizeFeedlyAPICaller(_ caller: FeedlyAPICaller, completionHandler: @escaping (Bool) -> ())
func reauthorizeFeedlyAPICaller(_ caller: FeedlyAPICaller, completionHandler: @escaping (Bool) -> Void)
}
final class FeedlyAPICaller {
@ -26,7 +26,7 @@ final class FeedlyAPICaller {
var baseUrlComponents: URLComponents {
var components = URLComponents()
components.scheme = "https"
switch self{
switch self {
case .sandbox:
// https://groups.google.com/forum/#!topic/feedly-cloud/WwQWMgDmOuw
components.host = "sandbox7.feedly.com"
@ -132,7 +132,7 @@ final class FeedlyAPICaller {
}
}
func importOpml(_ opmlData: Data, completion: @escaping (Result<Void, Error>) -> ()) {
func importOpml(_ opmlData: Data, completion: @escaping (Result<Void, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -172,7 +172,7 @@ final class FeedlyAPICaller {
}
}
func createCollection(named label: String, completion: @escaping (Result<FeedlyCollection, Error>) -> ()) {
func createCollection(named label: String, completion: @escaping (Result<FeedlyCollection, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -224,7 +224,7 @@ final class FeedlyAPICaller {
}
}
func renameCollection(with id: String, to name: String, completion: @escaping (Result<FeedlyCollection, Error>) -> ()) {
func renameCollection(with id: String, to name: String, completion: @escaping (Result<FeedlyCollection, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -281,7 +281,7 @@ final class FeedlyAPICaller {
return pathComponent.addingPercentEncoding(withAllowedCharacters: uriComponentAllowed)
}
func deleteCollection(with id: String, completion: @escaping (Result<Void, Error>) -> ()) {
func deleteCollection(with id: String, completion: @escaping (Result<Void, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -325,7 +325,7 @@ final class FeedlyAPICaller {
}
}
func removeFeed(_ feedId: String, fromCollectionWith collectionId: String, completion: @escaping (Result<Void, Error>) -> ()) {
func removeFeed(_ feedId: String, fromCollectionWith collectionId: String, completion: @escaping (Result<Void, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -389,7 +389,7 @@ final class FeedlyAPICaller {
extension FeedlyAPICaller: FeedlyAddFeedToCollectionService {
func addFeed(with feedId: FeedlyFeedResourceId, title: String? = nil, toCollectionWith collectionId: String, completion: @escaping (Result<[FeedlyFeed], Error>) -> ()) {
func addFeed(with feedId: FeedlyFeedResourceId, title: String? = nil, toCollectionWith collectionId: String, completion: @escaping (Result<[FeedlyFeed], Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -470,7 +470,7 @@ extension FeedlyAPICaller: OAuthAuthorizationCodeGrantRequesting {
typealias AccessTokenResponse = FeedlyOAuthAccessTokenResponse
func requestAccessToken(_ authorizationRequest: OAuthAccessTokenRequest, completion: @escaping (Result<FeedlyOAuthAccessTokenResponse, Error>) -> ()) {
func requestAccessToken(_ authorizationRequest: OAuthAccessTokenRequest, completion: @escaping (Result<FeedlyOAuthAccessTokenResponse, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -517,7 +517,7 @@ extension FeedlyAPICaller: OAuthAuthorizationCodeGrantRequesting {
extension FeedlyAPICaller: OAuthAcessTokenRefreshRequesting {
func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest, completion: @escaping (Result<FeedlyOAuthAccessTokenResponse, Error>) -> ()) {
func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest, completion: @escaping (Result<FeedlyOAuthAccessTokenResponse, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -564,7 +564,7 @@ extension FeedlyAPICaller: OAuthAcessTokenRefreshRequesting {
extension FeedlyAPICaller: FeedlyGetCollectionsService {
func getCollections(completion: @escaping (Result<[FeedlyCollection], Error>) -> ()) {
func getCollections(completion: @escaping (Result<[FeedlyCollection], Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -605,7 +605,7 @@ extension FeedlyAPICaller: FeedlyGetCollectionsService {
extension FeedlyAPICaller: FeedlyGetStreamContentsService {
func getStreamContents(for resource: FeedlyResourceId, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStream, Error>) -> ()) {
func getStreamContents(for resource: FeedlyResourceId, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStream, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -642,7 +642,7 @@ extension FeedlyAPICaller: FeedlyGetStreamContentsService {
queryItems.append(contentsOf: [
URLQueryItem(name: "count", value: "1000"),
URLQueryItem(name: "streamId", value: resource.id),
URLQueryItem(name: "streamId", value: resource.id)
])
components.queryItems = queryItems
@ -673,7 +673,7 @@ extension FeedlyAPICaller: FeedlyGetStreamContentsService {
extension FeedlyAPICaller: FeedlyGetStreamIdsService {
func getStreamIds(for resource: FeedlyResourceId, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStreamIds, Error>) -> ()) {
func getStreamIds(for resource: FeedlyResourceId, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStreamIds, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -710,7 +710,7 @@ extension FeedlyAPICaller: FeedlyGetStreamIdsService {
queryItems.append(contentsOf: [
URLQueryItem(name: "count", value: "10000"),
URLQueryItem(name: "streamId", value: resource.id),
URLQueryItem(name: "streamId", value: resource.id)
])
components.queryItems = queryItems
@ -741,7 +741,7 @@ extension FeedlyAPICaller: FeedlyGetStreamIdsService {
extension FeedlyAPICaller: FeedlyGetEntriesService {
func getEntries(for ids: Set<String>, completion: @escaping (Result<[FeedlyEntry], Error>) -> ()) {
func getEntries(for ids: Set<String>, completion: @escaping (Result<[FeedlyEntry], Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -802,7 +802,7 @@ extension FeedlyAPICaller: FeedlyMarkArticlesService {
var entryIds: [String]
}
func mark(_ articleIds: Set<String>, as action: FeedlyMarkAction, completion: @escaping (Result<Void, Error>) -> ()) {
func mark(_ articleIds: Set<String>, as action: FeedlyMarkAction, completion: @escaping (Result<Void, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))
@ -823,7 +823,7 @@ extension FeedlyAPICaller: FeedlyMarkArticlesService {
let articleIdChunks = Array(articleIds).chunked(into: 300)
let dispatchGroup = DispatchGroup()
var groupError: Error? = nil
var groupError: Error?
for articleIdChunk in articleIdChunks {
@ -870,7 +870,7 @@ extension FeedlyAPICaller: FeedlyMarkArticlesService {
extension FeedlyAPICaller: FeedlySearchService {
func getFeeds(for query: String, count: Int, locale: String, completion: @escaping (Result<FeedlyFeedsSearchResponse, Error>) -> ()) {
func getFeeds(for query: String, count: Int, locale: String, completion: @escaping (Result<FeedlyFeedsSearchResponse, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
@ -887,7 +887,6 @@ extension FeedlyAPICaller: FeedlySearchService {
URLQueryItem(name: "locale", value: locale)
]
guard let url = components.url else {
fatalError("\(components) does not produce a valid URL.")
}
@ -914,7 +913,7 @@ extension FeedlyAPICaller: FeedlySearchService {
extension FeedlyAPICaller: FeedlyLogoutService {
func logout(completion: @escaping (Result<Void, Error>) -> ()) {
func logout(completion: @escaping (Result<Void, Error>) -> Void) {
guard !isSuspended else {
return DispatchQueue.main.async {
completion(.failure(TransportError.suspended))

View File

@ -38,7 +38,7 @@ extension FeedlyAccountDelegate: OAuthAuthorizationGranting {
return FeedlyAPICaller.authorizationCodeUrlRequest(for: authorizationRequest, baseUrlComponents: baseURLComponents)
}
static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse, transport: Transport, completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ()) {
static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse, transport: Transport, completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> Void) {
let client = environment.oauthAuthorizationClient
let request = OAuthAccessTokenRequest(authorizationResponse: response,
scope: oauthAuthorizationGrantScope,
@ -68,7 +68,7 @@ extension FeedlyAccountDelegate: OAuthAuthorizationGranting {
}
extension FeedlyAccountDelegate: OAuthAccessTokenRefreshing {
func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ()) {
func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> Void) {
let request = OAuthRefreshAccessTokenRequest(refreshToken: refreshToken, scope: nil, client: client)
caller.refreshAccessToken(request) { result in

View File

@ -105,7 +105,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
// MARK: Account API
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any], completion: @escaping () -> Void) {
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable: Any], completion: @escaping () -> Void) {
completion()
}
@ -170,7 +170,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
func sendArticleStatus(for account: Account, completion: @escaping ((Result<Void, Error>) -> Void)) {
// Ensure remote articles have the same status as they do locally.
let send = FeedlySendArticleStatusesOperation(database: database, service: caller, log: log)
send.completionBlock = { operation in
send.completionBlock = { _ in
// TODO: not call with success if operation was canceled? Not sure.
DispatchQueue.main.async {
completion(.success(()))
@ -395,7 +395,6 @@ final class FeedlyAccountDelegate: AccountDelegate {
log: log,
customFeedName: feed.editedName)
addExistingFeed.addCompletionHandler = { result in
completion(result)
}
@ -570,7 +569,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
extension FeedlyAccountDelegate: FeedlyAPICallerDelegate {
func reauthorizeFeedlyAPICaller(_ caller: FeedlyAPICaller, completionHandler: @escaping (Bool) -> ()) {
func reauthorizeFeedlyAPICaller(_ caller: FeedlyAPICaller, completionHandler: @escaping (Bool) -> Void) {
guard let account = initializedAccount else {
completionHandler(false)
return

View File

@ -36,11 +36,11 @@ public protocol OAuthAcessTokenRefreshRequesting {
/// Access tokens expire. Perform a request for a fresh access token given the long life refresh token received when authorization was granted.
/// - Parameter refreshRequest: The refresh token and other information the authorization server requires to grant the client fresh access tokens on the user's behalf.
/// - Parameter completion: On success, the access token response appropriate for concrete type's service. Both the access and refresh token should be stored, preferably on the Keychain. On failure, possibly a `URLError` or `OAuthAuthorizationErrorResponse` value.
func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest, completion: @escaping (Result<AccessTokenResponse, Error>) -> ())
func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest, completion: @escaping (Result<AccessTokenResponse, Error>) -> Void)
}
/// Implemented by concrete types to perform the actual request.
protocol OAuthAccessTokenRefreshing: AnyObject {
func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ())
func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> Void)
}

View File

@ -15,7 +15,7 @@ import Secrets
class FeedlyAddExistingFeedOperation: FeedlyOperation, FeedlyOperationDelegate, FeedlyCheckpointOperationDelegate {
private let operationQueue = MainThreadOperationQueue()
var addCompletionHandler: ((Result<Void, Error>) -> ())?
var addCompletionHandler: ((Result<Void, Error>) -> Void)?
init(account: Account, credentials: Credentials, resource: FeedlyFeedResourceId, service: FeedlyAddFeedToCollectionService, container: Container, progress: DownloadProgress, log: OSLog, customFeedName: String? = nil) throws {

View File

@ -9,7 +9,7 @@
import Foundation
protocol FeedlyAddFeedToCollectionService {
func addFeed(with feedId: FeedlyFeedResourceId, title: String?, toCollectionWith collectionId: String, completion: @escaping (Result<[FeedlyFeed], Error>) -> ())
func addFeed(with feedId: FeedlyFeedResourceId, title: String?, toCollectionWith collectionId: String, completion: @escaping (Result<[FeedlyFeed], Error>) -> Void)
}
final class FeedlyAddFeedToCollectionOperation: FeedlyOperation, FeedlyFeedsAndFoldersProviding, FeedlyResourceProviding {

View File

@ -28,11 +28,10 @@ class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate, Feedl
private let getStreamContentsService: FeedlyGetStreamContentsService
private let log: OSLog
private var feedResourceId: FeedlyFeedResourceId?
var addCompletionHandler: ((Result<Feed, Error>) -> ())?
var addCompletionHandler: ((Result<Feed, Error>) -> Void)?
init(account: Account, credentials: Credentials, url: String, feedName: String?, searchService: FeedlySearchService, addToCollectionService: FeedlyAddFeedToCollectionService, syncUnreadIdsService: FeedlyGetStreamIdsService, getStreamContentsService: FeedlyGetStreamContentsService, database: SyncDatabase, container: Container, progress: DownloadProgress, log: OSLog) throws {
let validator = FeedlyFeedContainerValidator(container: container)
(self.folder, self.collectionId) = try validator.getValidContainer()
@ -139,8 +138,7 @@ class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate, Feedl
}
if let feedResource = feedResourceId, let feed = folder.existingFeed(withFeedID: feedResource.id) {
handler(.success(feed))
}
else {
} else {
handler(.failure(AccountError.createErrorNotFound))
}
addCompletionHandler = nil

View File

@ -71,7 +71,7 @@ class FeedlyDownloadArticlesOperation: FeedlyOperation {
override func didCancel() {
// TODO: fix error on below line: "Expression type '()' is ambiguous without more context"
//os_log(.debug, log: log, "Cancelling %{public}@.", self)
// os_log(.debug, log: log, "Cancelling %{public}@.", self)
operationQueue.cancelAllOperations()
super.didCancel()
}

View File

@ -10,7 +10,7 @@ import Foundation
import os.log
protocol FeedlyLogoutService {
func logout(completion: @escaping (Result<Void, Error>) -> ())
func logout(completion: @escaping (Result<Void, Error>) -> Void)
}
final class FeedlyLogoutOperation: FeedlyOperation {

View File

@ -26,7 +26,7 @@ final class FeedlyOrganiseParsedItemsByFeedOperation: FeedlyOperation, FeedlyPar
return name ?? String(describing: Self.self)
}
var parsedItemsKeyedByFeedId: [String : Set<ParsedItem>] {
var parsedItemsKeyedByFeedId: [String: Set<ParsedItem>] {
precondition(Thread.isMainThread) // Needs to be on main thread because Feed is a main-thread-only model type.
return itemsKeyedByFeedId
}

View File

@ -9,7 +9,7 @@
import Foundation
protocol FeedlySearchService: AnyObject {
func getFeeds(for query: String, count: Int, locale: String, completion: @escaping (Result<FeedlyFeedsSearchResponse, Error>) -> ())
func getFeeds(for query: String, count: Int, locale: String, completion: @escaping (Result<FeedlyFeedsSearchResponse, Error>) -> Void)
}
protocol FeedlySearchOperationDelegate: AnyObject {

View File

@ -20,7 +20,7 @@ final class FeedlySyncAllOperation: FeedlyOperation {
private let log: OSLog
let syncUUID: UUID
var syncCompletionHandler: ((Result<Void, Error>) -> ())?
var syncCompletionHandler: ((Result<Void, Error>) -> Void)?
/// These requests to Feedly determine which articles to download:
/// 1. The set of all article ids we might need or show.

View File

@ -70,7 +70,6 @@ final class FeedlySyncStreamContentsOperation: FeedlyOperation, FeedlyOperationD
newerThan: newerThan,
log: log)
let organiseByFeed = FeedlyOrganiseParsedItemsByFeedOperation(account: account, parsedItemProvider: getPage, log: log)
let updateAccount = FeedlyUpdateAccountFeedsWithItemsOperation(account: account, organisedItemsProvider: organiseByFeed, log: log)

View File

@ -9,5 +9,5 @@
import Foundation
protocol FeedlyGetCollectionsService: AnyObject {
func getCollections(completion: @escaping (Result<[FeedlyCollection], Error>) -> ())
func getCollections(completion: @escaping (Result<[FeedlyCollection], Error>) -> Void)
}

View File

@ -9,5 +9,5 @@
import Foundation
protocol FeedlyGetEntriesService: AnyObject {
func getEntries(for ids: Set<String>, completion: @escaping (Result<[FeedlyEntry], Error>) -> ())
func getEntries(for ids: Set<String>, completion: @escaping (Result<[FeedlyEntry], Error>) -> Void)
}

View File

@ -9,5 +9,5 @@
import Foundation
protocol FeedlyGetStreamContentsService: AnyObject {
func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStream, Error>) -> ())
func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStream, Error>) -> Void)
}

View File

@ -9,5 +9,5 @@
import Foundation
protocol FeedlyGetStreamIdsService: AnyObject {
func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStreamIds, Error>) -> ())
func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStreamIds, Error>) -> Void)
}

View File

@ -31,5 +31,5 @@ enum FeedlyMarkAction: String {
}
protocol FeedlyMarkArticlesService: AnyObject {
func mark(_ articleIds: Set<String>, as action: FeedlyMarkAction, completion: @escaping (Result<Void, Error>) -> ())
func mark(_ articleIds: Set<String>, as action: FeedlyMarkAction, completion: @escaping (Result<Void, Error>) -> Void)
}