Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 9ddb467

Browse files
committed
Swiftlint updates
1 parent caa52b9 commit 9ddb467

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

WordPressKit/Insights/StatsCommentsInsight.swift

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,6 @@ public struct StatsTopCommentsPost: Codable {
6767
}
6868

6969
private extension StatsTopCommentsAuthor {
70-
public init(from decoder: Decoder) throws {
71-
let container = try decoder.container(keyedBy: CodingKeys.self)
72-
let name = try container.decode(String.self, forKey: .name)
73-
let commentCount: Int
74-
if let comments = try? container.decodeIfPresent(String.self, forKey: .commentCount) {
75-
commentCount = Int(comments) ?? 0
76-
} else {
77-
commentCount = 0
78-
}
79-
let iconURL = try container.decodeIfPresent(String.self, forKey: .iconURL)
80-
81-
self.init(name: name, avatar: iconURL, commentCount: commentCount)
82-
}
83-
8470
init(name: String, avatar: String?, commentCount: Int) {
8571
let url: URL?
8672

@@ -97,8 +83,24 @@ private extension StatsTopCommentsAuthor {
9783
}
9884
}
9985

100-
private extension StatsTopCommentsPost {
101-
public init(from decoder: Decoder) throws {
86+
public extension StatsTopCommentsAuthor {
87+
init(from decoder: Decoder) throws {
88+
let container = try decoder.container(keyedBy: CodingKeys.self)
89+
let name = try container.decode(String.self, forKey: .name)
90+
let commentCount: Int
91+
if let comments = try? container.decodeIfPresent(String.self, forKey: .commentCount) {
92+
commentCount = Int(comments) ?? 0
93+
} else {
94+
commentCount = 0
95+
}
96+
let iconURL = try container.decodeIfPresent(String.self, forKey: .iconURL)
97+
98+
self.init(name: name, avatar: iconURL, commentCount: commentCount)
99+
}
100+
}
101+
102+
public extension StatsTopCommentsPost {
103+
init(from decoder: Decoder) throws {
102104
let container = try decoder.container(keyedBy: CodingKeys.self)
103105
let name = try container.decode(String.self, forKey: .name)
104106
let postID = try container.decode(String.self, forKey: .postID)

WordPressKit/Insights/StatsDotComFollowersInsight.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extension StatsFollower {
5959
self.name = try container.decode(String.self, forKey: .name)
6060
if let id = try? container.decodeIfPresent(Int.self, forKey: .id) {
6161
self.id = "\(id)"
62-
} else if let id = try? container.decodeIfPresent(String.self, forKey: .id) {
62+
} else if let id = try? container.decodeIfPresent(String.self, forKey: .id) {
6363
self.id = id
6464
} else {
6565
self.id = nil

WordPressKit/Insights/StatsPublicizeInsight.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ public struct StatsPublicizeService: Codable {
3838
}
3939

4040
private extension StatsPublicizeService {
41-
public init(from decoder: Decoder) throws {
42-
let container = try decoder.container(keyedBy: CodingKeys.self)
43-
let name = try container.decode(String.self, forKey: .name)
44-
let followers = (try? container.decodeIfPresent(Int.self, forKey: .followers)) ?? 0
45-
46-
self.init(name: name, followers: followers)
47-
}
48-
4941
init(name: String, followers: Int) {
5042
let niceName: String
5143
let icon: URL?
@@ -79,3 +71,13 @@ private extension StatsPublicizeService {
7971
self.iconURL = icon
8072
}
8173
}
74+
75+
public extension StatsPublicizeService {
76+
init(from decoder: Decoder) throws {
77+
let container = try decoder.container(keyedBy: CodingKeys.self)
78+
let name = try container.decode(String.self, forKey: .name)
79+
let followers = (try? container.decodeIfPresent(Int.self, forKey: .followers)) ?? 0
80+
81+
self.init(name: name, followers: followers)
82+
}
83+
}

0 commit comments

Comments
 (0)