Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ only_rules:
# Closure arguments don't need to be wrapped in parentheses.
- unneeded_parentheses_in_closure_argument

# Catch statements should not declare error variables without type casting.
- untyped_error_in_catch

# Unused parameter in a closure should be replaced with _.
- unused_closure_parameter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension DomainsServiceRemote {

do {
parameters = try queryParameters(from: params)
} catch let error {
} catch {
completion(.failure(error))
return
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/WordPressKit/FeatureFlagRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ open class FeatureFlagRemote: ServiceRemoteWordPressComREST {

do {
dictionary = try params.dictionaryRepresentation()
} catch let error {
} catch {
callback(.failure(error))
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import WordPressKitObjC
if decodedResult.isCurrentPlan {
currentlyActivePlan = decodedResult
}
} catch let error {
} catch {
WPKitLogError("Error parsing plans response for site \(error)")
}
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/WordPressKit/SiteDesignServiceRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class SiteDesignServiceRemote {
do {
let result = try parseLayouts(fromResponse: responseObject)
completion(.success(result))
} catch let error {
} catch {
NSLog("error response object: %@", String(describing: responseObject))
completion(.failure(error))
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/WordPressData/Swift/BlockedAuthor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public extension BlockedAuthor {
request.predicate = query.predicate
let result = try context.fetch(request)
return result
} catch let error {
} catch {
DDLogError("Couldn't fetch blocked author with error: \(error.localizedDescription)")
return []
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/WordPressData/Swift/BlockedSite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public extension BlockedSite {
request.predicate = NSPredicate(format: "\(#keyPath(BlockedSite.accountID)) = %@ AND \(#keyPath(BlockedSite.blogID)) = %@", accountID, blogID)
let result = try context.fetch(request)
return result
} catch let error {
} catch {
DDLogError("Couldn't fetch blocked site with error: \(error.localizedDescription)")
return []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class MigrationEmailService {
throw MigrationError.accountNotFound
}
self.init(api: account.wordPressComRestV2Api)
} catch let error {
} catch {
DDLogError("[\(MigrationError.domain)] Object instantiation failed: \(error.localizedDescription)")
throw error
}
Expand All @@ -44,7 +44,7 @@ final class MigrationEmailService {
throw MigrationError.unsuccessfulResponse
}
tracker.track(.emailSent)
} catch let error {
} catch {
let properties = ["error_type": error.localizedDescription]
tracker.track(.emailFailed, properties: properties)
DDLogError("[\(MigrationError.domain)] Migration email sending failed: \(error.localizedDescription)")
Expand All @@ -60,7 +60,7 @@ final class MigrationEmailService {
let data = try JSONSerialization.data(withJSONObject: responseObject)
let response = try decoder.decode(SendMigrationEmailResponse.self, from: data)
continuation.resume(returning: response)
} catch let error {
} catch {
continuation.resume(throwing: error)
}
} failure: { error, _ in
Expand Down
2 changes: 1 addition & 1 deletion WordPress/Classes/Services/ReaderCardService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class ReaderCardService {
guard let objectData = object as? NSManagedObject else { continue }
context.delete(objectData)
}
} catch let error {
} catch {
print("Clean card error:", error)
}
}
Expand Down
2 changes: 1 addition & 1 deletion WordPress/Classes/Services/ReaderPostStreamService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ReaderPostStreamService {
}
context.delete(post)
}
} catch let error {
} catch {
print("Clean post error:", error)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private class WeeklyRoundupDataProvider {

do {
service = try Self.makeRemoteStatsService(for: site)
} catch let error {
} catch {
self.onError(error)
continue
}
Expand Down
4 changes: 2 additions & 2 deletions WordPress/Classes/Utility/ZendeskUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,8 @@ private extension ZendeskUtils {
let eventLogging = EventLogging(dataSource: dataProvider, delegate: delegate)
try eventLogging.enqueueLogForUpload(log: logFile)
}
catch let err {
return "Error preparing log file: \(err.localizedDescription)"
catch {
return "Error preparing log file: \(error.localizedDescription)"
}

return logFile.uuid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class EncryptedLogTableViewController: UITableViewController {

try self.eventLogging.enqueueLogForUpload(log: LogFile(url: url))
}
catch let err {
let alert = UIAlertController(title: "Unable to create log", message: err.localizedDescription, preferredStyle: .actionSheet)
catch {
let alert = UIAlertController(title: "Unable to create log", message: error.localizedDescription, preferredStyle: .actionSheet)
self.present(alert, animated: true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public class MeViewController: UITableViewController {
async let refreshSettings: Void = Self.refreshAccountSettings(with: accountSettingsService)
let _ = try await [refreshDetails, refreshSettings]
self.reloadViewModel()
} catch let error {
} catch {
DDLogError("\(error.localizedDescription)")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ private extension SignupEpilogueViewController {

finished(success, error)
}
} catch let err {
finished(false, err)
} catch {
finished(false, error)
return
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class ReaderBlockUserAction {
do {
let account = try WPAccount.lookupDefaultWordPressComAccount(in: context)
return account
} catch let error {
} catch {
DDLogError("Couldn't fetch default account: \(error.localizedDescription)")
return nil
}
Expand Down Expand Up @@ -45,7 +45,7 @@ final class ReaderBlockUserAction {
try context.save()
self.trackEvent(authorID: authorID, blocked: blocked)
completion?(.success(()))
} catch let error {
} catch {
let operation = blocked ? "block" : "unblock"
DDLogError("Couldn't \(operation) author: \(error.localizedDescription)")
completion?(.failure(error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ open class Snapshot: NSObject {
setLanguage(app)
setLocale(app)
setLaunchArguments(app)
} catch let error {
} catch {
NSLog(error.localizedDescription)
}
}
Expand Down Expand Up @@ -188,7 +188,7 @@ open class Snapshot: NSObject {
#else
try image.pngData()?.write(to: path, options: .atomic)
#endif
} catch let error {
} catch {
NSLog("Problem writing screenshot: \(name) to \(screenshotsDir)/\(simulator)-\(name).png")
NSLog(error.localizedDescription)
}
Expand Down