Skip to content

Commit b1648ed

Browse files
committed
fix: resolve all clippy warnings (collapsible_if, from_str rename)
1 parent 622ae84 commit b1648ed

6 files changed

Lines changed: 20 additions & 28 deletions

File tree

src/backend/qwen.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ fn play_wav(path: &Path) -> Result<Child> {
108108

109109
/// Remove orphaned `audio_*.wav` files from the current working directory.
110110
fn cleanup_cwd_wav() {
111-
if let Ok(dir) = std::env::current_dir() {
112-
if let Ok(entries) = std::fs::read_dir(&dir) {
111+
if let Ok(dir) = std::env::current_dir()
112+
&& let Ok(entries) = std::fs::read_dir(&dir) {
113113
for entry in entries.flatten() {
114114
let name = entry.file_name();
115115
let name_str = name.to_string_lossy();
@@ -118,7 +118,6 @@ fn cleanup_cwd_wav() {
118118
}
119119
}
120120
}
121-
}
122121
}
123122

124123
impl TtsBackend for QwenBackend {

src/chat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fn speak_text(text: &str, config: &ChatConfig) -> Result<()> {
152152
fn is_exit(text: &str) -> bool {
153153
let lower = text.to_lowercase();
154154
let trimmed = lower.trim().trim_end_matches(['.', '!', '?']);
155-
EXIT_WORDS.iter().any(|w| trimmed == *w)
155+
EXIT_WORDS.contains(&trimmed)
156156
}
157157

158158
pub fn run_chat_loop(config: ChatConfig) -> Result<()> {

src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl Gender {
2020
}
2121
}
2222

23-
pub fn from_str(s: &str) -> anyhow::Result<Self> {
23+
pub fn parse(s: &str) -> anyhow::Result<Self> {
2424
match s {
2525
"feminine" => Ok(Gender::Feminine),
2626
"masculine" => Ok(Gender::Masculine),
@@ -51,7 +51,7 @@ impl IntonationStyle {
5151
}
5252
}
5353

54-
pub fn from_str(s: &str) -> anyhow::Result<Self> {
54+
pub fn parse(s: &str) -> anyhow::Result<Self> {
5555
match s {
5656
"calm" => Ok(IntonationStyle::Calm),
5757
"energetic" => Ok(IntonationStyle::Energetic),

src/db.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ pub fn set_preference(conn: &Connection, key: &str, value: &str) -> Result<()> {
115115
// Validate specific keys
116116
match key {
117117
"gender" => {
118-
config::Gender::from_str(value)?;
118+
config::Gender::parse(value)?;
119119
}
120120
"style" => {
121-
config::IntonationStyle::from_str(value)?;
121+
config::IntonationStyle::parse(value)?;
122122
}
123123
"rate" => {
124124
value

src/init.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,21 @@ pub fn claude_md_has_vox(content: &str) -> bool {
4848

4949
/// Checks whether a parsed settings.json already has a vox hook.
5050
pub fn has_vox_hook(settings: &Value) -> bool {
51-
if let Some(hooks) = settings.get("hooks") {
52-
if let Some(stop) = hooks.get("Stop") {
53-
if let Some(arr) = stop.as_array() {
51+
if let Some(hooks) = settings.get("hooks")
52+
&& let Some(stop) = hooks.get("Stop")
53+
&& let Some(arr) = stop.as_array() {
5454
for entry in arr {
55-
if let Some(inner_hooks) = entry.get("hooks") {
56-
if let Some(inner_arr) = inner_hooks.as_array() {
55+
if let Some(inner_hooks) = entry.get("hooks")
56+
&& let Some(inner_arr) = inner_hooks.as_array() {
5757
for h in inner_arr {
58-
if let Some(cmd) = h.get("command").and_then(|c| c.as_str()) {
59-
if cmd.starts_with("vox ") {
58+
if let Some(cmd) = h.get("command").and_then(|c| c.as_str())
59+
&& cmd.starts_with("vox ") {
6060
return true;
6161
}
62-
}
6362
}
6463
}
65-
}
6664
}
6765
}
68-
}
69-
}
7066
false
7167
}
7268

@@ -100,8 +96,8 @@ pub fn build_settings(existing: Option<&str>) -> Result<String> {
10096
}
10197

10298
// Merge hooks
103-
if let Some(new_hooks) = vox_hook.get("hooks") {
104-
if let Some(new_stop) = new_hooks.get("Stop") {
99+
if let Some(new_hooks) = vox_hook.get("hooks")
100+
&& let Some(new_stop) = new_hooks.get("Stop") {
105101
let base_obj = base
106102
.as_object_mut()
107103
.context("settings.json is not an object")?;
@@ -115,13 +111,11 @@ pub fn build_settings(existing: Option<&str>) -> Result<String> {
115111
let stop_arr = hooks_map
116112
.entry("Stop")
117113
.or_insert_with(|| Value::Array(vec![]));
118-
if let Some(arr) = stop_arr.as_array_mut() {
119-
if let Some(new_entries) = new_stop.as_array() {
114+
if let Some(arr) = stop_arr.as_array_mut()
115+
&& let Some(new_entries) = new_stop.as_array() {
120116
arr.extend(new_entries.clone());
121117
}
122-
}
123118
}
124-
}
125119

126120
base
127121
}

src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,13 @@ fn handle_speak(cli: Cli) -> Result<()> {
156156
let mut ref_text = None;
157157
let mut effective_backend = backend_name.clone();
158158

159-
if let Some(ref voice_name) = voice {
160-
if let Some(vc) = clone::resolve_voice(&conn, voice_name)? {
159+
if let Some(ref voice_name) = voice
160+
&& let Some(vc) = clone::resolve_voice(&conn, voice_name)? {
161161
ref_audio = Some(vc.ref_audio);
162162
ref_text = vc.ref_text;
163163
effective_backend = "qwen".to_string();
164164
voice = None; // don't pass clone name as --voice
165165
}
166-
}
167166

168167
let backend = backend::get_backend(&effective_backend)?;
169168

0 commit comments

Comments
 (0)