chore(lint): clean up clippy warnings across workspace

Auto-applied cargo clippy --fix across 11 files — needless return,
unnecessary cast, map_or simplification, repeat().take() → repeat_n(),
iter().any() → contains(), manual char comparison, lifetime elision,
push_str single-char, reference immediately dereferenced.

Also fixed three lints on file_storage.rs manually: two doc-list-item
overindentations, plus the same needless-return. Baseline main was
not clippy-clean with -D warnings before; after this pass one
needless_range_loop warning remains (live.rs:1089) that clippy's
suggested rewrite would make less readable — left for a dedicated
refactor session.

Build + workspace tests remain green (245 passing, 0 failing, 1
ignored).
This commit is contained in:
2026-04-24 09:43:56 +01:00
parent 9b0067b4c0
commit fe61661305
11 changed files with 20 additions and 22 deletions

View File

@@ -112,7 +112,7 @@ impl MicrophoneCapture {
for device in devices {
let name = device_display_name(&device).unwrap_or_else(|| "<unnamed>".to_string());
let (sample_rate, channels) = match device.default_input_config() {
Ok(cfg) => (cfg.sample_rate(), cfg.channels() as u16),
Ok(cfg) => (cfg.sample_rate(), cfg.channels()),
Err(_) => (0, 0),
};
let is_likely_monitor = is_monitor_name(&name);
@@ -278,7 +278,7 @@ fn device_display_name(device: &cpal::Device) -> Option<String> {
fn extract_card_id(name: &str) -> Option<&str> {
let rest = name.split("CARD=").nth(1)?;
Some(
rest.split(|c: char| c == ',' || c == ';')
rest.split([',', ';'])
.next()
.unwrap_or(rest),
)
@@ -361,7 +361,7 @@ fn open_and_validate(
.default_input_config()
.map_err(|e| KonError::AudioCaptureFailed(format!("default_input_config: {e}")))?;
let sample_rate = config.sample_rate();
let channels = config.channels() as u16;
let channels = config.channels();
let format = config.sample_format();
eprintln!(

View File

@@ -343,14 +343,14 @@ async fn device_listener(
fn is_event_device(path: &Path) -> bool {
path.file_name()
.and_then(|n| n.to_str())
.map_or(false, |n| n.starts_with("event"))
.is_some_and(|n| n.starts_with("event"))
}
/// Return true when the device's reported key set includes the combo's
/// configured trigger key. A device that reports no keys at all (for
/// example a mouse whose `EV_KEY` capability is buttons only) is rejected.
fn device_supports_combo(supported: Option<&AttributeSetRef<Key>>, combo: &HotkeyCombo) -> bool {
supported.map_or(false, |keys| keys.contains(Key::new(combo.key_code)))
supported.is_some_and(|keys| keys.contains(Key::new(combo.key_code)))
}
#[cfg(test)]

View File

@@ -2,11 +2,11 @@ use std::path::PathBuf;
/// Resolve the per-user app data directory, following each OS's convention:
///
/// - Windows: `%LOCALAPPDATA%\kon\` e.g. `C:\Users\Jake\AppData\Local\kon`
/// - Windows: `%LOCALAPPDATA%\kon\` e.g. `C:\Users\Jake\AppData\Local\kon`
/// - macOS: `~/Library/Application Support/Kon/`
/// - Linux: `$XDG_DATA_HOME/kon` or `~/.local/share/kon` (XDG Base Directory),
/// with a fallback to the legacy `~/.kon/` if it already exists, so
/// existing installs keep working.
/// with a fallback to the legacy `~/.kon/` if it already exists, so
/// existing installs keep working.
/// - Other Unix: `~/.kon/`
///
/// TODO: Consolidate with `crates/transcription/src/model_manager.rs::dirs_path()`
@@ -45,7 +45,7 @@ pub fn app_data_dir() -> PathBuf {
return PathBuf::from(xdg).join("kon");
}
}
return PathBuf::from(home).join(".local").join("share").join("kon");
PathBuf::from(home).join(".local").join("share").join("kon")
}
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]

View File

@@ -158,7 +158,7 @@ mod tests {
let mut total_pushed: u64 = 0;
let tentative_per_cycle: u64 = 200;
for _ in 0..100 {
buf.extend(std::iter::repeat(0.25_f32).take(16_000));
buf.extend(std::iter::repeat_n(0.25_f32, 16_000));
total_pushed += 16_000;
let commit_point = total_pushed - tentative_per_cycle;
start = trim_buffer_to_commit_point(&mut buf, start, commit_point);
@@ -199,7 +199,7 @@ mod tests {
// Simulate a capture buffer that has received 1.2 s of audio
// starting at t=0.
let mut buf: Vec<f32> = std::iter::repeat(0.1_f32).take(19_200).collect();
let mut buf: Vec<f32> = std::iter::repeat_n(0.1_f32, 19_200).collect();
let new_start = trim_buffer_to_commit_point(&mut buf, 0, commit_idx);
assert_eq!(new_start, 8_000);
assert_eq!(buf.len(), 19_200 - 8_000);

View File

@@ -306,7 +306,7 @@ impl VadChunker for RmsVadChunker {
.saturating_sub(self.pending.len() as u64);
let pad_len = FRAME_SAMPLES - self.pending.len();
let mut padded = std::mem::take(&mut self.pending);
padded.extend(std::iter::repeat(0.0_f32).take(pad_len));
padded.extend(std::iter::repeat_n(0.0_f32, pad_len));
if let Some(chunk) = self.consume_frame(padded, frame_start) {
emitted.push(chunk);
}