Fix lint issues.

This commit is contained in:
Brent Simmons 2025-01-22 22:20:08 -08:00
parent bbef99f2d3
commit 10f4351904
64 changed files with 506 additions and 545 deletions

View File

@ -25,7 +25,7 @@ protocol ArticleExtractorDelegate {
class ArticleExtractor {
private var dataTask: URLSessionDataTask? = nil
private var dataTask: URLSessionDataTask?
var state: ArticleExtractorState!
var article: ExtractedArticle?
@ -56,7 +56,7 @@ class ArticleExtractor {
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
guard let self = self else { return }

View File

@ -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"] = ""
}
@ -283,27 +282,22 @@ private extension ArticleRenderer {
}
isFirstAuthor = false
var authorEmailAddress: String? = nil
var authorEmailAddress: String?
if let emailAddress = author.emailAddress, !(emailAddress.contains("noreply@") || emailAddress.contains("no-reply@")) {
authorEmailAddress = emailAddress
}
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 Article {
return url
}
}

View File

@ -32,7 +32,6 @@ public class ArticleThemeDownloader {
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)
@ -68,7 +67,6 @@ public class ArticleThemeDownloader {
}
}
/// Performs a deep search of the unzipped directory to find the theme file.
/// - Parameter searchPath: directory to search
/// - Returns: optional `String`

View File

@ -20,11 +20,11 @@ final class DeleteCommand: UndoableCommand {
var redoActionName: String {
return undoActionName
}
let errorHandler: (Error) -> ()
let errorHandler: (Error) -> Void
private let itemSpecifiers: [SidebarItemSpecifier]
init?(nodesToDelete: [Node], treeController: TreeController? = nil, undoManager: UndoManager, errorHandler: @escaping (Error) -> ()) {
init?(nodesToDelete: [Node], treeController: TreeController? = nil, undoManager: UndoManager, errorHandler: @escaping (Error) -> Void) {
guard DeleteCommand.canDelete(nodesToDelete) else {
return nil
@ -50,7 +50,7 @@ final class DeleteCommand: UndoableCommand {
let group = DispatchGroup()
for itemSpecifier in itemSpecifiers {
group.enter()
itemSpecifier.delete() {
itemSpecifier.delete {
group.leave()
}
}
@ -101,7 +101,7 @@ private struct SidebarItemSpecifier {
private let folder: Folder?
private let feed: Feed?
private let path: ContainerPath
private let errorHandler: (Error) -> ()
private let errorHandler: (Error) -> Void
private var container: Container? {
if let parentFolder = parentFolder {
@ -113,7 +113,7 @@ private struct SidebarItemSpecifier {
return nil
}
init?(node: Node, errorHandler: @escaping (Error) -> ()) {
init?(node: Node, errorHandler: @escaping (Error) -> Void) {
var account: Account?
@ -123,13 +123,11 @@ private struct SidebarItemSpecifier {
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 {
@ -175,8 +173,7 @@ private struct SidebarItemSpecifier {
if let _ = feed {
restoreFeed()
}
else if let _ = folder {
} else if let _ = folder {
restoreFolder()
}
}
@ -246,8 +243,7 @@ private extension Node {
while nomad != nil {
if let folder = nomad!.representedObject as? Folder {
folders += [folder]
}
else {
} else {
break
}
nomad = nomad!.parent
@ -274,11 +270,9 @@ private struct DeleteActionName {
for node in nodes {
if let _ = node.representedObject as? Feed {
numberOfFeeds += 1
}
else if let _ = node.representedObject as? Folder {
} else if let _ = node.representedObject as? Folder {
numberOfFolders += 1
}
else {
} else {
return nil // Delete only Feeds and Folders.
}
}

View File

@ -20,7 +20,7 @@ final class MarkStatusCommand: UndoableCommand {
let undoManager: UndoManager
let flag: Bool
let statusKey: ArticleStatus.Key
var completion: (() -> Void)? = nil
var completion: (() -> Void)?
init?(initialArticles: [Article], statusKey: ArticleStatus.Key, flag: Bool, undoManager: UndoManager, completion: (() -> Void)? = nil) {

View File

@ -57,7 +57,7 @@ private extension SendToMarsEditCommand {
let authorName = article.authors?.first?.name
let sender = SendToBlogEditorApp(targetDescriptor: targetDescriptor, title: article.title, body: body, summary: article.summary, link: article.externalLink, permalink: article.link, subject: nil, creator: authorName, commentsURL: nil, guid: article.uniqueID, sourceName: article.feed?.nameForDisplay, sourceHomeURL: article.feed?.homePageURL, sourceFeedURL: article.feed?.url)
let _ = sender.send()
sender.send()
}
func appToUse() -> UserApp? {

View File

@ -116,4 +116,3 @@ struct ArticleStringFormatter {
return dateFormatter.string(from: date)
}
}

View File

@ -161,24 +161,20 @@ extension Article {
}
isFirstAuthor = false
var authorEmailAddress: String? = nil
var authorEmailAddress: String?
if let emailAddress = author.emailAddress, !(emailAddress.contains("noreply@") || emailAddress.contains("no-reply@")) {
authorEmailAddress = emailAddress
}
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
}
}

View File

@ -60,7 +60,7 @@ final class IconImage {
}
#endif
fileprivate enum ImageLuminanceType {
private enum ImageLuminanceType {
case regular, bright, dark
}
@ -161,7 +161,6 @@ extension CGImage {
}
enum IconSize: Int, CaseIterable {
case small = 1
case medium = 2

View File

@ -40,7 +40,7 @@ extension NSAttributedString {
let baseDescriptor = baseFont.fontDescriptor
let baseSymbolicTraits = baseDescriptor.symbolicTraits
mutable.enumerateAttribute(.font, in: fullRange, options: []) { (font: Any?, range: NSRange, stop: UnsafeMutablePointer<ObjCBool>) in
mutable.enumerateAttribute(.font, in: fullRange, options: []) { (font: Any?, range: NSRange, _: UnsafeMutablePointer<ObjCBool>) in
guard let font = font as? Font else { return }
let currentDescriptor = font.fontDescriptor
@ -186,20 +186,19 @@ extension NSAttributedString {
} else {
if char == "&" {
var entity = "&"
var lastchar: Character? = nil
var lastchar: Character?
while let entitychar = iterator.next() {
if entitychar.isWhitespace {
lastchar = entitychar
break;
break
}
entity.append(entitychar)
if (entitychar == ";") { break }
if entitychar == ";" { break }
}
result.mutableString.append(entity.decodedEntity)
if let lastchar = lastchar { result.mutableString.append(String(lastchar)) }

View File

@ -63,5 +63,3 @@ private extension Node {
}
}
}

View File

@ -13,8 +13,6 @@ import AppKit
import UIKit
#endif
import RSCore
extension RSImage {
static let maxIconSize = 48

View File

@ -169,7 +169,7 @@ final class FaviconDownloader {
self.currentHomePageHasOnlyFaviconICO = faviconURLs.count == 1
if let firstIconURL = faviconURLs.first {
let _ = self.favicon(with: firstIconURL, homePageURL: url)
_ = self.favicon(with: firstIconURL, homePageURL: url)
self.remainingFaviconURLs[url] = faviconURLs.dropFirst()
}
}
@ -196,8 +196,8 @@ final class FaviconDownloader {
guard let _ = singleFaviconDownloader.iconImage else {
if let faviconURLs = remainingFaviconURLs[homePageURL] {
if let nextIconURL = faviconURLs.first {
let _ = favicon(with: nextIconURL, homePageURL: singleFaviconDownloader.homePageURL)
remainingFaviconURLs[homePageURL] = faviconURLs.dropFirst();
_ = favicon(with: nextIconURL, homePageURL: singleFaviconDownloader.homePageURL)
remainingFaviconURLs[homePageURL] = faviconURLs.dropFirst()
} else {
remainingFaviconURLs[homePageURL] = nil

View File

@ -127,8 +127,7 @@ private extension SingleFaviconDownloader {
DispatchQueue.main.async {
self.diskStatus = .onDisk
}
}
catch {}
} catch {}
}
}

View File

@ -44,8 +44,7 @@ final class AuthorAvatarDownloader {
if let imageData = imageDownloader.image(for: avatarURL) {
scaleAndCacheImageData(imageData, avatarURL)
}
else {
} else {
waitingForAvatarURLs.insert(avatarURL)
}

View File

@ -17,7 +17,7 @@ extension HTMLMetadata {
return nil
}
var bestImage: HTMLMetadataAppleTouchIcon? = nil
var bestImage: HTMLMetadataAppleTouchIcon?
for image in icons {
if let size = image.size {
@ -31,7 +31,7 @@ extension HTMLMetadata {
}
if let size = image.size, let bestImageSize = bestImage!.size {
if size.height > bestImageSize.height && size.width > bestImageSize.width {
bestImage = image;
bestImage = image
}
}
}

View File

@ -31,4 +31,3 @@ struct ImageUtilities {
return false
}
}

View File

@ -14,8 +14,7 @@ struct DefaultFeedsImporter {
static func importDefaultFeeds(account: Account) {
let defaultFeedsURL = Bundle.main.url(forResource: "DefaultFeeds", withExtension: "opml")!
AccountManager.shared.defaultAccount.importOPML(defaultFeedsURL) { result in }
AccountManager.shared.defaultAccount.importOPML(defaultFeedsURL) { _ in }
}
}

View File

@ -45,7 +45,7 @@ final class ExtensionContainersFile {
let errorPointer: NSErrorPointer = nil
let fileCoordinator = NSFileCoordinator()
let fileURL = URL(fileURLWithPath: ExtensionContainersFile.filePath)
var extensionContainers: ExtensionContainers? = nil
var extensionContainers: ExtensionContainers?
fileCoordinator.coordinate(readingItemAt: fileURL, options: [], error: errorPointer, byAccessor: { readURL in
if let fileData = try? Data(contentsOf: readURL) {

View File

@ -105,7 +105,7 @@ private extension ExtensionFeedAddRequestFile {
let fileCoordinator = NSFileCoordinator(filePresenter: self)
let fileURL = URL(fileURLWithPath: ExtensionFeedAddRequestFile.filePath)
var requests: [ExtensionFeedAddRequest]? = nil
var requests: [ExtensionFeedAddRequest]?
fileCoordinator.coordinate(writingItemAt: fileURL, options: [.forMerging], error: errorPointer, byAccessor: { url in
do {
@ -135,7 +135,7 @@ private extension ExtensionFeedAddRequestFile {
}
func processRequest(_ request: ExtensionFeedAddRequest) {
var destinationAccountID: String? = nil
var destinationAccountID: String?
switch request.destinationContainerID {
case .account(let accountID):
destinationAccountID = accountID
@ -149,7 +149,7 @@ private extension ExtensionFeedAddRequestFile {
return
}
var destinationContainer: Container? = nil
var destinationContainer: Container?
if account.containerID == request.destinationContainerID {
destinationContainer = account
} else {

View File

@ -36,4 +36,3 @@ struct SearchFeedDelegate: SmartFeedDelegate {
// TODO: after 5.0
}
}

View File

@ -14,7 +14,7 @@ import Account
final class SmartFeed: PseudoFeed {
var account: Account? = nil
var account: Account?
public var defaultReadFilterType: ReadFilterType {
return .none

View File

@ -40,4 +40,3 @@ import RSCore
return plist
}
}

View File

@ -28,4 +28,3 @@ struct TodayFeedDelegate: SmartFeedDelegate {
account.fetchUnreadCountForToday(completion)
}
}

View File

@ -20,7 +20,7 @@ import ArticlesDatabase
final class UnreadFeed: PseudoFeed {
var account: Account? = nil
var account: Account?
public var defaultReadFilterType: ReadFilterType {
return .alwaysRead

View File

@ -23,10 +23,10 @@ extension Array where Element == Article {
func orderedRowIndexes(fromIndex startIndex: Int, wrappingToTop wrapping: Bool) -> [Int] {
if startIndex >= self.count {
// Wrap around to the top if specified
return wrapping ? Array<Int>(0..<self.count) : []
return wrapping ? [Int](0..<self.count) : []
} else {
// Start at the selection and wrap around to the beginning
return Array<Int>(startIndex..<self.count) + (wrapping ? Array<Int>(0..<startIndex) : [])
return [Int](startIndex..<self.count) + (wrapping ? [Int](0..<startIndex) : [])
}
}
func rowOfNextUnreadArticle(_ selectedRow: Int, wrappingToTop wrapping: Bool) -> Int? {
@ -130,4 +130,3 @@ extension Array where Element == Article {
}
}

View File

@ -96,4 +96,3 @@ final class FetchRequestOperation {
}
}
}

View File

@ -13,7 +13,7 @@ import Foundation
final class FetchRequestQueue {
private var pendingRequests = [FetchRequestOperation]()
private var currentRequest: FetchRequestOperation? = nil
private var currentRequest: FetchRequestOperation?
var isAnyCurrentRequest: Bool {
if let currentRequest = currentRequest {

View File

@ -30,4 +30,3 @@ struct LatestArticle: Codable, Identifiable {
let pubDate: String
}

View File

@ -14,7 +14,6 @@ import RSCore
import Articles
import Account
public final class WidgetDataEncoder {
private let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Application")
@ -40,7 +39,7 @@ public final class WidgetDataEncoder {
os_log(.debug, log: log, "Starting encoding widget data.")
DispatchQueue.main.async {
self.encodeWidgetData() { latestData in
self.encodeWidgetData { latestData in
guard let latestData = latestData else {
self.isRunning = false
return
@ -67,7 +66,7 @@ public final class WidgetDataEncoder {
private func encodeWidgetData(completion: @escaping (WidgetData?) -> Void) {
let dispatchGroup = DispatchGroup()
var groupError: Error? = nil
var groupError: Error?
var unread = [LatestArticle]()
@ -178,5 +177,3 @@ public final class WidgetDataEncoder {
}
}