Skip to content

Commit 5be30d0

Browse files
committed
Updated swiftformat
1 parent de6cb5a commit 5be30d0

19 files changed

Lines changed: 171 additions & 49 deletions

File tree

MaruDictionaryManagement/DictionaryTypes/DictionaryFormat.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ enum DictionaryFormat: Int, Codable, CustomStringConvertible {
2929
/// Derive a format from optional "format" and legacy "version" fields.
3030
/// Order of precedence matches existing logic: explicit format, then version.
3131
static func resolve(format: Int?, version: Int?) throws -> DictionaryFormat {
32-
if let f = format, let fmt = DictionaryFormat(rawValue: f) { return fmt }
33-
if let v = version, let fmt = DictionaryFormat(rawValue: v) { return fmt }
32+
if let f = format, let fmt = DictionaryFormat(rawValue: f) {
33+
return fmt
34+
}
35+
if let v = version, let fmt = DictionaryFormat(rawValue: v) {
36+
return fmt
37+
}
3438
throw DictionaryImportError.unsupportedFormat
3539
}
3640
}

MaruDictionaryManagementTests/DictionaryParsingTests/TermMetaBankIteratorTests.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,27 @@ struct TermMetaBankIteratorTests {
8080
#expect(pitch.reading == "あるく")
8181
#expect(pitch.pitches.count == 3)
8282
// First accent pattern HLL with nasal [1], devoice [2,3]
83-
if case let .pattern(p) = pitch.pitches[0].position { #expect(p == "HLL") } else { #expect(Bool(false)) }
83+
if case let .pattern(p) = pitch.pitches[0].position {
84+
#expect(p == "HLL")
85+
} else {
86+
#expect(Bool(false))
87+
}
8488
#expect(pitch.pitches[0].nasal == [1])
8589
#expect(pitch.pitches[0].devoice == [2, 3])
8690
#expect(pitch.pitches[0].tags == ["v5k", "intransitive"])
8791
// Second accent mora 0
88-
if case let .mora(m0) = pitch.pitches[1].position { #expect(m0 == 0) } else { #expect(Bool(false)) }
92+
if case let .mora(m0) = pitch.pitches[1].position {
93+
#expect(m0 == 0)
94+
} else {
95+
#expect(Bool(false))
96+
}
8997
#expect(pitch.pitches[1].nasal == nil)
9098
// Third accent mora 3 with nasal single (converted to array), devoice [4]
91-
if case let .mora(m3) = pitch.pitches[2].position { #expect(m3 == 3) } else { #expect(Bool(false)) }
99+
if case let .mora(m3) = pitch.pitches[2].position {
100+
#expect(m3 == 3)
101+
} else {
102+
#expect(Bool(false))
103+
}
92104
#expect(pitch.pitches[2].nasal == [2])
93105
#expect(pitch.pitches[2].devoice == [4])
94106
#expect(pitch.pitches[2].tags == ["alt"])

MaruDictionaryManagementTests/DictionaryParsingTests/TermMetaParsingTests.swift

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,11 @@ struct TermMetaParsingTests {
252252
switch entries[0].data {
253253
case let .pitch(pitch):
254254
#expect(pitch.pitches.count == 1)
255-
if case let .mora(n) = pitch.pitches[0].position { #expect(n == 1) } else { #expect(Bool(false)) }
255+
if case let .mora(n) = pitch.pitches[0].position {
256+
#expect(n == 1)
257+
} else {
258+
#expect(Bool(false))
259+
}
256260
#expect(pitch.pitches[0].nasal == [2])
257261
#expect(pitch.pitches[0].devoice == nil)
258262
default: #expect(Bool(false), "Expected pitch data")
@@ -326,8 +330,16 @@ struct TermMetaParsingTests {
326330
switch entries[0].data {
327331
case let .pitch(pitch):
328332
#expect(pitch.pitches.count == 2)
329-
if case let .mora(n0) = pitch.pitches[0].position { #expect(n0 == 0) } else { #expect(Bool(false)) }
330-
if case let .mora(n1) = pitch.pitches[1].position { #expect(n1 == 1) } else { #expect(Bool(false)) }
333+
if case let .mora(n0) = pitch.pitches[0].position {
334+
#expect(n0 == 0)
335+
} else {
336+
#expect(Bool(false))
337+
}
338+
if case let .mora(n1) = pitch.pitches[1].position {
339+
#expect(n1 == 1)
340+
} else {
341+
#expect(Bool(false))
342+
}
331343
#expect(pitch.pitches[0].tags == ["heiban"])
332344
#expect(pitch.pitches[1].tags == ["odaka"])
333345
default: #expect(Bool(false), "Expected pitch data")
@@ -355,7 +367,11 @@ struct TermMetaParsingTests {
355367
case let .pitch(pitch):
356368
#expect(pitch.reading == "あるく")
357369
#expect(pitch.pitches.count == 1)
358-
if case let .pattern(p) = pitch.pitches[0].position { #expect(p == "HLL") } else { #expect(Bool(false)) }
370+
if case let .pattern(p) = pitch.pitches[0].position {
371+
#expect(p == "HLL")
372+
} else {
373+
#expect(Bool(false))
374+
}
359375
#expect(pitch.pitches[0].nasal == [1])
360376
#expect(pitch.pitches[0].devoice == [2, 3])
361377
#expect(pitch.pitches[0].tags == ["v5k", "intransitive"])
@@ -388,7 +404,11 @@ struct TermMetaParsingTests {
388404
let entries = try decoder.decode([TermMetaBankV3Entry].self, from: data)
389405
switch entries[0].data {
390406
case let .pitch(pitch):
391-
if case let .mora(n) = pitch.pitches[0].position { #expect(n == 0) } else { #expect(Bool(false)) }
407+
if case let .mora(n) = pitch.pitches[0].position {
408+
#expect(n == 0)
409+
} else {
410+
#expect(Bool(false))
411+
}
392412
default: #expect(Bool(false), "Expected pitch data")
393413
}
394414
}

MaruDictionaryUICommon/DictionarySearchViewModel.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,9 @@ public final class DictionarySearchViewModel: NSObject, WKScriptMessageHandler {
478478
// Start new search with debounce
479479
searchTask = Task {
480480
try? await Task.sleep(nanoseconds: 300_000_000) // 0.3s debounce
481-
if Task.isCancelled { return }
481+
if Task.isCancelled {
482+
return
483+
}
482484

483485
let resolvedContextValues = contextValues ?? currentRequest?.contextValues
484486
let lookupRequest = TextLookupRequest(context: searchQuery, contextValues: resolvedContextValues)

MaruManga/Services/MangaArchiveReader.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ public actor MangaArchiveReader {
247247
guard i >= 0, i < count else { continue }
248248

249249
let isCached = await self.isCached(pageIndex: i)
250-
if isCached { continue }
250+
if isCached {
251+
continue
252+
}
251253

252254
_ = try? await self.loadPage(at: i)
253255
}
@@ -273,7 +275,9 @@ public actor MangaArchiveReader {
273275
guard index >= 0, index < count else { continue }
274276

275277
let isCached = await self.isCached(pageIndex: index)
276-
if isCached { continue }
278+
if isCached {
279+
continue
280+
}
277281

278282
_ = try? await self.loadPage(at: index)
279283
}

MaruManga/SpreadLayout.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ struct SpreadLayout: Equatable {
4646

4747
/// Whether this is a single page (not a spread).
4848
var isSingle: Bool {
49-
if case .single = self { return true }
49+
if case .single = self {
50+
return true
51+
}
5052
return false
5153
}
5254
}

MaruManga/Views/MangaLibraryView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,11 @@ public struct MangaArchiveLibraryView: View {
308308
private func deleteConfirmationBinding(for book: MangaArchive) -> Binding<Bool> {
309309
Binding(
310310
get: { showingDeleteConfirmation && bookToDelete?.objectID == book.objectID },
311-
set: { if !$0 { showingDeleteConfirmation = false; bookToDelete = nil } }
311+
set: {
312+
if !$0 {
313+
showingDeleteConfirmation = false; bookToDelete = nil
314+
}
315+
}
312316
)
313317
}
314318

MaruReader/Views/Anki/PendingNotesView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ struct PendingNotesView: View {
8787
}
8888
.alert("Error", isPresented: .init(
8989
get: { errorMessage != nil },
90-
set: { if !$0 { errorMessage = nil } }
90+
set: {
91+
if !$0 {
92+
errorMessage = nil
93+
}
94+
}
9195
)) {
9296
Button("OK", role: .cancel) {}
9397
} message: {

MaruReader/Views/BookLibraryView.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ struct BookLibraryView: View {
117117
private var isShowingReader: Binding<Bool> {
118118
Binding(
119119
get: { selectedBookID != nil },
120-
set: { if !$0 { selectedBookID = nil } }
120+
set: {
121+
if !$0 {
122+
selectedBookID = nil
123+
}
124+
}
121125
)
122126
}
123127

@@ -261,7 +265,11 @@ struct BookLibraryView: View {
261265
private func deleteConfirmationBinding(for book: Book) -> Binding<Bool> {
262266
Binding(
263267
get: { showingDeleteConfirmation && bookToDelete?.objectID == book.objectID },
264-
set: { if !$0 { showingDeleteConfirmation = false; bookToDelete = nil } }
268+
set: {
269+
if !$0 {
270+
showingDeleteConfirmation = false; bookToDelete = nil
271+
}
272+
}
265273
)
266274
}
267275

MaruReader/Views/OCRScanView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ struct OCRScanView: View {
190190
}
191191
.alert("Error", isPresented: .init(
192192
get: { errorMessage != nil },
193-
set: { if !$0 { errorMessage = nil } }
193+
set: {
194+
if !$0 {
195+
errorMessage = nil
196+
}
197+
}
194198
)) {
195199
Button("OK", role: .cancel) {}
196200
} message: {

0 commit comments

Comments
 (0)