From 03e9bbff34ffe0f82da059d9dfedc572cd1ff723 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 22 Jan 2025 22:07:11 -0800 Subject: [PATCH] Fix lint issues. --- Modules/Articles/Package.swift | 6 +++--- Modules/Articles/Sources/Articles/Article.swift | 13 ++++++------- .../Articles/Sources/Articles/ArticleStatus.swift | 4 ++-- Modules/Articles/Sources/Articles/Author.swift | 11 ++++------- Modules/Articles/Sources/Articles/DatabaseID.swift | 4 ++-- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Modules/Articles/Package.swift b/Modules/Articles/Package.swift index 17a37b46e..36a0c574b 100644 --- a/Modules/Articles/Package.swift +++ b/Modules/Articles/Package.swift @@ -9,10 +9,10 @@ let package = Package( .library( name: "Articles", type: .dynamic, - targets: ["Articles"]), + targets: ["Articles"]) ], dependencies: [ - .package(path: "../RSCore"), + .package(path: "../RSCore") ], targets: [ .target( @@ -21,6 +21,6 @@ let package = Package( "RSCore" ], swiftSettings: [.unsafeFlags(["-warnings-as-errors"])] - ), + ) ] ) diff --git a/Modules/Articles/Sources/Articles/Article.swift b/Modules/Articles/Sources/Articles/Article.swift index 6876ce115..c7b71e4b0 100644 --- a/Modules/Articles/Sources/Articles/Article.swift +++ b/Modules/Articles/Sources/Articles/Article.swift @@ -43,11 +43,10 @@ public final class Article: Hashable { self.dateModified = dateModified self.authors = authors self.status = status - + if let articleID = articleID { self.articleID = articleID - } - else { + } else { self.articleID = Article.calculatedArticleID(feedID: feedID, uniqueID: uniqueID) } } @@ -70,7 +69,7 @@ public final class Article: Hashable { } public extension Set where Element == Article { - + func articleIDs() -> Set { return Set(map { $0.articleID }) } @@ -83,11 +82,11 @@ public extension Set where Element == Article { func contains(accountID: String, articleID: String) -> Bool { return contains(where: { $0.accountID == accountID && $0.articleID == articleID}) } - + } public extension Array where Element == Article { - + func articleIDs() -> [String] { return map { $0.articleID } } @@ -118,7 +117,7 @@ public extension Article { forHTML ? result.append("<\(tag)>") : result.append("<\(tag)>") } - let _ = scanner.scanString(">") + _ = scanner.scanString(">") } } } diff --git a/Modules/Articles/Sources/Articles/ArticleStatus.swift b/Modules/Articles/Sources/Articles/ArticleStatus.swift index a958e3d5e..513ccf910 100644 --- a/Modules/Articles/Sources/Articles/ArticleStatus.swift +++ b/Modules/Articles/Sources/Articles/ArticleStatus.swift @@ -15,7 +15,7 @@ public final class ArticleStatus: Sendable, Hashable { case read = "read" case starred = "starred" } - + public let articleID: String public let dateArrived: Date @@ -59,7 +59,7 @@ public final class ArticleStatus: Sendable, Hashable { return starred } } - + public func setBoolStatus(_ status: Bool, forKey key: ArticleStatus.Key) { switch key { case .read: diff --git a/Modules/Articles/Sources/Articles/Author.swift b/Modules/Articles/Sources/Articles/Author.swift index 3bedce5bd..0e1c93b0d 100644 --- a/Modules/Articles/Sources/Articles/Author.swift +++ b/Modules/Articles/Sources/Articles/Author.swift @@ -15,7 +15,7 @@ public struct Author: Codable, Hashable { public let url: String? public let avatarURL: String? public let emailAddress: String? - + public init?(authorID: String?, name: String?, url: String?, avatarURL: String?, emailAddress: String?) { if name == nil && url == nil && emailAddress == nil { return nil @@ -27,8 +27,7 @@ public struct Author: Codable, Hashable { if let authorID = authorID { self.authorID = authorID - } - else { + } else { var s = name ?? "" s += url ?? "" s += avatarURL ?? "" @@ -47,8 +46,7 @@ public struct Author: Codable, Hashable { do { let authors = try decoder.decode([Author].self, from: data) return Set(authors) - } - catch { + } catch { assertionFailure("JSON representation of Author array could not be decoded: \(jsonString) error: \(error)") } return nil @@ -76,8 +74,7 @@ extension Set where Element == Author { do { let jsonData = try encoder.encode(Array(self)) return String(data: jsonData, encoding: .utf8) - } - catch { + } catch { assertionFailure("JSON representation of Author array could not be encoded: \(self) error: \(error)") } return nil diff --git a/Modules/Articles/Sources/Articles/DatabaseID.swift b/Modules/Articles/Sources/Articles/DatabaseID.swift index 1ad269cc3..8105d16cf 100644 --- a/Modules/Articles/Sources/Articles/DatabaseID.swift +++ b/Modules/Articles/Sources/Articles/DatabaseID.swift @@ -20,11 +20,11 @@ public func databaseIDWithString(_ s: String) -> String { defer { databaseIDCacheLock.unlock() } - + if let identifier = databaseIDCache[s] { return identifier } - + let identifier = s.md5String databaseIDCache[s] = identifier return identifier