From fd84481129c705cd48c89bd49446d98a9bee2d27 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 25 Jan 2025 10:25:26 -0800 Subject: [PATCH] Fix lint issues. --- .../Parser/FeedParser/Feeds/JSON/RSSInJSONParser.swift | 9 ++++----- .../Sources/Parser/FeedParser/Feeds/ParsedItem.swift | 5 +---- .../Sources/Parser/HTMLParser/HTMLEntityDecoder.swift | 7 ++++--- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Modules/Parser/Sources/Parser/FeedParser/Feeds/JSON/RSSInJSONParser.swift b/Modules/Parser/Sources/Parser/FeedParser/Feeds/JSON/RSSInJSONParser.swift index 0146342ce..39495b323 100644 --- a/Modules/Parser/Sources/Parser/FeedParser/Feeds/JSON/RSSInJSONParser.swift +++ b/Modules/Parser/Sources/Parser/FeedParser/Feeds/JSON/RSSInJSONParser.swift @@ -117,11 +117,10 @@ private extension RSSInJSONParser { } if s.isEmpty { // Sheesh. Tough case. - if let _ = contentHTML { - s = contentHTML! - } - if let _ = contentText { - s = contentText! + if let contentHTML { + s = contentHTML + } else if let contentText { + s = contentText } } uniqueID = s.md5String diff --git a/Modules/Parser/Sources/Parser/FeedParser/Feeds/ParsedItem.swift b/Modules/Parser/Sources/Parser/FeedParser/Feeds/ParsedItem.swift index c748e8996..c6a29b361 100644 --- a/Modules/Parser/Sources/Parser/FeedParser/Feeds/ParsedItem.swift +++ b/Modules/Parser/Sources/Parser/FeedParser/Feeds/ParsedItem.swift @@ -28,10 +28,7 @@ public final class ParsedItem: Hashable, Sendable { public let tags: Set? public let attachments: Set? - public init(syncServiceID: String?, uniqueID: String, feedURL: String, url: String?, externalURL: String?, title: String?, - language: String?, contentHTML: String?, contentText: String?, summary: String?, imageURL: String?, - bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: Set?, - tags: Set?, attachments: Set?) { + public init(syncServiceID: String?, uniqueID: String, feedURL: String, url: String?, externalURL: String?, title: String?, language: String?, contentHTML: String?, contentText: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: Set?, tags: Set?, attachments: Set?) { self.syncServiceID = syncServiceID self.uniqueID = uniqueID diff --git a/Modules/Parser/Sources/Parser/HTMLParser/HTMLEntityDecoder.swift b/Modules/Parser/Sources/Parser/HTMLParser/HTMLEntityDecoder.swift index f7d4341c8..d2c9cbcd2 100644 --- a/Modules/Parser/Sources/Parser/HTMLParser/HTMLEntityDecoder.swift +++ b/Modules/Parser/Sources/Parser/HTMLParser/HTMLEntityDecoder.swift @@ -131,9 +131,10 @@ private func decodedRawEntityValue(_ rawEntity: ContiguousArray) -> Strin entityCharacters.append(character) } - let key = String(decoding: entityCharacters, as: UTF8.self) - if let entityString = entitiesDictionary[key] { - return entityString + if let key = String(bytes: entityCharacters, encoding: .utf8) { + if let entityString = entitiesDictionary[key] { + return entityString + } } if rawEntity[0] == numberSignCharacter {