chore(lint): SwiftLint-Config + 0-Warnings-Pass + Swift-6-Concurrency-Fixes

Bringt cards-native auf 0 SwiftLint-Violations bei 75 Files. Build-Status
unverändert grün (xcodebuild iOS Debug).

.swiftlint.yml
- identifier_name excludes erweitert um math/index-Konventionen
  (i, j, n, m, x, y, w, h, r, g, b, a, c, d, s, f, p, q, t, l) —
  in algorithmischem Code klarer als verbose
- opening_brace disabled — kollidiert mit SwiftFormats
  wrapMultilineStatementBraces (SwiftFormat ist im Pre-Commit-Hook
  und gewinnt)

Code-Modernisierungen (real, nicht nur Annotations)
- Cloze.swift: regex-Tuple bekommt `swiftlint:disable large_tuple`-
  Region — Regex-Output-Type ist Builder-bedingt nicht reduzierbar
- Media.swift: `data(using: .utf8)` → `Data(s.utf8)` (non-failable),
  `String(data:as:)` → `String(bytes:encoding:)`
- CardsTheme.swift: HSL-Wert-Typ statt anonymes 3-Tupel —
  konkretere Call-Sites, kein `large_tuple`-Warning mehr
- MediaCache.swift: `CacheEntry`-Struct statt 3-Tupel im Prune-Pfad
- GradeQueue / MediaCache / StudySession / MarketplaceStore: OSLog-
  Interpolations auf lokale Variablen ziehen — fixt Swift-6-Strict-
  Concurrency-Fail bei Actor-isolated-Property-Zugriff aus
  @Sendable-Autoclosure
- DeckMutations.swift, MarketplaceModeration.swift: verschachtelte
  VersionInfo-Sub-Types auf Top-Level (`PullUpdateVersion`,
  `OwnedMarketplaceVersion`) — fixt `nesting`-Warning
- Tests/UnitTests/*.swift: alle `""".data(using: .utf8)!` migriert auf
  `Data("""…""".utf8)`; force-cast `as!` in MutationEncodingTests
  durch guard-let + throw ersetzt

Pragmatische Disables (mit Doc-Comment-Begründung)
- DeckEditorView / MarketplacePublishView / DeckDetailView /
  PublicDeckView / DeckListView / CardEditorView / CardsAPI:
  `swiftlint:disable type_body_length` (+ teilweise file_length)
  als Region-Disable mit `enable` nach dem Struct. Begründung im
  Doc-Comment: Multi-State-Maschinen mit shared Toolbar + Sheets;
  Aufspalten würde nur @Binding-Plumbing produzieren

Auto-Format-Aufräumung
- Redundante `Sendable`-Conformance entfernt (Swift 6 leitet das
  bei Wert-Typen mit Sendable-Mitgliedern automatisch ab)
- EnvironmentValues nutzt jetzt @Entry-Macro statt manueller
  EnvironmentKey-Boilerplate
- Brace-Reformatting + Import-Sortierung auf allen 75 Files

Ergebnis: 80 Warnings + 3 Errors → 0 / 0.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-05-14 02:04:29 +02:00
parent 73f9081fa1
commit aece169360
37 changed files with 489 additions and 349 deletions

View file

@ -11,16 +11,16 @@ import SwiftUI
/// - Background hsl(--color-surface)
/// - Aspect-Ratio 5/7 für `.md` und `.hero`, fix für `.lg`
struct CardSurface<Content: View>: View {
enum Size: Sendable {
case md // Deck-Tile in der Liste (max-width 18rem)
case lg // Fan-Detail (12rem x 16.8rem)
case hero // Study-Lernkarte (max-width 24rem)
enum Size {
case md // Deck-Tile in der Liste (max-width 18rem)
case lg // Fan-Detail (12rem x 16.8rem)
case hero // Study-Lernkarte (max-width 24rem)
}
enum Elevation: Sendable {
case flat // Subtle shadow
enum Elevation {
case flat // Subtle shadow
case standard // Default Karten-Shadow
case raised // Study-Hero
case raised // Study-Hero
}
let size: Size
@ -73,9 +73,9 @@ struct CardSurface<Content: View>: View {
private var maxWidth: CGFloat? {
switch size {
case .md: 288 // 18rem
case .lg: 192 // 12rem
case .hero: 384 // 24rem
case .md: 288 // 18rem
case .lg: 192 // 12rem
case .hero: 384 // 24rem
}
}

View file

@ -1,11 +1,13 @@
import SwiftUI
#if canImport(UIKit)
import UIKit
private typealias PlatformColorType = UIColor
import UIKit
private typealias PlatformColorType = UIColor
#elseif canImport(AppKit)
import AppKit
private typealias PlatformColorType = NSColor
import AppKit
private typealias PlatformColorType = NSColor
#endif
/// Forest-Theme aus `mana/packages/themes/src/variants/forest.css`.
@ -16,56 +18,67 @@ private typealias PlatformColorType = NSColor
/// `mana/docs/MANA_SWIFT.md` bis dahin lebt forest hier.
enum CardsTheme {
/// Page-Hintergrund
static let background = dynamic(light: (0, 0, 100), dark: (142, 30, 8))
static let background = dynamic(light: HSL(0, 0, 100), dark: HSL(142, 30, 8))
/// Standard-Text
static let foreground = dynamic(light: (142, 30, 12), dark: (142, 15, 95))
static let foreground = dynamic(light: HSL(142, 30, 12), dark: HSL(142, 15, 95))
/// Card, Panel, Modal
static let surface = dynamic(light: (142, 25, 98), dark: (142, 25, 12))
static let surface = dynamic(light: HSL(142, 25, 98), dark: HSL(142, 25, 12))
/// Hover-State auf Surface
static let surfaceHover = dynamic(light: (142, 20, 95), dark: (142, 20, 16))
static let surfaceHover = dynamic(light: HSL(142, 20, 95), dark: HSL(142, 20, 16))
/// Disabled-Felder, Skeleton
static let muted = dynamic(light: (142, 15, 93), dark: (142, 18, 18))
static let muted = dynamic(light: HSL(142, 15, 93), dark: HSL(142, 18, 18))
/// Sekundär-Text, Placeholder
static let mutedForeground = dynamic(light: (142, 10, 42), dark: (142, 12, 65))
static let mutedForeground = dynamic(light: HSL(142, 10, 42), dark: HSL(142, 12, 65))
/// Rahmen, Trennlinien
static let border = dynamic(light: (142, 15, 88), dark: (142, 18, 22))
static let border = dynamic(light: HSL(142, 15, 88), dark: HSL(142, 18, 22))
/// Cards-Brand-Grün Tiefgrün im Light, leuchtender im Dark
static let primary = dynamic(light: (142, 76, 28), dark: (142, 71, 45))
static let primary = dynamic(light: HSL(142, 76, 28), dark: HSL(142, 71, 45))
/// Text auf Primary
static let primaryForeground = dynamic(light: (0, 0, 100), dark: (142, 30, 8))
static let primaryForeground = dynamic(light: HSL(0, 0, 100), dark: HSL(142, 30, 8))
static let error = dynamic(light: (0, 84, 60), dark: (0, 63, 55))
static let success = dynamic(light: (142, 71, 45), dark: (142, 71, 45))
static let warning = dynamic(light: (38, 92, 50), dark: (48, 96, 53))
static let error = dynamic(light: HSL(0, 84, 60), dark: HSL(0, 63, 55))
static let success = dynamic(light: HSL(142, 71, 45), dark: HSL(142, 71, 45))
static let warning = dynamic(light: HSL(38, 92, 50), dark: HSL(48, 96, 53))
// MARK: - HSL Helper
private static func dynamic(
light: (Double, Double, Double),
dark: (Double, Double, Double)
) -> Color {
let lightColor = fromHSL(light.0, light.1, light.2)
let darkColor = fromHSL(dark.0, dark.1, dark.2)
/// Hue/Saturation/Lightness als Wert-Typ. HSL ist konkreter als ein
/// 3-Tupel und macht die Call-Sites lesbar.
struct HSL {
let hue: Double
let saturation: Double
let lightness: Double
init(_ hue: Double, _ saturation: Double, _ lightness: Double) {
self.hue = hue
self.saturation = saturation
self.lightness = lightness
}
}
private static func dynamic(light: HSL, dark: HSL) -> Color {
let lightColor = fromHSL(light.hue, light.saturation, light.lightness)
let darkColor = fromHSL(dark.hue, dark.saturation, dark.lightness)
#if canImport(UIKit)
return Color(uiColor: UIColor { trait in
trait.userInterfaceStyle == .dark ? darkColor : lightColor
})
return Color(uiColor: UIColor { trait in
trait.userInterfaceStyle == .dark ? darkColor : lightColor
})
#elseif canImport(AppKit)
return Color(nsColor: NSColor(name: nil) { appearance in
let isDark = appearance.bestMatch(from: [.darkAqua, .vibrantDark]) != nil
return isDark ? darkColor : lightColor
})
return Color(nsColor: NSColor(name: nil) { appearance in
let isDark = appearance.bestMatch(from: [.darkAqua, .vibrantDark]) != nil
return isDark ? darkColor : lightColor
})
#else
return Color(red: 0, green: 0, blue: 0)
return Color(red: 0, green: 0, blue: 0)
#endif
}