Skip to content
Draft
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 @@ -60,6 +60,9 @@ only_rules:
# Example: CGPoint.zero instead of CGPoint(x: 0, y: 0)
- prefer_zero_over_explicit_init

# `nil` coalescing on a non-optional is redundant.
- redundant_nil_coalescing

- shorthand_optional_binding

# Prefer `someBool.toggle()` over `someBool = !someBool`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ private final class SaliencyCache: @unchecked Sendable {
}

func cachedRect(for url: URL) -> CGRect? {
// swiftlint:disable:next redundant_nil_coalescing
lock.withLock { store[url.absoluteString] ?? nil }
}

Expand Down
4 changes: 2 additions & 2 deletions Modules/Sources/WordPressKit/DomainsServiceRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public struct DomainSuggestion: Codable {
}

self.domainName = domain
self.productID = json["product_id"] as? Int ?? nil
self.supportsPrivacy = json["supports_privacy"] as? Bool ?? nil
self.productID = json["product_id"] as? Int
self.supportsPrivacy = json["supports_privacy"] as? Bool
self.costString = json["cost"] as? String ?? ""
self.cost = json["raw_price"] as? Double
self.saleCost = json["sale_cost"] as? Double
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/WordPressKit/JetpackScanThreat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public struct JetpackScanThreat: Decodable {
description = try container.decode(String.self, forKey: .description)
firstDetected = try container.decode(Date.self, forKey: .firstDetected)
fixedOn = try container.decodeIfPresent(Date.self, forKey: .fixedOn)
fixable = try? container.decodeIfPresent(JetpackScanThreatFixer.self, forKey: .fixable) ?? nil
fixable = try? container.decodeIfPresent(JetpackScanThreatFixer.self, forKey: .fixable)
`extension` = try container.decodeIfPresent(JetpackThreatExtension.self, forKey: .extension)
diff = try container.decodeIfPresent(String.self, forKey: .diff)
rows = try container.decodeIfPresent([String: Any].self, forKey: .rows)
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/WordPressKitModels/RemoteUser+Likes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import Foundation
public init(dictionary: [String: Any]) {
blogUrl = dictionary["url"] as? String ?? ""
blogName = dictionary["name"] as? String ?? ""
blogID = dictionary["id"] as? NSNumber ?? nil
blogID = dictionary["id"] as? NSNumber

iconUrl = {
if let iconInfo = dictionary["icon"] as? [String: Any],
Expand Down
14 changes: 7 additions & 7 deletions Sources/WordPressData/Swift/SiteTaxonomy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public struct SiteTaxonomy: Codable {
self.name = details.name
self.restBase = details.restBase
self.labels = LocalizedLabels(
name: details.labels[.name] ?? nil,
newItemName: details.labels[.newItemName] ?? nil,
addNewItem: details.labels[.addNewItem] ?? nil,
nameFieldDescription: details.labels[.nameFieldDescription] ?? nil,
descFieldDescription: details.labels[.descFieldDescription] ?? nil,
noTerms: details.labels[.noTerms] ?? nil,
searchItems: details.labels[.searchItems] ?? nil
name: details.labels[.name],
newItemName: details.labels[.newItemName],
addNewItem: details.labels[.addNewItem],
nameFieldDescription: details.labels[.nameFieldDescription],
descFieldDescription: details.labels[.descFieldDescription],
noTerms: details.labels[.noTerms],
searchItems: details.labels[.searchItems]
)
self.supportedPostTypes = details.types
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ extension FullyQuotedDomainSuggestion {
}

let domainName = domain
let productID = json["product_id"] as? Int ?? nil
let supportsPrivacy = json["supports_privacy"] as? Bool ?? nil
let productID = json["product_id"] as? Int
let supportsPrivacy = json["supports_privacy"] as? Bool
let costString = json["cost"] as? String ?? ""
let saleCostString: String? = nil

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension MediaLibraryTestSupport {
}

private func handleREST(request: URLRequest, failAtPage pageToFail: Int) -> HTTPStubsResponse {
let cursor = request.url?.query("page_handle") ?? nil
let cursor = request.url?.query("page_handle")
let number = request.url?.query("number").flatMap(Int.init(_:)) ?? 100

let cursorIndex = media.firstIndex { $0.cusor == cursor } ?? 0
Expand Down
2 changes: 1 addition & 1 deletion WordPress/Classes/Stores/StatsPeriodStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ extension StatsPeriodStore {
guard let postId else {
return nil
}
return state.postStats[postId] ?? nil
return state.postStats[postId]
}

func getMostRecentDate(forPost postId: Int?) -> Date? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class JetpackScanCoordinator {
let returnThreats: [JetpackScanThreat]?

if scan?.state == .fixingThreats {
returnThreats = scan?.threatFixStatus?.compactMap { $0.threat } ?? nil
returnThreats = scan?.threatFixStatus?.compactMap { $0.threat }
} else {
returnThreats = scan?.state == .idle ? scan?.threats : nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class ReaderDetailHeaderViewModel: ObservableObject {

self.isFollowingSite = post.isFollowing

self.authorAvatarURL = post.avatarURLForDisplay() ?? nil
self.authorAvatarURL = post.avatarURLForDisplay()

if let authorName = post.authorForDisplay(), !authorName.isEmpty {
self.authorName = authorName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class OffsetTableViewHandler: WPTableViewHandler {

let oldIndexPath = indexPath.map {
adjustedToTable(indexPath: $0)
} ?? nil
}

let newPath = newIndexPath.map {
adjustedToTable(indexPath: $0)
} ?? nil
}

super.controller(controller, didChange: anObject, at: oldIndexPath, for: type, newIndexPath: newPath)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ private extension SupportTableViewController {
// MARK: - Helpers

func controllerToShowFrom() -> UIViewController? {
return showHelpFromViewController ?? navigationController ?? nil
return showHelpFromViewController ?? navigationController
}

// MARK: - Localized Text
Expand Down