Skip to content

Commit fd03ab5

Browse files
committed
change formatter to swift-format
1 parent d618959 commit fd03ab5

File tree

70 files changed

+413
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+413
-293
lines changed

.swift-format

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"fileScopedDeclarationPrivacy" : {
3+
"accessLevel" : "private"
4+
},
5+
"indentConditionalCompilationBlocks" : false,
6+
"indentSwitchCaseLabels" : false,
7+
"indentation" : {
8+
"spaces" : 4
9+
},
10+
"lineBreakAroundMultilineExpressionChainComponents" : false,
11+
"lineBreakBeforeControlFlowKeywords" : false,
12+
"lineBreakBeforeEachArgument" : false,
13+
"lineBreakBeforeEachGenericRequirement" : false,
14+
"lineLength" : 120,
15+
"maximumBlankLines" : 1,
16+
"multiElementCollectionTrailingCommas" : true,
17+
"noAssignmentInExpressions" : {
18+
"allowedFunctions" : [
19+
"XCTAssertNoThrow"
20+
]
21+
},
22+
"prioritizeKeepingFunctionOutputTogether" : false,
23+
"respectsExistingLineBreaks" : true,
24+
"rules" : {
25+
"AllPublicDeclarationsHaveDocumentation" : false,
26+
"AlwaysUseLiteralForEmptyCollectionInit" : false,
27+
"AlwaysUseLowerCamelCase" : true,
28+
"AmbiguousTrailingClosureOverload" : true,
29+
"BeginDocumentationCommentWithOneLineSummary" : false,
30+
"DoNotUseSemicolons" : true,
31+
"DontRepeatTypeInStaticProperties" : true,
32+
"FileScopedDeclarationPrivacy" : true,
33+
"FullyIndirectEnum" : true,
34+
"GroupNumericLiterals" : true,
35+
"IdentifiersMustBeASCII" : true,
36+
"NeverForceUnwrap" : false,
37+
"NeverUseForceTry" : false,
38+
"NeverUseImplicitlyUnwrappedOptionals" : false,
39+
"NoAccessLevelOnExtensionDeclaration" : true,
40+
"NoAssignmentInExpressions" : true,
41+
"NoBlockComments" : true,
42+
"NoCasesWithOnlyFallthrough" : true,
43+
"NoEmptyTrailingClosureParentheses" : true,
44+
"NoLabelsInCasePatterns" : true,
45+
"NoLeadingUnderscores" : false,
46+
"NoParensAroundConditions" : true,
47+
"NoPlaygroundLiterals" : true,
48+
"NoVoidReturnOnFunctionSignature" : true,
49+
"OmitExplicitReturns" : false,
50+
"OneCasePerLine" : true,
51+
"OneVariableDeclarationPerLine" : true,
52+
"OnlyOneTrailingClosureArgument" : true,
53+
"OrderedImports" : true,
54+
"ReplaceForEachWithForLoop" : true,
55+
"ReturnVoidInsteadOfEmptyTuple" : true,
56+
"TypeNamesShouldBeCapitalized" : true,
57+
"UseEarlyExits" : false,
58+
"UseExplicitNilCheckInConditions" : true,
59+
"UseLetInEveryBoundCaseVariable" : true,
60+
"UseShorthandTypeNames" : true,
61+
"UseSingleLinePropertyGetter" : true,
62+
"UseSynthesizedInitializer" : true,
63+
"UseTripleSlashForDocumentationComments" : true,
64+
"UseWhereClausesInForLoops" : false,
65+
"ValidateDocumentationComments" : false
66+
},
67+
"spacesAroundRangeFormationOperators" : false,
68+
"tabWidth" : 8,
69+
"version" : 1
70+
}

.swift-format.swp

12 KB
Binary file not shown.

App/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let package = Package(
1212
.library(
1313
name: "MidoriApp",
1414
targets: ["MidoriApp"]
15-
),
15+
)
1616
],
1717
dependencies: [
1818
.package(path: "UI"),

App/Tests/AppTests/AppTests.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
@testable import App
21
import Testing
32

3+
@testable import App
4+
45
@Test func example() async throws {
56
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
67
}

MangaDexAPIClient/Sources/MangaDexAPIClient/APIClient.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public enum MangaDexServer: CaseIterable, Sendable {
1414
case development
1515
}
1616

17-
public extension APIClient {
17+
extension APIClient {
1818
/// Creates a client for MangaDex API.
19-
static func mangaDex(
19+
public static func mangaDex(
2020
server: MangaDexServer = .production,
2121
sessionConfiguration: URLSessionConfiguration = .default
2222
) -> Self {
@@ -43,8 +43,8 @@ private enum MangaDexAPIClientDependencyKey: DependencyKey {
4343
static let liveValue: APIClient = .mangaDex()
4444
}
4545

46-
public extension DependencyValues {
47-
var mangaDexAPIClient: APIClient {
46+
extension DependencyValues {
47+
public var mangaDexAPIClient: APIClient {
4848
get { self[MangaDexAPIClientDependencyKey.self] }
4949
set { self[MangaDexAPIClientDependencyKey.self] = newValue }
5050
}

MangaDexAPIClient/Sources/MangaDexAPIClient/Endpoint/AtHomeEndpoint.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import Foundation
99
import Get
1010

11-
public extension MangaDexAPI {
12-
struct AtHome: Sendable {
11+
extension MangaDexAPI {
12+
public struct AtHome: Sendable {
1313
static let path = "/at-home"
1414

1515
public static func server(chapterID: UUID) -> Server {
@@ -18,14 +18,14 @@ public extension MangaDexAPI {
1818
}
1919
}
2020

21-
public extension MangaDexAPI.AtHome {
22-
struct Server: Sendable {
21+
extension MangaDexAPI.AtHome {
22+
public struct Server: Sendable {
2323
let path: String
2424
}
2525
}
2626

27-
public extension MangaDexAPI.AtHome.Server {
28-
func get(forceHTTPS: Bool = false) -> Request<AtHomeServer> {
27+
extension MangaDexAPI.AtHome.Server {
28+
public func get(forceHTTPS: Bool = false) -> Request<AtHomeServer> {
2929
var query: [(String, String?)] = []
3030
if forceHTTPS {
3131
query.append(("forcePort443", "true"))

MangaDexAPIClient/Sources/MangaDexAPIClient/Endpoint/ChapterEndpoint.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import Foundation
99
import Get
1010

11-
public extension MangaDexAPI {
11+
extension MangaDexAPI {
1212
/// Chapter resource
13-
struct Chapter: Sendable {
13+
public struct Chapter: Sendable {
1414
static let basePath = "chapter"
1515
let path: String
1616

@@ -22,8 +22,8 @@ public extension MangaDexAPI {
2222

2323
// MARK: - Chapter Reference
2424

25-
public extension MangaDexAPI.Chapter {
26-
enum Reference: String, EndpointReference, Sendable {
25+
extension MangaDexAPI.Chapter {
26+
public enum Reference: String, EndpointReference, Sendable {
2727
case manga
2828
case scanlationGroup = "scanlation_group"
2929
case user
@@ -38,16 +38,16 @@ public struct GetChapterListResponse: Decodable, Sendable {
3838
public let data: [Chapter]
3939
}
4040

41-
public extension MangaDexAPI.Chapter {
42-
enum ListSortOptions: String, Sendable {
41+
extension MangaDexAPI.Chapter {
42+
public enum ListSortOptions: String, Sendable {
4343
case createdAt
4444
case updatedAt
4545
case publishAt
4646
case readableAt
4747
}
4848

4949
/// Get manga list
50-
static func list(
50+
public static func list(
5151
pagination: Pagination,
5252
order: [ListSortOptions: SortOrder] = [:],
5353
includes: [Reference] = [.scanlationGroup]

MangaDexAPIClient/Sources/MangaDexAPIClient/Endpoint/MangaEndpoint.swift

+18-17
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import Foundation
99
import Get
1010

11-
public extension MangaDexAPI {
11+
extension MangaDexAPI {
1212
/// Manga resource
13-
struct Manga: Sendable {
13+
public struct Manga: Sendable {
1414
static let basePath = "manga"
1515
let path: String
1616

@@ -22,8 +22,8 @@ public extension MangaDexAPI {
2222

2323
// MARK: - Manga Reference
2424

25-
public extension MangaDexAPI.Manga {
26-
enum Reference: String, EndpointReference, Sendable {
25+
extension MangaDexAPI.Manga {
26+
public enum Reference: String, EndpointReference, Sendable {
2727
case manga
2828
case cover = "cover_art"
2929
case author
@@ -41,15 +41,15 @@ public struct GetMangaListResponse: Decodable, Sendable {
4141
public let data: [Manga]
4242
}
4343

44-
public extension MangaDexAPI.Manga {
45-
enum ListSortOptions: String, Sendable {
44+
extension MangaDexAPI.Manga {
45+
public enum ListSortOptions: String, Sendable {
4646
case latestUploadChapter
4747
case followedCount
4848
case createdAt
4949
}
5050

5151
/// Get manga list
52-
static func list(
52+
public static func list(
5353
pagination: Pagination,
5454
order: [ListSortOptions: SortOrder] = [:],
5555
includes: [Reference] = [.artist, .author, .cover],
@@ -63,10 +63,11 @@ public extension MangaDexAPI.Manga {
6363
query.append(contentsOf: includes.queryItems)
6464

6565
if let createdAtSince {
66-
query.append(URLQueryItem(
67-
name: "createdAtSince",
68-
value: createdAtSince.formatted(.mangaDexAPIDate)
69-
))
66+
query.append(
67+
URLQueryItem(
68+
name: "createdAtSince",
69+
value: createdAtSince.formatted(.mangaDexAPIDate)
70+
))
7071
}
7172

7273
if let ids {
@@ -87,9 +88,9 @@ public struct GetMangaResponse: Decodable, Sendable {
8788
public let data: Manga
8889
}
8990

90-
public extension MangaDexAPI.Manga {
91+
extension MangaDexAPI.Manga {
9192
/// Get manga
92-
func get(includes: [Reference] = [.artist, .author, .cover]) -> Request<GetMangaResponse> {
93+
public func get(includes: [Reference] = [.artist, .author, .cover]) -> Request<GetMangaResponse> {
9394
var query: [URLQueryItem] = []
9495
query.append(contentsOf: includes.queryItems)
9596

@@ -105,9 +106,9 @@ public struct GetMangaFeedResponse: Decodable, Sendable {
105106
public let data: [Chapter]
106107
}
107108

108-
public extension MangaDexAPI.Manga {
109+
extension MangaDexAPI.Manga {
109110
/// Get manga feed
110-
func feed(
111+
public func feed(
111112
pagination: Pagination,
112113
includes: [MangaDexAPI.Chapter.Reference] = [.scanlationGroup]
113114
) -> Request<GetMangaFeedResponse> {
@@ -121,8 +122,8 @@ public extension MangaDexAPI.Manga {
121122

122123
// MARK: - Get Manga volumes & chapters
123124

124-
public extension MangaDexAPI.Manga {
125-
func aggregate(groups: [UUID] = []) -> Request<MangaAggregate> {
125+
extension MangaDexAPI.Manga {
126+
public func aggregate(groups: [UUID] = []) -> Request<MangaAggregate> {
126127
var query: [URLQueryItem] = []
127128
query.append(contentsOf: groups.queryItems(name: "groups[]"))
128129

MangaDexAPIClient/Sources/MangaDexAPIClient/Endpoint/StatisticsEndpoint.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import Foundation
99
import Get
1010

11-
public extension MangaDexAPI {
11+
extension MangaDexAPI {
1212
/// Statistics endpoint.
13-
enum Statistics {}
13+
public enum Statistics {}
1414
}
1515

16-
public extension MangaDexAPI.Statistics {
16+
extension MangaDexAPI.Statistics {
1717
/// Manga statistics.
18-
struct Manga {
18+
public struct Manga {
1919
static let basePath = "statistics/manga"
2020
let path: String
2121

@@ -48,8 +48,8 @@ public struct GetMangaStatisticsListResponse: Decodable, Sendable {
4848
}
4949
}
5050

51-
public extension MangaDexAPI.Statistics.Manga {
52-
static func list(ids: [UUID]) -> Request<GetMangaStatisticsListResponse> {
51+
extension MangaDexAPI.Statistics.Manga {
52+
public static func list(ids: [UUID]) -> Request<GetMangaStatisticsListResponse> {
5353
var query: [URLQueryItem] = []
5454
query.append(contentsOf: ids.queryItems(name: "manga[]"))
5555

MangaDexAPIClient/Sources/MangaDexAPIClient/Endpoint/UserEndpoint.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import Foundation
99
import Get
1010

11-
public extension MangaDexAPI {
12-
struct User: Sendable {}
11+
extension MangaDexAPI {
12+
public struct User: Sendable {}
1313
}
1414

1515
// MARK: - Get logged in user
@@ -18,8 +18,8 @@ public struct GetLoggedInUserResponse: Decodable, Sendable {
1818
public let data: User
1919
}
2020

21-
public extension MangaDexAPI.User {
22-
static func me() -> Request<GetLoggedInUserResponse> {
21+
extension MangaDexAPI.User {
22+
public static func me() -> Request<GetLoggedInUserResponse> {
2323
Request(path: "/user/me")
2424
}
2525
}
@@ -32,8 +32,8 @@ public struct GetUserFollowedMangaFeedResponse: Decodable, Sendable {
3232
public let data: [Chapter]
3333
}
3434

35-
public extension MangaDexAPI.User {
36-
static func followedMangaFeed(
35+
extension MangaDexAPI.User {
36+
public static func followedMangaFeed(
3737
pagination: Pagination,
3838
order: [MangaDexAPI.Chapter.ListSortOptions: SortOrder] = [:],
3939
includes: [MangaDexAPI.Chapter.Reference] = [.scanlationGroup]

MangaDexAPIClient/Sources/MangaDexAPIClient/MangaDexAPIClientDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class MangaDexAPIClientDelegate: APIClientDelegate {
1919
data: Data,
2020
task _: URLSessionTask
2121
) throws {
22-
guard (200 ..< 300).contains(response.statusCode) else {
22+
guard (200..<300).contains(response.statusCode) else {
2323
throw MangaDexAPIError(response: response, data: data)
2424
}
2525
}

MangaDexAPIClient/Sources/MangaDexAPIClient/Model/Common/LocalizedString.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public struct LocalizedString: Decodable, Sendable {
1313
// A lot of localized strings only have 1 variant, so a dictionary is overkill
1414
enum Storage {
1515
case single(Variant)
16-
case multiple(Variant, [String: String]) // a primary variant and other variants, if any
16+
case multiple(Variant, [String: String]) // a primary variant and other variants, if any
1717
}
1818

1919
let storage: Storage

MangaDexAPIClient/Sources/MangaDexAPIClient/Model/Entity/Entity.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public protocol Entity<Attributes>: Identifiable, Decodable, Sendable {
2222
init(id: UUID, attributes: Attributes)
2323
}
2424

25-
public extension Entity {
26-
var relationships: RelationshipContainer {
25+
extension Entity {
26+
public var relationships: RelationshipContainer {
2727
RelationshipContainer()
2828
}
2929
}
3030

31-
public extension Entity {
32-
subscript<T>(dynamicMember keyPath: KeyPath<Attributes, T>) -> T {
31+
extension Entity {
32+
public subscript<T>(dynamicMember keyPath: KeyPath<Attributes, T>) -> T {
3333
attributes[keyPath: keyPath]
3434
}
3535
}

0 commit comments

Comments
 (0)