Skip to content

Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more

fix regression test lint

altic-dev16cabf7323d1
diff --git a/Tests/DictationDefaultProviderTests.swift b/Tests/DictationDefaultProviderTests.swift
index 21386b3f..160c59db 100644
--- a/Tests/DictationDefaultProviderTests.swift
+++ b/Tests/DictationDefaultProviderTests.swift
@@ -11,8 +11,10 @@ enum DictationDefaultProviderTests {
static func main() {
func resolve(_ selection: SettingsStore.DictationPromptSelection, _ global: String, _ provider: String = "", _ model: String = "") -> String {
DictationDefaultProvider.providerID(
- selection: selection, configuration: .init(providerID: provider, modelName: model),
- selectedProviderID: global, privateProviderID: "fluid-1"
+ selection: selection,
+ configuration: .init(providerID: provider, modelName: model),
+ selectedProviderID: global,
+ privateProviderID: "fluid-1"
)
}
precondition(resolve(.off, "openai", "openrouter", "model") == "")
diff --git a/Tests/HistoryPresentationTests.swift b/Tests/HistoryPresentationTests.swift
index 866771c8..fe7c4908 100644
--- a/Tests/HistoryPresentationTests.swift
+++ b/Tests/HistoryPresentationTests.swift
@@ -15,21 +15,44 @@ enum PrivateAIModelRegistry {
@main
struct HistoryPresentationTests {
static func main() throws {
- let audio = DictationAudioMetadata(fileName: "saved.wav", durationMilliseconds: 10300,
- byteCount: 331000, sampleRate: 16000, channels: 1, model: nil)
- let enhanced = TranscriptionHistoryEntry(rawText: " raw words ", processedText: " final words ",
- appName: "Notes", windowTitle: "", wasAIProcessed: true, processingModel: "historical-model",
- transcriptionDurationMilliseconds: 57,
- aiProcessingDurationMilliseconds: 104, aiTokensPerSecond: 746,
- audio: audio)
+ let audio = DictationAudioMetadata(
+ fileName: "saved.wav",
+ durationMilliseconds: 10_300,
+ byteCount: 331_000,
+ sampleRate: 16_000,
+ channels: 1,
+ model: nil
+ )
+ let enhanced = TranscriptionHistoryEntry(
+ rawText: " raw words ",
+ processedText: " final words ",
+ appName: "Notes",
+ windowTitle: "",
+ wasAIProcessed: true,
+ processingModel: "historical-model",
+ transcriptionDurationMilliseconds: 57,
+ aiProcessingDurationMilliseconds: 104,
+ aiTokensPerSecond: 746,
+ audio: audio
+ )
let before = enhanced
precondition(enhanced.clipboardText == "final words")
precondition(enhanced == before, "Reading copy text must not mutate an entry")
- let raw = TranscriptionHistoryEntry(rawText: " raw words ", processedText: " ",
- appName: "Notes", windowTitle: "", wasAIProcessed: false)
+ let raw = TranscriptionHistoryEntry(
+ rawText: " raw words ",
+ processedText: " ",
+ appName: "Notes",
+ windowTitle: "",
+ wasAIProcessed: false
+ )
precondition(raw.clipboardText == "raw words")
- let empty = TranscriptionHistoryEntry(rawText: " ", processedText: " ",
- appName: "Notes", windowTitle: "", wasAIProcessed: false)
+ let empty = TranscriptionHistoryEntry(
+ rawText: " ",
+ processedText: " ",
+ appName: "Notes",
+ windowTitle: "",
+ wasAIProcessed: false
+ )
precondition(empty.clipboardText == nil)
let decoded = try JSONDecoder().decode(TranscriptionHistoryEntry.self, from: JSONEncoder().encode(enhanced))
precondition(decoded == enhanced, "Presentation must preserve persisted fields")
@@ -47,16 +70,20 @@ struct HistoryPresentationTests {
("வணக்கம் 👋🏽 café", "வணக்கம் 👋🏽 Café!"),
]
for (original, final) in cases {
- let diff = HistoryTextDiff.compare(original: original, final: final)!
+ guard let diff = HistoryTextDiff.compare(original: original, final: final) else {
+ preconditionFailure("Expected a bounded comparison")
+ }
precondition(diff.original.map(\.text).joined() == original)
precondition(diff.final.map(\.text).joined() == final)
precondition(diff.hasChanges == (original != final))
}
- let replacement = HistoryTextDiff.compare(original: "red blue", final: "green blue")!
+ guard let replacement = HistoryTextDiff.compare(original: "red blue", final: "green blue") else {
+ preconditionFailure("Expected a replacement comparison")
+ }
precondition(replacement.original.filter(\.changed).map(\.text).joined() == "red")
precondition(replacement.final.filter(\.changed).map(\.text).joined() == "green")
precondition(HistoryTextDiff.compare(original: String(repeating: "a ", count: 2000), final: "") == nil)
- precondition(HistoryTextDiff.compare(original: String(repeating: "x", count: 24001), final: "") == nil)
+ precondition(HistoryTextDiff.compare(original: String(repeating: "x", count: 24_001), final: "") == nil)
precondition(ModelDisplayName.forID("mini-internal") == "Fluid 1 Mini")
precondition(ModelDisplayName.forID("legacy-mini") == "Fluid 1 Mini")
precondition(ModelDisplayName.forID(" mini-internal ") == "Fluid 1 Mini")
diff --git a/Tests/ProviderModelVerificationStoreTests.swift b/Tests/ProviderModelVerificationStoreTests.swift
index 2c1d32fd..36220424 100644
--- a/Tests/ProviderModelVerificationStoreTests.swift
+++ b/Tests/ProviderModelVerificationStoreTests.swift
@@ -4,7 +4,9 @@ import Foundation
enum ProviderModelVerificationStoreTests {
@MainActor
static func main() {
- let defaults = UserDefaults(suiteName: "fluidvoice.model-verification-tests.\(UUID().uuidString)")!
+ guard let defaults = UserDefaults(suiteName: "fluidvoice.model-verification-tests.\(UUID().uuidString)") else {
+ preconditionFailure("Could not create isolated test defaults")
+ }
defer { defaults.removeObject(forKey: ProviderModelVerificationStore.defaultsKey) }
let store = ProviderModelVerificationStore(defaults: defaults)
func identity(_ model: String, key: String = "secret", endpoint: String = "https://example.com/v1", provider: String = "openrouter") -> String {
@@ -28,7 +30,9 @@ enum ProviderModelVerificationStoreTests {
for index in 0..<300 {
store.recordSuccess(identity("model-\(index)"), now: Date(timeIntervalSince1970: Double(index)))
}
- let saved = defaults.dictionary(forKey: ProviderModelVerificationStore.defaultsKey)!
+ guard let saved = defaults.dictionary(forKey: ProviderModelVerificationStore.defaultsKey) else {
+ preconditionFailure("Expected persisted verifications")
+ }
precondition(saved.count == ProviderModelVerificationStore.maximumEntries)
precondition(saved.keys.allSatisfy { $0.count == 64 && !$0.contains("secret") })
precondition(!store.contains(identity("model-0")) && store.contains(identity("model-299")))
diff --git a/Tests/StatsSnapshotTests.swift b/Tests/StatsSnapshotTests.swift
index 299a15f3..f4d4e8ad 100644
--- a/Tests/StatsSnapshotTests.swift
+++ b/Tests/StatsSnapshotTests.swift
@@ -4,16 +4,33 @@ import Foundation
struct StatsSnapshotTests {
static func main() async throws {
var calendar = Calendar(identifier: .gregorian)
- calendar.timeZone = TimeZone(identifier: "America/Los_Angeles")!
+ guard let timeZone = TimeZone(identifier: "America/Los_Angeles") else {
+ preconditionFailure("Missing test time zone")
+ }
+ calendar.timeZone = timeZone
func date(_ day: Int, month: Int = 9) -> Date {
- calendar.date(from: DateComponents(year: 2026, month: month, day: day, hour: 12))!
+ guard let value = calendar.date(from: DateComponents(year: 2026, month: month, day: day, hour: 12)) else {
+ preconditionFailure("Invalid test date")
+ }
+ return value
}
func entry(_ day: Int, text: String, app: String = "Notes", ai: Bool = false, month: Int = 9) -> TranscriptionHistoryEntry {
- TranscriptionHistoryEntry(timestamp: date(day, month: month), rawText: "raw must not count", processedText: text,
- appName: app, windowTitle: "", wasAIProcessed: ai)
+ TranscriptionHistoryEntry(
+ timestamp: date(day, month: month),
+ rawText: "raw must not count",
+ processedText: text,
+ appName: app,
+ windowTitle: "",
+ wasAIProcessed: ai
+ )
}
- let entries = [entry(7, text: "one two\nthree", ai: true), entry(7, text: "four", app: ""),
- entry(6, text: "five six"), entry(4, text: "seven"), entry(3, text: "eight")]
+ let entries = [
+ entry(7, text: "one two\nthree", ai: true),
+ entry(7, text: "four", app: ""),
+ entry(6, text: "five six"),
+ entry(4, text: "seven"),
+ entry(3, text: "eight"),
+ ]
let original = entries
let snapshot = try StatsSnapshot.build(entries: entries, now: date(7), calendar: calendar)
precondition(entries == original, "Summary must not mutate history")
@@ -24,7 +41,7 @@ struct StatsSnapshotTests {
precondition(snapshot.currentStreak == 2, "Settings projection must not alter cached summary")
precondition(snapshot.longestTranscriptionWords == 3 && snapshot.mostWordsInDay == 4 && snapshot.mostTranscriptionsInDay == 2)
precondition(snapshot.dailyWordCounts(days: 7).count == 7 && snapshot.activity.count == 30)
- precondition(snapshot.activity.last!.words == 4 && snapshot.activity.reduce(0) { $0 + $1.words } == 8)
+ precondition(snapshot.activity.last?.words == 4 && snapshot.activity.reduce(0) { $0 + $1.words } == 8)
precondition(snapshot.topAppsFormatted(limit: 3) == ["Notes", "Unknown"])
precondition(snapshot.formattedTimeSaved(typingWPM: 0) == "< 1m")
precondition(snapshot.formattedTimeSaved(typingWPM: 200) == "< 1m")
@@ -40,7 +57,7 @@ struct StatsSnapshotTests {
let large = Array(repeating: entry(7, text: String(repeating: "word ", count: 100)), count: 9000)
let start = Date()
let big = try StatsSnapshot.build(entries: large, now: date(7), calendar: calendar)
- precondition(big.totalWords == 900000 && big.longestTranscriptionWords == 100 && big.activity.count == 30)
+ precondition(big.totalWords == 900_000 && big.longestTranscriptionWords == 100 && big.activity.count == 30)
print("9,000-entry / 900,000-word summary: \(Int(Date().timeIntervalSince(start) * 1000)) ms off-main workload")
let cancelled = Task.detached {
try await Task.sleep(nanoseconds: 50_000_000)