mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-29 08:42:51 +00:00
Fix various SwiftLint warnings.
This commit is contained in:
1 parent
61e109a0d5
commit
0b429ae259
15 files changed
+44
-85
No files matched your search
@@ -55,7 +55,7 @@ public enum ArticleExtractorState: Sendable {
|
||||
|
||||
state = .processing
|
||||
|
||||
dataTask = URLSession.shared.dataTask(with: url) { [weak self] data, response, error in
|
||||
dataTask = URLSession.shared.dataTask(with: url) { [weak self] data, _, error in
|
||||
Task { @MainActor in
|
||||
guard let self else {
|
||||
return
|
||||
|
||||
@@ -230,8 +230,7 @@ private extension ArticleRenderer {
|
||||
components.path = article.articleID
|
||||
if let imageIconURLString = components.string {
|
||||
d["avatar_src"] = imageIconURLString
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
d["avatar_src"] = ""
|
||||
}
|
||||
|
||||
@@ -290,20 +289,15 @@ private extension ArticleRenderer {
|
||||
|
||||
if let emailAddress = authorEmailAddress, emailAddress.contains(" ") {
|
||||
byline += emailAddress // probably name plus email address
|
||||
}
|
||||
else if let name = author.name, let url = author.url {
|
||||
} else if let name = author.name, let url = author.url {
|
||||
byline += name.htmlByAddingLink(url)
|
||||
}
|
||||
else if let name = author.name, let emailAddress = authorEmailAddress {
|
||||
} else if let name = author.name, let emailAddress = authorEmailAddress {
|
||||
byline += "\(name) <\(emailAddress)>"
|
||||
}
|
||||
else if let name = author.name {
|
||||
} else if let name = author.name {
|
||||
byline += name
|
||||
}
|
||||
else if let emailAddress = authorEmailAddress {
|
||||
} else if let emailAddress = authorEmailAddress {
|
||||
byline += "<\(emailAddress)>" // TODO: mailto link
|
||||
}
|
||||
else if let url = author.url {
|
||||
} else if let url = author.url {
|
||||
byline += String.htmlWithLink(url)
|
||||
}
|
||||
}
|
||||
@@ -355,4 +349,3 @@ private extension ArticleRenderer {
|
||||
return url
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,9 @@ public final class ArticleThemeDownloader: Sendable {
|
||||
createDownloadDirectoryIfRequired()
|
||||
let movedFileLocation = try moveTheme(from: location)
|
||||
let unzippedFileLocation = try unzipFile(at: movedFileLocation)
|
||||
NotificationCenter.default.post(name: .didEndDownloadingTheme, object: nil, userInfo: ["url" : unzippedFileLocation])
|
||||
NotificationCenter.default.post(name: .didEndDownloadingTheme, object: nil, userInfo: ["url": unzippedFileLocation])
|
||||
}
|
||||
|
||||
|
||||
/// Creates `Application Support/NetNewsWire/Downloads` if needed.
|
||||
private func createDownloadDirectoryIfRequired() {
|
||||
try? FileManager.default.createDirectory(at: downloadDirectory(), withIntermediateDirectories: true, attributes: nil)
|
||||
@@ -75,7 +74,7 @@ public final class ArticleThemeDownloader: Sendable {
|
||||
if let directoryContents = FileManager.default.enumerator(atPath: searchPath) {
|
||||
while let file = directoryContents.nextObject() as? String {
|
||||
if file.hasPrefix("__MACOSX/") {
|
||||
//logger.debug("Ignoring theme file in __MACOSX folder.")
|
||||
// logger.debug("Ignoring theme file in __MACOSX folder.")
|
||||
continue
|
||||
}
|
||||
if file.hasSuffix(".nnwtheme") {
|
||||
|
||||
@@ -13,12 +13,11 @@ import Account
|
||||
import Articles
|
||||
|
||||
final class DeleteCommand: UndoableCommand {
|
||||
|
||||
let treeController: TreeController?
|
||||
let undoManager: UndoManager
|
||||
let undoActionName: String
|
||||
var redoActionName: String {
|
||||
return undoActionName
|
||||
undoActionName
|
||||
}
|
||||
let errorHandler: (Error) -> ()
|
||||
|
||||
@@ -38,7 +37,7 @@ final class DeleteCommand: UndoableCommand {
|
||||
self.undoManager = undoManager
|
||||
self.errorHandler = errorHandler
|
||||
|
||||
let itemSpecifiers = nodesToDelete.compactMap{ SidebarItemSpecifier(node: $0, errorHandler: errorHandler) }
|
||||
let itemSpecifiers = nodesToDelete.compactMap { SidebarItemSpecifier(node: $0, errorHandler: errorHandler) }
|
||||
guard !itemSpecifiers.isEmpty else {
|
||||
return nil
|
||||
}
|
||||
@@ -50,7 +49,7 @@ final class DeleteCommand: UndoableCommand {
|
||||
let group = DispatchGroup()
|
||||
itemSpecifiers.forEach {
|
||||
group.enter()
|
||||
$0.delete() {
|
||||
$0.delete {
|
||||
group.leave()
|
||||
}
|
||||
}
|
||||
@@ -113,7 +112,7 @@ final class DeleteCommand: UndoableCommand {
|
||||
return nil
|
||||
}
|
||||
|
||||
@MainActor init?(node: Node, errorHandler: @escaping (Error) -> ()) {
|
||||
@MainActor init?(node: Node, errorHandler: @escaping (Error) -> Void) {
|
||||
|
||||
var account: Account?
|
||||
|
||||
@@ -123,13 +122,11 @@ final class DeleteCommand: UndoableCommand {
|
||||
self.feed = feed
|
||||
self.folder = nil
|
||||
account = feed.account
|
||||
}
|
||||
else if let folder = node.representedObject as? Folder {
|
||||
} else if let folder = node.representedObject as? Folder {
|
||||
self.feed = nil
|
||||
self.folder = folder
|
||||
account = folder.account
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
if account == nil {
|
||||
@@ -144,9 +141,7 @@ final class DeleteCommand: UndoableCommand {
|
||||
}
|
||||
|
||||
func delete(completion: @escaping () -> Void) {
|
||||
|
||||
if let feed = feed {
|
||||
|
||||
if let feed {
|
||||
guard let container = path.resolveContainer() else {
|
||||
completion()
|
||||
return
|
||||
@@ -159,20 +154,17 @@ final class DeleteCommand: UndoableCommand {
|
||||
self.checkResult(result)
|
||||
}
|
||||
|
||||
} else if let folder = folder {
|
||||
|
||||
} else if let folder {
|
||||
BatchUpdate.shared.start()
|
||||
account?.removeFolder(folder) { result in
|
||||
BatchUpdate.shared.end()
|
||||
completion()
|
||||
self.checkResult(result)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func restore() {
|
||||
|
||||
if let _ = feed {
|
||||
restoreFeed()
|
||||
}
|
||||
@@ -192,7 +184,6 @@ final class DeleteCommand: UndoableCommand {
|
||||
BatchUpdate.shared.end()
|
||||
self.checkResult(result)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private func restoreFolder() {
|
||||
@@ -206,7 +197,6 @@ final class DeleteCommand: UndoableCommand {
|
||||
BatchUpdate.shared.end()
|
||||
self.checkResult(result)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private func checkResult(_ result: Result<Void, Error>) {
|
||||
@@ -217,9 +207,7 @@ final class DeleteCommand: UndoableCommand {
|
||||
case .failure(let error):
|
||||
errorHandler(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@MainActor private extension Node {
|
||||
@@ -255,7 +243,6 @@ final class DeleteCommand: UndoableCommand {
|
||||
|
||||
return folders.reversed()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private struct DeleteActionName {
|
||||
|
||||
@@ -84,13 +84,17 @@ import Articles
|
||||
}
|
||||
|
||||
static func filteredArticles(_ articles: [Article], _ statusKey: ArticleStatus.Key, _ flag: Bool) -> [Article] {
|
||||
|
||||
return articles.filter{ article in
|
||||
guard article.status.boolStatus(forKey: statusKey) != flag else { return false }
|
||||
guard statusKey == .read else { return true }
|
||||
guard !article.status.read || article.isAvailableToMarkUnread else { return false }
|
||||
articles.filter { article in
|
||||
guard article.status.boolStatus(forKey: statusKey) != flag else {
|
||||
return false
|
||||
}
|
||||
guard statusKey == .read else {
|
||||
return true
|
||||
}
|
||||
guard !article.status.read || article.isAvailableToMarkUnread else {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ import Account
|
||||
|
||||
private func accountAndArticlesDictionary(_ articles: Set<Article>) -> [String: Set<Article>] {
|
||||
let d = Dictionary(grouping: articles, by: { $0.accountID })
|
||||
return d.mapValues{ Set($0) }
|
||||
return d.mapValues { Set($0) }
|
||||
}
|
||||
|
||||
@MainActor extension Article {
|
||||
@@ -161,17 +161,13 @@ private func accountAndArticlesDictionary(_ articles: Set<Article>) -> [String:
|
||||
|
||||
if let emailAddress = authorEmailAddress, emailAddress.contains(" ") {
|
||||
byline += emailAddress // probably name plus email address
|
||||
}
|
||||
else if let name = author.name, let emailAddress = authorEmailAddress {
|
||||
} else if let name = author.name, let emailAddress = authorEmailAddress {
|
||||
byline += "\(name) <\(emailAddress)>"
|
||||
}
|
||||
else if let name = author.name {
|
||||
} else if let name = author.name {
|
||||
byline += name
|
||||
}
|
||||
else if let emailAddress = authorEmailAddress {
|
||||
} else if let emailAddress = authorEmailAddress {
|
||||
byline += "<\(emailAddress)>"
|
||||
}
|
||||
else if let url = author.url {
|
||||
} else if let url = author.url {
|
||||
byline += url
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,10 +175,11 @@ extension NSAttributedString {
|
||||
|
||||
entity.append(entitychar)
|
||||
|
||||
if (entitychar == ";") { break }
|
||||
if entitychar == ";" {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
result.mutableString.append(entity.decodedEntity)
|
||||
|
||||
if let lastchar = lastchar { result.mutableString.append(String(lastchar)) }
|
||||
@@ -252,7 +253,6 @@ extension NSAttributedString {
|
||||
|
||||
self.init(attributedString: result)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// This is a very, very basic implementation that only covers our needs.
|
||||
|
||||
@@ -13,10 +13,7 @@ import AppKit
|
||||
import UIKit
|
||||
#endif
|
||||
|
||||
import RSCore
|
||||
|
||||
extension RSImage {
|
||||
|
||||
static let maxIconSize = 48
|
||||
|
||||
static func scaledForIcon(_ data: Data, imageResultBlock: @escaping ImageResultBlock) {
|
||||
@@ -34,7 +31,7 @@ extension RSImage {
|
||||
#else
|
||||
let size = NSSize(width: cgImage.width, height: cgImage.height)
|
||||
return RSImage(cgImage: cgImage, size: size)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static var appIconImage: RSImage? {
|
||||
|
||||
@@ -44,8 +44,7 @@ extension Notification.Name {
|
||||
|
||||
if let imageData = imageDownloader.image(for: avatarURL) {
|
||||
scaleAndCacheImageData(imageData, avatarURL)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
waitingForAvatarURLs.insert(avatarURL)
|
||||
}
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@ extension Notification.Name {
|
||||
return cachedImage
|
||||
}
|
||||
|
||||
if let homePageURLString = feed.homePageURL, let homePageURL = URL(string: homePageURLString), (homePageURL.host == "nnw.ranchero.com" || homePageURL.host == "netnewswire.blog") {
|
||||
if let homePageURLString = feed.homePageURL, let homePageURL = URL(string: homePageURLString), homePageURL.host == "nnw.ranchero.com" || homePageURL.host == "netnewswire.blog" {
|
||||
return IconImage.nnwFeedIcon
|
||||
}
|
||||
if (Self.shouldSkipDownloadingFeedIcon(feed: feed)) {
|
||||
if Self.shouldSkipDownloadingFeedIcon(feed: feed) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
struct UnreadWidgetView: View {
|
||||
|
||||
@Environment(\.widgetFamily) var family: WidgetFamily
|
||||
@Environment(\.sizeCategory) var sizeCategory: ContentSizeCategory
|
||||
|
||||
@@ -21,7 +20,7 @@ struct UnreadWidgetView: View {
|
||||
inboxZero
|
||||
.widgetURL(WidgetDeepLink.unread.url)
|
||||
} else {
|
||||
GeometryReader { metrics in
|
||||
GeometryReader { _ in
|
||||
unreadImage
|
||||
.frame(width: WidgetLayout.titleImageSize, alignment: .leading)
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
@@ -102,6 +101,4 @@ struct UnreadWidgetView: View {
|
||||
.multilineTextAlignment(.center)
|
||||
.padding()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,10 +66,6 @@ final class AddAccountViewController: UITableViewController, AddAccountDismissDe
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
}
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
return AddAccountSections.allCases.count
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ import UIKit
|
||||
let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel")
|
||||
alertController.addAction(UIAlertAction(title: cancelTitle, style: .cancel))
|
||||
|
||||
let overwriteAction = UIAlertAction(title: NSLocalizedString("Overwrite", comment: "Overwrite"), style: .default) { action in
|
||||
let overwriteAction = UIAlertAction(title: NSLocalizedString("Overwrite", comment: "Overwrite"), style: .default) { _ in
|
||||
importTheme()
|
||||
}
|
||||
alertController.addAction(overwriteAction)
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
import UIKit
|
||||
import Articles
|
||||
|
||||
class ModernTimelineCustomizerTableViewController: UITableViewController {
|
||||
|
||||
|
||||
final class ModernTimelineCustomizerTableViewController: UITableViewController {
|
||||
private var previewArticle: Article {
|
||||
var components = DateComponents()
|
||||
components.year = 1925
|
||||
@@ -39,7 +37,6 @@ class ModernTimelineCustomizerTableViewController: UITableViewController {
|
||||
status: ArticleStatus(articleID: "_testArticleID", read: false, starred: false, dateArrived: .now))
|
||||
}
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
title = NSLocalizedString("Timeline Customizer", comment: "Timeline Customizer")
|
||||
@@ -51,7 +48,6 @@ class ModernTimelineCustomizerTableViewController: UITableViewController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
tableView.reloadSections(IndexSet(integer: 2), with: .fade)
|
||||
}
|
||||
@@ -74,7 +70,6 @@ class ModernTimelineCustomizerTableViewController: UITableViewController {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
if indexPath.section == 0 {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "IconSizeCell") as! ModernTimelineSliderCell
|
||||
@@ -134,6 +129,4 @@ class ModernTimelineCustomizerTableViewController: UITableViewController {
|
||||
func userDefaultsDidChange() {
|
||||
tableView.reloadSections(IndexSet(integersIn: 2...3), with: .none)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,7 +68,6 @@ final class SettingsViewController: UITableViewController {
|
||||
refreshClearsReadArticlesSwitch.isOn = false
|
||||
}
|
||||
|
||||
|
||||
articleThemeDetailLabel.text = ArticleThemesManager.shared.currentTheme.name
|
||||
|
||||
if AppDefaults.shared.confirmMarkAllAsRead {
|
||||
@@ -93,7 +92,6 @@ final class SettingsViewController: UITableViewController {
|
||||
|
||||
openLinksInNetNewsWire.isOn = !AppDefaults.shared.useSystemBrowser
|
||||
|
||||
|
||||
let buildLabel = NonIntrinsicLabel(frame: CGRect(x: 32.0, y: 0.0, width: 0.0, height: 0.0))
|
||||
buildLabel.font = UIFont.systemFont(ofSize: 11.0)
|
||||
buildLabel.textColor = UIColor.gray
|
||||
@@ -401,7 +399,7 @@ private extension SettingsViewController {
|
||||
}
|
||||
|
||||
for account in AccountManager.shared.sortedActiveAccounts {
|
||||
let action = UIAlertAction(title: account.nameForDisplay, style: .default) { [weak self] action in
|
||||
let action = UIAlertAction(title: account.nameForDisplay, style: .default) { [weak self] _ in
|
||||
self?.opmlAccount = account
|
||||
self?.importOPMLDocumentPicker()
|
||||
}
|
||||
@@ -457,7 +455,7 @@ private extension SettingsViewController {
|
||||
}
|
||||
|
||||
for account in AccountManager.shared.sortedAccounts {
|
||||
let action = UIAlertAction(title: account.nameForDisplay, style: .default) { [weak self] action in
|
||||
let action = UIAlertAction(title: account.nameForDisplay, style: .default) { [weak self] _ in
|
||||
self?.opmlAccount = account
|
||||
self?.exportOPMLDocumentPicker()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user