chore(lint): neue wordeck-Event-Dateien swiftlint-sauber

k/v→key/value, clamp-Param v→value, cyclomatic-Disables für die großen
Switch-Reducer, file/type-body/param-count-Disables (begrenzt) für die
zentrale Coordinator-Klasse + FSRS-applyLearningSteps, identifier_name
für die snake_case-JSON-Spiegel im FSRS-Golden-Test, superfluous
type_body_length-Disable in WordeckAPI entfernt (Delegation verkleinerte
die Datei). 49/49 Tests grün.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-05-25 15:55:57 +02:00
parent 96ef285dfe
commit cb4bb13d09
6 changed files with 22 additions and 13 deletions

View file

@ -1,8 +1,6 @@
import Foundation
import ManaCore
// swiftlint:disable type_body_length
/// Wordeck-API-Client. Wrapper um `AuthenticatedTransport`
/// aus ManaCore, der die Wordeck-Endpoints kennt. Marketplace-Moderation
/// + Self-Endpoints + AI-Generation sind in `WordeckAPI+Marketplace.swift`
@ -288,8 +286,6 @@ actor WordeckAPI {
}
}
// swiftlint:enable type_body_length
private struct CardsServerError: Decodable {
let error: String?
}

View file

@ -179,6 +179,7 @@ struct FSRS {
nextEasy.due = Self.dateScheduler(now, easy, isDay: true)
}
// swiftlint:disable:next function_parameter_count
private func applyLearningSteps(
_ nextCard: inout FSRSCard, current: FSRSCard, now: Date, elapsed _: Int,
grade: FSRSRating, toState: FSRSState
@ -321,8 +322,8 @@ struct FSRS {
return jsRound(num * f) / f
}
static func clamp(_ v: Double, _ lo: Double, _ hi: Double) -> Double {
min(max(v, lo), hi)
static func clamp(_ value: Double, _ lo: Double, _ hi: Double) -> Double {
min(max(value, lo), hi)
}
static func stepMinutes(_ step: String) -> Int {

View file

@ -29,13 +29,13 @@ enum WordeckEventAdapters {
let obj = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
else { return [:] }
var out: [String: String] = [:]
for (k, v) in obj {
if let s = v as? String {
out[k] = s
} else if let d = try? JSONSerialization.data(withJSONObject: v),
let s = String(data: d, encoding: .utf8)
for (key, value) in obj {
if let string = value as? String {
out[key] = string
} else if let data = try? JSONSerialization.data(withJSONObject: value),
let string = String(data: data, encoding: .utf8)
{
out[k] = s
out[key] = string
}
}
return out

View file

@ -2,6 +2,10 @@ import Foundation
import ManaCore
import ManaEventSync
// Zentrale Repository-Klasse + Delegations-Fassade bewusst groß, viele
// Domänen-Methoden + ein FSRS-Import mit vielen Feldern.
// swiftlint:disable file_length type_body_length function_parameter_count
/// Event-sourced Daten-API für wordeck-native (E-4.4b). Ersetzt die
/// user-owned-Routen von `WordeckAPI` (decks/cards/reviews) die sind
/// seit dem Web-Cutover 410-tot. Marketplace + KI-Generate bleiben REST.
@ -387,7 +391,6 @@ final class WordeckEventCoordinator {
/// Importiert einen Review-State 1:1 aus dem Cache: `ReviewInitialized`
/// plus (falls schon gelernt, `reps > 0`) ein `ReviewGraded`, das die
/// gespeicherten FSRS-Felder exakt übernimmt **kein** Re-Compute.
// swiftlint:disable:next function_parameter_count
func importReview(
cardId: String, subIndex: Int, due: String, state: String,
stability: Double, difficulty: Double, elapsedDays: Double, scheduledDays: Double,
@ -500,3 +503,5 @@ enum WordeckData {
try await coordinator().gradeReview(cardId: cardId, subIndex: subIndex, rating: rating, reviewedAt: reviewedAt)
}
}
// swiftlint:enable file_length type_body_length function_parameter_count

View file

@ -18,6 +18,7 @@ enum WordeckReducers {
return state.id.isEmpty ? nil : state
}
// swiftlint:disable:next cyclomatic_complexity
private static func applyDeck(_ state: DeckProjection, _ event: EventEnvelope) -> DeckProjection {
var s = state
switch event.eventType {
@ -81,6 +82,7 @@ enum WordeckReducers {
return state.id.isEmpty ? nil : state
}
// swiftlint:disable:next cyclomatic_complexity
private static func applyCard(_ state: CardProjection, _ event: EventEnvelope) -> CardProjection {
var s = state
switch event.eventType {

View file

@ -2,6 +2,9 @@ import Foundation
import Testing
@testable import WordeckNative
// Step-Felder spiegeln die snake_case-JSON-Keys der Golden-Fixtures.
// swiftlint:disable identifier_name
/// Byte-Paritäts-Tests des Swift-FSRS-Ports gegen echte ts-fsrs-v5.3.2-
/// Outputs (`Fixtures/fsrs_golden.json`, generiert mit `enable_fuzz:false`).
/// Schlägt der Test fehl, weicht die Karten-Planung vom Web ab würde
@ -82,3 +85,5 @@ struct FSRSSchedulerTests {
}
}
}
// swiftlint:enable identifier_name