Skip to content
Open
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 @@ -98,6 +98,9 @@ only_rules:
# Lines should not have trailing whitespace.
- trailing_whitespace

# Closure arguments don't need to be wrapped in parentheses.
- unneeded_parentheses_in_closure_argument

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

Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/AztecExtensions/ImgUploadProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ImgUploadProcessor: Processor {
self.height = height
}

lazy var imgPostMediaUploadProcessor = HTMLProcessor(for: "img", replacer: { (img) in
lazy var imgPostMediaUploadProcessor = HTMLProcessor(for: "img", replacer: { img in
guard let imgUploadValue = img.attributes[MediaAttachment.uploadKey]?.value,
case let .string(imgUploadID) = imgUploadValue,
self.mediaUploadID == imgUploadID else {
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/DesignSystem/Gallery/FontGallery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct FontGallery: View {
var body: some View {
List {
Section("Recoleta") {
ForEach(textStyles, id: \.self.1) { (name, textStyle) in
ForEach(textStyles, id: \.self.1) { name, textStyle in
Text(name)
.font(Font.make(.recoleta, textStyle: textStyle))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ extension WordPressKit.StatsServiceRemoteV2 {

func getEmailOpens(for postID: Int) async throws -> StatsEmailOpensData {
try await withCheckedThrowingContinuation { continuation in
getEmailOpens(for: postID) { (data, error) in
getEmailOpens(for: postID) { data, error in
if let data {
continuation.resume(returning: data)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ actor MockStatsService: ObservableObject, StatsServiceProtocol {

// Convert to array with updated metric value and sort
let sortedItems = aggregatedItems.values
.map { (item, totalValue) -> any TopListItemProtocol in
.map { item, totalValue -> any TopListItemProtocol in
// Create a mutable copy and update the aggregated metric value
var mutableItem = item
mutableItem.metrics[metric] = totalValue
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/JetpackStats/Services/StatsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ actor StatsService: StatsServiceProtocol {
switch metric {
case .views:
let data = try await getData(StatsArchiveTimeIntervalData.self)
let sections = data.summary.compactMap { (sectionName, items) -> TopListItem.ArchiveSection? in
let sections = data.summary.compactMap { sectionName, items -> TopListItem.ArchiveSection? in
guard !items.isEmpty else { return nil }
return TopListItem.ArchiveSection(sectionName: sectionName, items: items)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class SharedCoreDataStack {

fileprivate lazy var storeContainer: SharedPersistentContainer = {
let container = SharedPersistentContainer(name: "SharedCoreDataStack", managedObjectModel: SharedCoreDataStack.model)
container.loadPersistentStores { (_, error) in
container.loadPersistentStores { _, error in
if let error = error as NSError? {
DDLogError("Error loading persistent stores: \(error), \(error.userInfo)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ public class AztecEditorScreen: ScreenObject {

// returns void since return screen depends on from which screen it loaded
public func closeEditor() {
XCTContext.runActivity(named: "Close the Aztec editor") { (_) in
XCTContext.runActivity(named: "Close the More menu if needed") { (_) in
XCTContext.runActivity(named: "Close the Aztec editor") { _ in
XCTContext.runActivity(named: "Close the More menu if needed") { _ in
let actionSheet = app.sheets.element(boundBy: 0)
if actionSheet.exists {
if XCTestCase.isPad {
Expand All @@ -228,7 +228,7 @@ public class AztecEditorScreen: ScreenObject {

editorCloseButton.tap()

XCTContext.runActivity(named: "Discard any local changes") { (_) in
XCTContext.runActivity(named: "Discard any local changes") { _ in

let postHasChangesSheet = app.sheets["post-has-changes-alert"]
let discardButton = XCTestCase.isPad ? postHasChangesSheet.buttons.lastMatch : postHasChangesSheet.buttons.element(boundBy: 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ public class BlockEditorScreen: ScreenObject {

// returns void since return screen depends on from which screen it loaded
public func closeEditor() {
XCTContext.runActivity(named: "Close the block editor") { (_) in
XCTContext.runActivity(named: "Close the More menu if needed") { (_) in
XCTContext.runActivity(named: "Close the block editor") { _ in
XCTContext.runActivity(named: "Close the More menu if needed") { _ in
let actionSheet = app.sheets.element(boundBy: 0)
if actionSheet.exists {
dismissBlockEditorPopovers()
Expand All @@ -260,7 +260,7 @@ public class BlockEditorScreen: ScreenObject {
editorCloseButton.waitForIsHittable(timeout: 3)
editorCloseButton.tap()

XCTContext.runActivity(named: "Discard any local changes") { (_) in
XCTContext.runActivity(named: "Discard any local changes") { _ in
guard unsavedChangesLabel.waitForIsHittable(timeout: 3) else { return }

Logger.log(message: "Discarding unsaved changes", event: .v)
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/WordPressFlux/Dispatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class Dispatcher<Payload> {
///
public func dispatch(_ payload: Payload) {
assertMainThread()
self.observers.forEach { (_, callback) in
self.observers.forEach { _, callback in
callback(payload)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/WordPressFlux/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ open class Store: Observable {
///
public init(dispatcher: ActionDispatcher = .global) {
actionDispatcher = dispatcher
dispatchReceipt = dispatcher.subscribe { [weak self] (action) in
dispatchReceipt = dispatcher.subscribe { [weak self] action in
self?.onDispatch(action)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ extension AccountServiceRemoteREST {
] as [String: AnyObject]

if let connectParameters {
params.merge(connectParameters, uniquingKeysWith: { (current, _) in current })
params.merge(connectParameters, uniquingKeysWith: { current, _ in current })
}

wordPressComRESTAPI.post(path, parameters: params, success: { (_, _) in
wordPressComRESTAPI.post(path, parameters: params, success: { _, _ in
success()
}, failure: { (error, _) in
}, failure: { error, _ in
failure(error)
})
}
Expand Down Expand Up @@ -73,9 +73,9 @@ extension AccountServiceRemoteREST {
"service": service.rawValue
] as [String: AnyObject]

wordPressComRESTAPI.post(path, parameters: params, success: { (_, _) in
wordPressComRESTAPI.post(path, parameters: params, success: { _, _ in
success()
}, failure: { (error, _) in
}, failure: { error, _ in
failure(error)
})
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/Sources/WordPressKit/AccountSettingsRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ public class AccountSettingsRemote: ServiceRemoteWordPressComREST {
let endpoint = "wpcom/v2/users/username/suggestions"
let parameters = ["name": base]

wordPressComRESTAPI.get(endpoint, parameters: parameters as [String: AnyObject]?, success: { (responseObject, _) in
wordPressComRESTAPI.get(endpoint, parameters: parameters as [String: AnyObject]?, success: { responseObject, _ in
guard let response = responseObject as? [String: AnyObject],
let suggestions = response["suggestions"] as? [String] else {
finished([])
return
}

finished(suggestions)
}) { (_, _) in
}) { _, _ in
finished([])
}
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/WordPressKit/ActivityServiceRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private extension ActivityServiceRemote {
throw ActivityServiceRemote.ResponseError.decodingFailure
}

let groups: [ActivityGroup] = try rawGroups.map { (key, value) -> ActivityGroup in
let groups: [ActivityGroup] = try rawGroups.map { key, value -> ActivityGroup in
guard let group = value as? [String: AnyObject] else {
throw ActivityServiceRemote.ResponseError.decodingFailure
}
Expand Down
10 changes: 5 additions & 5 deletions Modules/Sources/WordPressKit/AutomatedTransferService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class AutomatedTransferService: ServiceRemoteWordPressComREST {
let endpoint = "sites/\(siteID)/automated-transfers/eligibility"
let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)

wordPressComRESTAPI.get(path, parameters: nil, success: { (responseObject, _) in
wordPressComRESTAPI.get(path, parameters: nil, success: { responseObject, _ in
guard let response = responseObject as? [String: AnyObject] else {
failure(.unknown)
return
Expand All @@ -54,7 +54,7 @@ public class AutomatedTransferService: ServiceRemoteWordPressComREST {
let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)
let payload = ["plugin": pluginSlug] as [String: AnyObject]

wordPressComRESTAPI.post(path, parameters: payload, success: { (responseObject, _) in
wordPressComRESTAPI.post(path, parameters: payload, success: { responseObject, _ in
guard let response = responseObject as? [String: AnyObject] else {
failure(ResponseError.decodingFailure)
return
Expand All @@ -68,7 +68,7 @@ public class AutomatedTransferService: ServiceRemoteWordPressComREST {
}

success((transferID: transferID, status: statusObject))
}) { (error, _) in
}) { error, _ in
failure(error)
}

Expand All @@ -81,7 +81,7 @@ public class AutomatedTransferService: ServiceRemoteWordPressComREST {
let endpoint = "sites/\(siteID)/automated-transfers/status"
let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)

wordPressComRESTAPI.get(path, parameters: nil, success: { (responseObject, _) in
wordPressComRESTAPI.get(path, parameters: nil, success: { responseObject, _ in
guard let response = responseObject as? [String: AnyObject] else {
failure(ResponseError.decodingFailure)
return
Expand All @@ -96,7 +96,7 @@ public class AutomatedTransferService: ServiceRemoteWordPressComREST {
}

success(statusObject)
}) { (error, _) in
}) { error, _ in
failure(error)
}

Expand Down
6 changes: 3 additions & 3 deletions Modules/Sources/WordPressKit/DomainsServiceRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public class DomainsServiceRemote: ServiceRemoteWordPressComREST {
wordPressComRESTAPI.get(
servicePath,
parameters: nil,
success: { (response, _) in
success: { response, _ in
do {
let data = try JSONSerialization.data(withJSONObject: response, options: .prettyPrinted)
let decodedResult = try JSONDecoder.apiDecoder.decode(DomainContactInformation.self, from: data)
Expand All @@ -188,7 +188,7 @@ public class DomainsServiceRemote: ServiceRemoteWordPressComREST {
WPKitLogError("Error parsing DomainContactInformation (\(error)): \(response)")
failure(error)
}
}) { (error, _) in
}) { error, _ in
failure(error)
}
}
Expand All @@ -214,7 +214,7 @@ public class DomainsServiceRemote: ServiceRemoteWordPressComREST {
WPKitLogError("Error parsing ValidateDomainContactInformationResponse (\(error)): \(response)")
failure(error)
}
}) { (error, _) in
}) { error, _ in
failure(error)
}
}
Expand Down
14 changes: 7 additions & 7 deletions Modules/Sources/WordPressKit/EditorServiceRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ public class EditorServiceRemote: ServiceRemoteWordPressComREST {
let endpoint = "sites/\(siteID)/gutenberg?platform=mobile&editor=\(editor.rawValue)"
let path = self.path(forEndpoint: endpoint, withVersion: ._2_0)

wordPressComRESTAPI.post(path, parameters: nil, success: { (responseObject, _) in
wordPressComRESTAPI.post(path, parameters: nil, success: { responseObject, _ in
do {
let settings = try EditorSettings(with: responseObject)
success(settings)
} catch {
failure(error)
}
}) { (error, _) in
}) { error, _ in
failure(error)
}
}
Expand All @@ -28,21 +28,21 @@ public class EditorServiceRemote: ServiceRemoteWordPressComREST {
"set_only_if_empty": setOnlyIfEmpty
] as [String: AnyObject]

wordPressComRESTAPI.post(path, parameters: parameters, success: { (responseObject, _) in
wordPressComRESTAPI.post(path, parameters: parameters, success: { responseObject, _ in
guard let response = responseObject as? [String: String] else {
if let boolResponse = responseObject as? Bool, boolResponse == false {
return failure(EditorSettings.Error.badRequest)
}
return failure(EditorSettings.Error.badResponse)
}

let mappedResponse = response.reduce(into: [Int: EditorSettings.Mobile](), { (result, response) in
let mappedResponse = response.reduce(into: [Int: EditorSettings.Mobile](), { result, response in
if let id = Int(response.key), let editor = EditorSettings.Mobile(rawValue: response.value) {
result[id] = editor
}
})
success(mappedResponse)
}) { (error, _) in
}) { error, _ in
failure(error)
}
}
Expand All @@ -51,14 +51,14 @@ public class EditorServiceRemote: ServiceRemoteWordPressComREST {
let endpoint = "sites/\(siteID)/gutenberg"
let path = self.path(forEndpoint: endpoint, withVersion: ._2_0)

wordPressComRESTAPI.get(path, parameters: nil, success: { (responseObject, _) in
wordPressComRESTAPI.get(path, parameters: nil, success: { responseObject, _ in
do {
let settings = try EditorSettings(with: responseObject)
success(settings)
} catch {
failure(error)
}
}) { (error, _) in
}) { error, _ in
failure(error)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/WordPressKit/GravatarServiceRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ open class GravatarServiceRemote {

// Task
let session = URLSession.shared
let task = session.uploadTask(with: request as URLRequest, from: requestBody, completionHandler: { (_, _, error) in
let task = session.uploadTask(with: request as URLRequest, from: requestBody, completionHandler: { _, _, error in
completion?(error as NSError?)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ open class HTTPAuthenticationAlertController {

let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: "Cancel button label"),
style: .default,
handler: { (_) in
handler: { _ in
executeHandlerForChallenge(challenge, disposition: .cancelAuthenticationChallenge, credential: nil)
})
controller.addAction(cancelAction)

let trustAction = UIAlertAction(title: NSLocalizedString("Trust", comment: "Connect when the SSL certificate is invalid"),
style: .default,
handler: { (_) in
handler: { _ in
let credential = URLCredential(trust: challenge.protectionSpace.serverTrust!)
URLCredentialStorage.shared.setDefaultCredential(credential, for: challenge.protectionSpace)
executeHandlerForChallenge(challenge, disposition: .useCredential, credential: credential)
Expand All @@ -69,25 +69,25 @@ open class HTTPAuthenticationAlertController {
message: message,
preferredStyle: .alert)

controller.addTextField( configurationHandler: { (textField) in
controller.addTextField( configurationHandler: { textField in
textField.placeholder = NSLocalizedString("Username", comment: "Login dialog username placeholder")
})

controller.addTextField(configurationHandler: { (textField) in
controller.addTextField(configurationHandler: { textField in
textField.placeholder = NSLocalizedString("Password", comment: "Login dialog password placeholder")
textField.isSecureTextEntry = true
})

let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: "Cancel button label"),
style: .default,
handler: { (_) in
handler: { _ in
executeHandlerForChallenge(challenge, disposition: .cancelAuthenticationChallenge, credential: nil)
})
controller.addAction(cancelAction)

let loginAction = UIAlertAction(title: NSLocalizedString("Log In", comment: "Log In button label."),
style: .default,
handler: { (_) in
handler: { _ in
guard let username = controller.textFields?.first?.text,
let password = controller.textFields?.last?.text else {
executeHandlerForChallenge(challenge, disposition: .cancelAuthenticationChallenge, credential: nil)
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/WordPressKit/JSONDecoderExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension JSONDecoder.DateDecodingStrategy {
}

static var supportMultipleDateFormats: JSONDecoder.DateDecodingStrategy {
return JSONDecoder.DateDecodingStrategy.custom({ (decoder) -> Date in
return JSONDecoder.DateDecodingStrategy.custom({ decoder -> Date in
let container = try decoder.singleValueContainer()
let dateStr = try container.decode(String.self)

Expand Down
Loading