Skip to content

Commit 5dcdfcd

Browse files
committed
fix clippy warnings
1 parent c07797b commit 5dcdfcd

8 files changed

Lines changed: 21 additions & 19 deletions

File tree

src/api/anthropic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl AnthropicClient {
163163

164164
let line = line.trim_end();
165165
let json_str = match line.strip_prefix("data: ") {
166-
Some(s) if s == "[DONE]" => continue,
166+
Some("[DONE]") => continue,
167167
Some(s) => s,
168168
None => continue,
169169
};

src/error_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ mod tests {
7373
fn test_with_context() {
7474
let result: std::io::Result<()> = Err(io::Error::new(io::ErrorKind::NotFound, "test"));
7575
let err = result
76-
.with_context(|| format!("Failed to read file: test.txt"))
76+
.with_context(|| "Failed to read file: test.txt".to_string())
7777
.unwrap_err();
7878

7979
assert!(matches!(err, SofosError::Context { .. }));

src/repl/conversation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Show imperial units only when the user explicitly asks for them."#,
208208
let message_tokens: usize = self
209209
.messages
210210
.iter()
211-
.map(|m| Self::estimate_message_tokens(m))
211+
.map(Self::estimate_message_tokens)
212212
.sum();
213213

214214
system_tokens + message_tokens

src/repl/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,8 @@ impl Repl {
524524

525525
if is_400_error && is_image_error && has_images {
526526
println!(
527-
"\n{} {}\n",
528-
"⚠️ Image loading error:".bright_yellow().bold(),
529-
"One or more image URLs in the conversation could not be loaded by the API"
527+
"\n{} One or more image URLs in the conversation could not be loaded by the API\n",
528+
"⚠️ Image loading error:".bright_yellow().bold()
530529
);
531530

532531
self.session_state.conversation.remove_last_message();

src/repl/response_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub struct ResponseHandler {
2828
}
2929

3030
impl ResponseHandler {
31+
#[allow(clippy::too_many_arguments)]
3132
pub fn new(
3233
client: LlmClient,
3334
tool_executor: ToolExecutor,

src/session/history.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,12 @@ mod tests {
331331
SystemPrompt::new_cached_with_ttl("Test system prompt".to_string(), None);
332332

333333
manager
334-
.save_session(&session_id, &messages, &[], &[system_prompt.clone()])
334+
.save_session(
335+
&session_id,
336+
&messages,
337+
&[],
338+
std::slice::from_ref(&system_prompt),
339+
)
335340
.unwrap();
336341

337342
let loaded = manager.load_session(&session_id).unwrap();
@@ -353,7 +358,7 @@ mod tests {
353358
&session_id1,
354359
&[Message::user("First session")],
355360
&[],
356-
&[system_prompt.clone()],
361+
std::slice::from_ref(&system_prompt),
357362
)
358363
.unwrap();
359364

src/tools/image.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ pub fn detect_image_reference(text: &str) -> Option<ImageReference> {
4545
let trimmed = text.trim();
4646

4747
// Strip common trailing punctuation that might be attached to paths in sentences
48-
let cleaned = trimmed.trim_end_matches(|c| matches!(c, '.' | ',' | ';' | ':' | '!' | '?'));
48+
let cleaned = trimmed.trim_end_matches(['.', ',', ';', ':', '!', '?']);
4949

50-
if cleaned.starts_with("http://") || cleaned.starts_with("https://") {
51-
if is_image_url(cleaned) {
52-
return Some(ImageReference::WebUrl(cleaned.to_string()));
53-
}
50+
if (cleaned.starts_with("http://") || cleaned.starts_with("https://")) && is_image_url(cleaned)
51+
{
52+
return Some(ImageReference::WebUrl(cleaned.to_string()));
5453
}
5554

5655
if has_image_extension(cleaned) {
@@ -239,12 +238,12 @@ impl ImageLoader {
239238
pub fn extract_image_references(input: &str) -> (String, Vec<ImageReference>) {
240239
let mut remaining_text = String::new();
241240
let mut references = Vec::new();
242-
let mut chars = input.chars().peekable();
241+
let chars = input.chars();
243242
let mut current_word = String::new();
244243
let mut in_quotes = false;
245244
let mut quote_char = ' ';
246245

247-
while let Some(ch) = chars.next() {
246+
for ch in chars {
248247
match ch {
249248
// Only treat quotes as delimiters if we're at a word boundary (current_word is empty)
250249
// This prevents apostrophes in contractions like "don't" from being treated as quotes

src/tools/permissions.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,8 @@ impl PermissionManager {
481481
if result == CommandPermission::Denied || result == CommandPermission::Ask {
482482
return result;
483483
}
484-
if result == CommandPermission::Allowed {
485-
if self.is_read_explicit_allow(original) {
486-
return CommandPermission::Allowed;
487-
}
484+
if result == CommandPermission::Allowed && self.is_read_explicit_allow(original) {
485+
return CommandPermission::Allowed;
488486
}
489487

490488
let canonical_result = self.check_read_permission(canonical);

0 commit comments

Comments
 (0)