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:
@@ -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!(
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -2,7 +2,7 @@ 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
|
||||
@@ -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")))]
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ fn assert_localhost_llm_csp() {
|
||||
let tokens: Vec<&str> = connect_src.split_whitespace().collect();
|
||||
for required in ["http://127.0.0.1:*", "ws://127.0.0.1:*"] {
|
||||
assert!(
|
||||
tokens.iter().any(|t| *t == required),
|
||||
tokens.contains(&required),
|
||||
"build.rs: tauri.conf.json CSP connect-src must permit {required} \
|
||||
for local LLM connectivity (brief item #2). Current connect-src: \
|
||||
{connect_src:?}"
|
||||
|
||||
@@ -247,7 +247,7 @@ pub async fn generate_diagnostic_report(
|
||||
.map(|d| d.as_secs())
|
||||
.unwrap_or(0);
|
||||
out.push_str(&format!("- Generated: unix `{}`\n", now));
|
||||
out.push_str("\n");
|
||||
out.push('\n');
|
||||
out.push_str(
|
||||
"> This report is local-only until you choose to share it. \
|
||||
Review the contents below before sending to anyone.\n\n",
|
||||
|
||||
@@ -1155,12 +1155,10 @@ fn longest_common_token_subsequence(a: &[&str], b: &[&str]) -> usize {
|
||||
}
|
||||
|
||||
fn is_low_signal_token(token: &str) -> bool {
|
||||
LOW_SIGNAL_TOKENS
|
||||
.iter()
|
||||
.any(|low_signal| *low_signal == token)
|
||||
LOW_SIGNAL_TOKENS.contains(&token)
|
||||
}
|
||||
|
||||
fn meaningful_tokens<'a>(text: &'a str) -> Vec<&'a str> {
|
||||
fn meaningful_tokens(text: &str) -> Vec<&str> {
|
||||
text.split_whitespace()
|
||||
.filter(|token| !token.is_empty() && token.len() > 1 && !is_low_signal_token(token))
|
||||
.collect()
|
||||
|
||||
@@ -412,7 +412,7 @@ pub fn detect_active_compute_device() -> ActiveComputeDevice {
|
||||
reason: None,
|
||||
};
|
||||
}
|
||||
return ActiveComputeDevice {
|
||||
ActiveComputeDevice {
|
||||
kind: "cpu".into(),
|
||||
label: "CPU (fallback)".into(),
|
||||
reason: Some(
|
||||
@@ -420,7 +420,7 @@ pub fn detect_active_compute_device() -> ActiveComputeDevice {
|
||||
libvulkan1 (Linux) to enable GPU acceleration."
|
||||
.into(),
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -345,7 +345,7 @@ fn classify_terminal(raw: &str) -> Option<String> {
|
||||
fn detect_focused_window_class() -> Option<String> {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
return detect_focused_window_class_linux();
|
||||
detect_focused_window_class_linux()
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
|
||||
@@ -234,7 +234,7 @@ pub fn run() {
|
||||
// Runtime-warning banner: push CPU-feature + Vulkan-loader
|
||||
// fallbacks to the frontend so Settings can render a one-line
|
||||
// hint. No-ops on a fully-supported box.
|
||||
crate::commands::models::emit_runtime_warnings(&app.handle());
|
||||
crate::commands::models::emit_runtime_warnings(app.handle());
|
||||
|
||||
if let Err(e) = tray::setup(app) {
|
||||
eprintln!("Failed to setup tray: {e}");
|
||||
|
||||
Reference in New Issue
Block a user