diff --git a/Mintfile b/Mintfile index 4769ce7..93228eb 100644 --- a/Mintfile +++ b/Mintfile @@ -1,3 +1,3 @@ nicklockwood/SwiftFormat@0.47.0 realm/SwiftLint@0.41.0 -peripheryapp/periphery@2.12.3 +peripheryapp/periphery@2.18.0 diff --git a/Sources/SyndiKit/Decoding/DecodingError.swift b/Sources/SyndiKit/Decoding/DecodingError.swift index 0e96ebf..3cc52f0 100644 --- a/Sources/SyndiKit/Decoding/DecodingError.swift +++ b/Sources/SyndiKit/Decoding/DecodingError.swift @@ -1,7 +1,7 @@ import Foundation extension DecodingError { - private struct Dictionary: Error { + internal struct Dictionary: Error { internal init?(errors: [String: DecodingError]) { guard errors.count > 1 else { return nil @@ -9,7 +9,7 @@ extension DecodingError { self.errors = errors } - private let errors: [String: DecodingError] + internal let errors: [String: DecodingError] } internal static func failedAttempts(_ errors: [String: DecodingError]) -> Self { diff --git a/Sources/SyndiKit/Decoding/SynDecoder.swift b/Sources/SyndiKit/Decoding/SynDecoder.swift index b9ce0ce..ee7cb3a 100644 --- a/Sources/SyndiKit/Decoding/SynDecoder.swift +++ b/Sources/SyndiKit/Decoding/SynDecoder.swift @@ -58,7 +58,7 @@ public class SynDecoder { return (source.source, type.anyDecoding(using: decoder)) } - return Dictionary(grouping: decodings, by: { $0.0 }) + return Dictionary(grouping: decodings) { $0.0 } .mapValues { $0 .map { $0.1 } .map { (type(of: $0).label, $0) } diff --git a/Sources/SyndiKit/Formats/Blogs/SiteCategory.swift b/Sources/SyndiKit/Formats/Blogs/SiteCategory.swift index d62c468..71282e5 100644 --- a/Sources/SyndiKit/Formats/Blogs/SiteCategory.swift +++ b/Sources/SyndiKit/Formats/Blogs/SiteCategory.swift @@ -7,7 +7,7 @@ public struct SiteCategory { return nil } self.type = type - descriptors = Dictionary(grouping: languages, by: { $0.language }) + descriptors = Dictionary(grouping: languages) { $0.language } .compactMapValues { $0.first?.descriptor } } } diff --git a/Sources/SyndiKit/Formats/Blogs/SiteDirectory.swift b/Sources/SyndiKit/Formats/Blogs/SiteDirectory.swift index 23a27d4..960183d 100644 --- a/Sources/SyndiKit/Formats/Blogs/SiteDirectory.swift +++ b/Sources/SyndiKit/Formats/Blogs/SiteDirectory.swift @@ -9,14 +9,14 @@ public struct SiteCollectionDirectory: SiteDirectory { public typealias CategorySequence = Dictionary.Values - private struct Instance { - fileprivate let allSites: [Site] - fileprivate let languageDictionary: [SiteLanguageType: SiteLanguage] - fileprivate let categoryDictionary: [SiteCategoryType: SiteCategory] - fileprivate let languageIndicies: [SiteLanguageType: Set] - fileprivate let categoryIndicies: [SiteCategoryType: Set] - - fileprivate func sites( + internal struct Instance { + internal let allSites: [Site] + internal let languageDictionary: [SiteLanguageType: SiteLanguage] + internal let categoryDictionary: [SiteCategoryType: SiteCategory] + internal let languageIndicies: [SiteLanguageType: Set] + internal let categoryIndicies: [SiteCategoryType: Set] + + internal func sites( withLanguage language: SiteLanguageType?, withCategory category: SiteCategoryType? ) -> [Site] { @@ -56,7 +56,7 @@ public struct SiteCollectionDirectory: SiteDirectory { } // swiftlint:disable function_body_length - fileprivate init(blogs: SiteCollection) { + internal init(blogs: SiteCollection) { var categories = [CategoryLanguage]() var languages = [SiteLanguage]() var sites = [Site]() @@ -90,10 +90,8 @@ public struct SiteCollectionDirectory: SiteDirectory { languages.append(language) } - categoryDictionary = Dictionary( - grouping: categories, - by: { $0.type } - ).compactMapValues(SiteCategory.init) + categoryDictionary = Dictionary(grouping: categories) { $0.type } + .compactMapValues(SiteCategory.init) languageDictionary = Dictionary( uniqueKeysWithValues: languages.map { ($0.type, $0) } ) diff --git a/Sources/SyndiKit/Formats/Blogs/SiteLanguageCategory+Site.swift b/Sources/SyndiKit/Formats/Blogs/SiteLanguageCategory+Site.swift index 7946977..634511c 100644 --- a/Sources/SyndiKit/Formats/Blogs/SiteLanguageCategory+Site.swift +++ b/Sources/SyndiKit/Formats/Blogs/SiteLanguageCategory+Site.swift @@ -1,4 +1,6 @@ import Foundation + +// swiftlint:disable nesting extension SiteLanguageCategory { public struct Site: Codable { public let title: String diff --git a/Sources/SyndiKit/Formats/Media/Podcast/PodcastChapters+MimeType.swift b/Sources/SyndiKit/Formats/Media/Podcast/PodcastChapters+MimeType.swift index 4b57a7e..de3cac7 100644 --- a/Sources/SyndiKit/Formats/Media/Podcast/PodcastChapters+MimeType.swift +++ b/Sources/SyndiKit/Formats/Media/Podcast/PodcastChapters+MimeType.swift @@ -10,8 +10,11 @@ extension PodcastChapters { init?(mimeType: MimeType) { switch mimeType { - case .json: self = .json - case .unknown: return nil + case .json: + self = .json + + case .unknown: + return nil } } } @@ -47,7 +50,8 @@ extension PodcastChapters { private init(knownMimeType: KnownMimeType) { switch knownMimeType { - case .json: self = .json + case .json: + self = .json } } } diff --git a/Sources/SyndiKit/Formats/Media/Podcast/PodcastPerson+Role.swift b/Sources/SyndiKit/Formats/Media/Podcast/PodcastPerson+Role.swift index d3359d1..f292a2e 100644 --- a/Sources/SyndiKit/Formats/Media/Podcast/PodcastPerson+Role.swift +++ b/Sources/SyndiKit/Formats/Media/Podcast/PodcastPerson+Role.swift @@ -14,16 +14,32 @@ extension PodcastPerson { self.init(rawValue: caseInsensitive.lowercased()) } + // swiftlint:disable:next function_body_length cyclomatic_complexity init?(role: Role) { switch role { - case .guest: self = .guest - case .host: self = .host - case .editor: self = .editor - case .writer: self = .writer - case .designer: self = .designer - case .composer: self = .composer - case .producer: self = .producer - case .unknown: return nil + case .guest: + self = .guest + + case .host: + self = .host + + case .editor: + self = .editor + + case .writer: + self = .writer + + case .designer: + self = .designer + + case .composer: + self = .composer + + case .producer: + self = .producer + + case .unknown: + return nil } } } @@ -63,15 +79,29 @@ extension PodcastPerson { } } + // swiftlint:disable:next cyclomatic_complexity private init(knownRole: KnownRole) { switch knownRole { - case .guest: self = .guest - case .host: self = .host - case .editor: self = .editor - case .writer: self = .writer - case .designer: self = .designer - case .composer: self = .composer - case .producer: self = .producer + case .guest: + self = .guest + + case .host: + self = .host + + case .editor: + self = .editor + + case .writer: + self = .writer + + case .designer: + self = .designer + + case .composer: + self = .composer + + case .producer: + self = .producer } } } diff --git a/Sources/SyndiKit/Formats/Media/Podcast/PodcastTranscript+MimeType.swift b/Sources/SyndiKit/Formats/Media/Podcast/PodcastTranscript+MimeType.swift index 654c9d6..95f118b 100644 --- a/Sources/SyndiKit/Formats/Media/Podcast/PodcastTranscript+MimeType.swift +++ b/Sources/SyndiKit/Formats/Media/Podcast/PodcastTranscript+MimeType.swift @@ -15,13 +15,26 @@ extension PodcastTranscript { init?(mimeType: MimeType) { switch mimeType { - case .plain: self = .plain - case .html: self = .html - case .srt: self = .srt - case .vtt: self = .vtt - case .json: self = .json - case .subrip: self = .subrip - case .unknown: return nil + case .plain: + self = .plain + + case .html: + self = .html + + case .srt: + self = .srt + + case .vtt: + self = .vtt + + case .json: + self = .json + + case .subrip: + self = .subrip + + case .unknown: + return nil } } } @@ -62,12 +75,23 @@ extension PodcastTranscript { private init(knownMimeType: KnownMimeType) { switch knownMimeType { - case .plain: self = .plain - case .html: self = .html - case .srt: self = .srt - case .vtt: self = .vtt - case .json: self = .json - case .subrip: self = .subrip + case .plain: + self = .plain + + case .html: + self = .html + + case .srt: + self = .srt + + case .vtt: + self = .vtt + + case .json: + self = .json + + case .subrip: + self = .subrip } } } diff --git a/Sources/SyndiKit/Formats/Media/Wordpress/WordPressPost.swift b/Sources/SyndiKit/Formats/Media/Wordpress/WordPressPost.swift index 5c2ab14..61317a2 100644 --- a/Sources/SyndiKit/Formats/Media/Wordpress/WordPressPost.swift +++ b/Sources/SyndiKit/Formats/Media/Wordpress/WordPressPost.swift @@ -6,16 +6,6 @@ public enum WordPressError: Error, Equatable { case missingField(WordPressPost.Field) } -extension Entryable { - public var wpPost: WordPressPost? { - guard let rssItem = self as? RSSItem else { - return nil - } - - return try? WordPressPost(item: rssItem) - } -} - public struct WordPressPost { public typealias PostType = String public typealias CommentStatus = String @@ -61,7 +51,7 @@ public struct WordPressPost { public let pingStatus: PingStatus public let parentID: Int? public let menuOrder: Int? - public let id: Int + public let ID: Int public let isSticky: Bool public let postDate: Date public let postDateGMT: Date? @@ -108,7 +98,7 @@ public struct WordPressPost { self.pingStatus = pingStatus self.parentID = parentID self.menuOrder = menuOrder - self.id = id + self.ID = id self.isSticky = isSticky self.postDate = postDate self.postDateGMT = postDateGMT @@ -184,17 +174,14 @@ extension WordPressPost { self.body = body.value tags = categoryDictionary["post_tag", default: []].map { $0.value } categories = categoryDictionary["category", default: []].map { $0.value } - self.meta = Dictionary(grouping: meta, by: { - $0.key.value - }).compactMapValues { - $0.last?.value.value - } + self.meta = Dictionary(grouping: meta) { $0.key.value } + .compactMapValues { $0.last?.value.value } self.status = status.value self.commentStatus = commentStatus.value self.pingStatus = pingStatus.value self.parentID = parentID self.menuOrder = menuOrder - self.id = id + self.ID = id self.isSticky = (isSticky != 0) self.postDate = postDate postDateGMT = item.wpPostDateGMT @@ -205,10 +192,20 @@ extension WordPressPost { extension WordPressPost: Hashable { public static func == (lhs: WordPressPost, rhs: WordPressPost) -> Bool { - lhs.id == rhs.id + lhs.ID == rhs.ID } public func hash(into hasher: inout Hasher) { - hasher.combine(id) + hasher.combine(ID) + } +} + +extension Entryable { + public var wpPost: WordPressPost? { + guard let rssItem = self as? RSSItem else { + return nil + } + + return try? WordPressPost(item: rssItem) } }