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

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

- vertical_whitespace

- weak_delegate
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/AsyncImageKit/Views/CachedAsyncImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ fileprivate let videoURL = URL(
}

#Preview("Image that never loads") {
CachedAsyncImage(url: nil) { image in
CachedAsyncImage(url: nil) { _ in
Text("This shouldn't be visible")
} placeholder: {
ProgressView("Forever loading...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct RealtimeTopListCard: View {
}
.padding(.vertical, Constants.step3)
.redacted(reason: viewModel.isFirstLoad ? .placeholder : [])
.onChange(of: selectedItem) { oldValue, newValue in
.onChange(of: selectedItem) { _, newValue in
viewModel.loadData(for: newValue)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/JetpackStats/Screens/AuthorStatsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct AuthorStatsView: View {
}
.background(Constants.Colors.background)
.animation(.spring, value: viewModel.data.map(ObjectIdentifier.init))
.onChange(of: dateRange) { oldValue, newValue in
.onChange(of: dateRange) { _, newValue in
viewModel.dateRange = newValue
}
.onAppear {
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/JetpackStats/Screens/StatsMainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public struct StatsMainView: View {
.onAppear {
context.tracker?.send(.statsMainScreenShown)
}
.onChange(of: selectedTab) { oldValue, newValue in
.onChange(of: selectedTab) { _, newValue in
trackTabChange(from: selectedTab, to: newValue)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct UTMMetricStatsView: View {
}
.background(Constants.Colors.background)
.animation(.spring, value: viewModel.data.map(ObjectIdentifier.init))
.onChange(of: dateRange) { oldValue, newValue in
.onChange(of: dateRange) { _, newValue in
viewModel.dateRange = newValue
}
.onAppear {
Expand Down
14 changes: 7 additions & 7 deletions Modules/Sources/JetpackStats/Services/Data/TopListData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ extension TopListData {
("Medium", "medium.com", 600)
]

return referrers.enumerated().map { index, data in
return referrers.enumerated().map { _, data in
let baseValue = data.2
let metrics = createMetrics(baseValue: baseValue, metric: metric)
return TopListItem.Referrer(
Expand Down Expand Up @@ -195,7 +195,7 @@ extension TopListData {
("Netherlands", "NL", "🇳🇱", 900)
]

return locations.enumerated().map { index, data in
return locations.enumerated().map { _, data in
let baseValue = data.3
let metrics = createMetrics(baseValue: baseValue, metric: metric)
return TopListItem.Location(
Expand Down Expand Up @@ -266,7 +266,7 @@ extension TopListData {
("Sarah Davis", "Contributor", 8, 400)
]

return authors.enumerated().map { index, data in
return authors.enumerated().map { _, data in
let baseValue = data.3
let metrics = createMetrics(baseValue: baseValue, metric: metric)
return TopListItem.Author(
Expand All @@ -291,7 +291,7 @@ extension TopListData {
("SwiftUI Lab", "https://swiftui-lab.com", 300)
]

return links.enumerated().map { index, data in
return links.enumerated().map { _, data in
let baseValue = data.2
let metrics = createMetrics(baseValue: baseValue, metric: metric)
return TopListItem.ExternalLink(
Expand All @@ -315,7 +315,7 @@ extension TopListData {
("dataset.csv", "/downloads/data/dataset.csv", 400)
]

return files.enumerated().map { index, data in
return files.enumerated().map { _, data in
let baseValue = data.2
let metrics = createMetrics(baseValue: baseValue, metric: metric)
return TopListItem.FileDownload(
Expand All @@ -338,7 +338,7 @@ extension TopListData {
("swift best practices", 500)
]

return terms.enumerated().map { index, data in
return terms.enumerated().map { _, data in
let baseValue = data.1
let metrics = createMetrics(baseValue: baseValue, metric: metric)
return TopListItem.SearchTerm(
Expand All @@ -360,7 +360,7 @@ extension TopListData {
("Testing Strategies", "108", "https://example.com/videos/testing.mp4", 700)
]

return videos.enumerated().map { index, data in
return videos.enumerated().map { _, data in
let baseValue = data.3
let metrics = createMetrics(baseValue: baseValue, metric: metric)
return TopListItem.Video(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct TopListCardCustomizationView: View {
}
}
}
.onChange(of: selectedItem) { oldValue, newValue in
.onChange(of: selectedItem) { _, newValue in
if let newValue {
updateConfiguration(with: newValue)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct WeeklyTrendsView: View {
private var heatmap: some View {
VStack(spacing: cellSpacing) {
// Show last 4 weeks, 7 days per week
ForEach(Array(viewModel.weeks.prefix(4).enumerated()), id: \.offset) { weekIndex, week in
ForEach(Array(viewModel.weeks.prefix(4).enumerated()), id: \.offset) { _, week in
HStack(spacing: 8) {
// Week label
Text(viewModel.weekLabel(for: week))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct TopListItemsView: View {

var body: some View {
VStack(spacing: Constants.step1 / 2) {
ForEach(Array(data.items.prefix(itemLimit).enumerated()), id: \.element.id) { index, item in
ForEach(Array(data.items.prefix(itemLimit).enumerated()), id: \.element.id) { _, item in
makeView(for: item)
.transition(.move(edge: .leading)
.combined(with: .scale(scale: 0.75))
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 { (storeDescription, 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 @@ -70,7 +70,7 @@ struct ActivityLogDetailView: View {
}
.task(self.loadLogContent)
.refreshable(action: self.loadLogContent)
.onChange(of: state) { oldValue, newValue in
.onChange(of: state) { _, _ in
if case .loaded(_, let isSharing) = state {
self.sharingIsDisabled = false
self.isDisplayingShareSheet = isSharing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct CompositionView: View {
}
.padding(.horizontal, 16)
.padding(.vertical, 8)
.onChange(of: self.text, initial: true, { oldValue, newValue in
.onChange(of: self.text, initial: true, { _, newValue in
withAnimation {
textIsEmpty = newValue
.trimmingCharacters(in: .whitespacesAndNewlines)
Expand Down Expand Up @@ -88,7 +88,7 @@ struct CompositionView: View {
NavigationStack {
VStack {
Spacer()
CompositionView(isDisabled: false) { message in
CompositionView(isDisabled: false) { _ in
// Do nothing
}
}
Expand All @@ -103,7 +103,7 @@ struct CompositionView: View {
}
VStack {
Spacer()
CompositionView(isDisabled: false) { message in
CompositionView(isDisabled: false) { _ in
// You'd do something with the message if this weren't a preview
}
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/Sources/Support/UI/OverlayProgressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct OverlayProgressView: View {
.accessibilityAddTraits(.isStaticText)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.padding(.top, 24)
.onChange(of: context.date, { oldValue, newValue in
.onChange(of: context.date, { _, _ in
if case .awaitingHiding(let until) = state {
if until.hasPast {
withAnimation {
Expand All @@ -68,7 +68,7 @@ struct OverlayProgressView: View {
}
}
})
.onChange(of: self.shouldBeVisible) { oldValue, newValue in
.onChange(of: self.shouldBeVisible) { _, newValue in
withAnimation {
if newValue {
self.state = .mustBeVisible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct SingleImageView: View {
@GestureState private var currentZoom = 1.0

var magnification: some Gesture {
MagnifyGesture().updating($currentZoom, body: { newValue, state, transaction in
MagnifyGesture().updating($currentZoom, body: { newValue, state, _ in
state = newValue.magnification
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ struct EmailRowView: View {
header

HStack {
TimelineView(.periodic(from: .now, by: 1.0)) { context in
TimelineView(.periodic(from: .now, by: 1.0)) { _ in
Text(formatTimestamp(conversation.lastMessageSentAt))
.font(.caption)
.foregroundColor(.secondary)
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/UITestsFoundation/Globals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ extension ScreenObject {
}

public func openMagicLink() {
XCTContext.runActivity(named: "Open magic link in Safari") { activity in
XCTContext.runActivity(named: "Open magic link in Safari") { _ in
let safari = Apps.safari
safari.launch()

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") { (activity) in
XCTContext.runActivity(named: "Close the More menu if needed") { (activity) 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") { (activity) 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") { (activity) in
XCTContext.runActivity(named: "Close the More menu if needed") { (activity) 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") { (activity) 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/WordPressKit/DashboardServiceRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ open class DashboardServiceRemote: ServiceRemoteWordPressComREST {
"cards": cards.joined(separator: ",") as NSString
]
let featureFlagParams: [String: AnyObject]? = try SessionDetails(deviceId: deviceId).dictionaryRepresentation()
return cardsParams.merging(featureFlagParams ?? [:]) { first, second in
return cardsParams.merging(featureFlagParams ?? [:]) { first, _ in
return first
}
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/WordPressKit/PostServiceRemoteREST.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extension PostServiceRemoteREST {

wordPressComRESTAPI.get(requestUrl,
parameters: parameters,
success: { (responseObject, httpResponse) in
success: { (responseObject, _) in
if let success {
let responseDict = responseObject as? [String: Any] ?? [:]
let jsonUsers = responseDict["likes"] as? [[String: Any]] ?? []
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/WordPressShared/Utility/Debouncer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public final class Debouncer {
}

private func scheduleCallback() {
timer = Timer.scheduledTimer(withTimeInterval: delay, repeats: false) { [callback] timer in
timer = Timer.scheduledTimer(withTimeInterval: delay, repeats: false) { [callback] _ in
callback?()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ extension String {
let range = NSMakeRange(0, count)
var offset = 0

detector.enumerateMatches(in: self, options: [], range: range) { (result, flags, stop) in
detector.enumerateMatches(in: self, options: [], range: range) { (result, _, _) in
guard let range = result?.range else {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public final class AdaptiveTabBarController<Item: AdaptiveTabBarItem> {
}

private func setupTraitObserver(for viewController: UIViewController) {
traitObserver = viewController.registerForTraitChanges([UITraitHorizontalSizeClass.self]) { [weak self] (viewController: UIViewController, previousTraitCollection: UITraitCollection) in
traitObserver = viewController.registerForTraitChanges([UITraitHorizontalSizeClass.self]) { [weak self] (_: UIViewController, _: UITraitCollection) in
self?.refresh()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class BloggingRemindersSchedulerTests: XCTestCase {
return
}

let notificationCenter = NotificationSchedulerMock { (request, completionHandler) in
let notificationCenter = NotificationSchedulerMock { (_, completionHandler) in
completionHandler?(nil)
} removeNotificationMock: { identifier in
} removeNotificationMock: { _ in
}

let scheduler = BloggingRemindersScheduler(
Expand Down Expand Up @@ -109,10 +109,10 @@ class BloggingRemindersSchedulerTests: XCTestCase {
return
}

let notificationCenter = NotificationSchedulerMock { (request, completionHandler) in
let notificationCenter = NotificationSchedulerMock { (_, completionHandler) in
scheduleExpectation.fulfill()
completionHandler?(nil)
} removeNotificationMock: { identifier in
} removeNotificationMock: { _ in
cancelExpectation.fulfill()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class BlogDashboardServiceTests: CoreDataTestCase {

let blog = newTestBlog(id: wpComID, context: mainContext)

service.fetch(blog: blog) { snapshot in
service.fetch(blog: blog) { _ in
XCTAssertEqual(self.persistenceMock.didCallPersistWithCards,
self.dictionary(from: "dashboard-200-with-drafts-and-scheduled.json"))
XCTAssertEqual(self.persistenceMock.didCallPersistWithWpComID, self.wpComID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class MarkAsSpamActionTests: CoreDataTestCase {

var executionCompleted = false

let context = ActionContext(block: try utility.mockCommentContent(), content: "content") { (request, success) in
let context = ActionContext(block: try utility.mockCommentContent(), content: "content") { (_, _) in
executionCompleted = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class PushAuthenticationServiceTests: CoreDataTestCase {

func testAuthorizeLoginDoesntCallServiceRemoteIfItsNull() {
pushAuthenticationService.authenticationServiceRemote = nil
pushAuthenticationService.authorizeLogin(token, completion: { (completed: Bool) -> () in
pushAuthenticationService.authorizeLogin(token, completion: { (_: Bool) -> () in
})
XCTAssertFalse(mockPushAuthenticationServiceRemote!.authorizeLoginCalled, "Authorize login should not have been called")
}

func testAuthorizeLoginCallsServiceRemoteAuthorizeLoginWhenItsNotNull() {
pushAuthenticationService.authorizeLogin(token, completion: { (completed: Bool) -> () in
pushAuthenticationService.authorizeLogin(token, completion: { (_: Bool) -> () in
})
XCTAssertTrue(mockPushAuthenticationServiceRemote.authorizeLoginCalled, "Authorize login should have been called")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final class TrashCommentActionTests: CoreDataTestCase {
action?.on = false

var executionCompleted = false
let context = ActionContext(block: try utils.mockCommentContent(), content: "content") { (request, success) in
let context = ActionContext(block: try utils.mockCommentContent(), content: "content") { (_, _) in
executionCompleted = true
}

Expand Down
Loading