Skip to content

Commit 384be4c

Browse files
committed
fix: resolve clippy warnings for Rust 1.93.0
- Remove unused imports across test modules and examples - Fix duplicated #[test] attributes in config.rs - Replace filter_map with map where all branches return Some - Replace vec![] with array literals for non-growing collections - Use rfind instead of filter().last() on DoubleEndedIterator - Allow dead_code on ToolEntry.description (stored for future use) - Allow clippy::large_enum_variant on SandboxState - Allow clippy::assertions_on_constants in compaction tests - Use or_default() instead of or_insert_with(VecDeque::new) - Remove needless borrows for generic args
1 parent fd543eb commit 384be4c

16 files changed

Lines changed: 32 additions & 48 deletions

core/examples/default_implementations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async fn main() -> anyhow::Result<()> {
4949
println!(" - Max file size: 1MB\n");
5050

5151
// 4. Set up HITL confirmation
52-
let (event_tx, mut event_rx) = broadcast::channel(256);
52+
let (event_tx, _event_rx) = broadcast::channel(256);
5353
let hitl_policy = ConfirmationPolicy::enabled()
5454
.with_timeout(30_000, a3s_code_core::hitl::TimeoutAction::Reject);
5555
let confirmation_manager = Arc::new(ConfirmationManager::new(hitl_policy, event_tx.clone()));
@@ -60,7 +60,7 @@ async fn main() -> anyhow::Result<()> {
6060
println!(" - Timeout action: Reject\n");
6161

6262
// 5. Create session with all default implementations
63-
let session = agent.session(
63+
let _session = agent.session(
6464
".",
6565
Some(
6666
SessionOptions::new()

core/examples/sdk_chat.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,22 @@ async fn main() -> anyhow::Result<()> {
108108
let preview = msg
109109
.content
110110
.iter()
111-
.filter_map(|b| match b {
111+
.map(|b| match b {
112112
ContentBlock::Text { text } => {
113113
let trimmed = text.trim();
114114
if trimmed.len() > 60 {
115-
Some(format!("{}...", &trimmed[..60]))
115+
format!("{}...", &trimmed[..60])
116116
} else {
117-
Some(trimmed.to_string())
117+
trimmed.to_string()
118118
}
119119
}
120-
ContentBlock::ToolUse { name, .. } => Some(format!("[tool_use: {}]", name)),
120+
ContentBlock::ToolUse { name, .. } => format!("[tool_use: {}]", name),
121121
ContentBlock::ToolResult { content, .. } => {
122122
let text = content.as_text();
123123
let truncated = &text[..text.len().min(40)];
124-
Some(format!("[tool_result: {}]", truncated))
124+
format!("[tool_result: {}]", truncated)
125125
}
126-
ContentBlock::Image { .. } => Some("[image]".to_string()),
126+
ContentBlock::Image { .. } => "[image]".to_string(),
127127
})
128128
.collect::<Vec<_>>()
129129
.join(" | ");

core/examples/test_auto_compact.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//!
66
//! Run with: cargo run --example test_auto_compact
77
8-
use a3s_code_core::{Agent, AgentEvent, SessionOptions};
8+
use a3s_code_core::{Agent, SessionOptions};
99
use anyhow::Result;
1010
use std::path::PathBuf;
1111

core/examples/test_parallel_processing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async fn main() -> Result<()> {
4949
let agent = Agent::new(config_path.to_str().unwrap()).await?;
5050
let session = agent.session(".", None)?;
5151

52-
let tasks = vec![
52+
let tasks = [
5353
"Count the number of Rust files in this project",
5454
"Find all TODO comments in Rust files",
5555
"List all public functions in src/lib.rs",
@@ -97,7 +97,7 @@ async fn main() -> Result<()> {
9797

9898
let session = agent.session(".", Some(opts))?;
9999

100-
let tasks = vec![
100+
let tasks = [
101101
"Count the number of Rust files in this project",
102102
"Find all TODO comments in Rust files",
103103
"List all public functions in src/lib.rs",
@@ -178,7 +178,7 @@ async fn main() -> Result<()> {
178178
let start = Instant::now();
179179

180180
// Mix of different task types
181-
let tasks = vec![
181+
let tasks = [
182182
("Query", "How many Rust files are there?"),
183183
("Query", "What is the project structure?"),
184184
("Query", "List all dependencies"),
@@ -245,7 +245,7 @@ async fn main() -> Result<()> {
245245
println!(" Initial delay: 100ms");
246246
println!(" Strategy: exponential");
247247

248-
let tasks = vec![
248+
let tasks = [
249249
"Analyze the main function",
250250
"Find all error types",
251251
"List all test functions",

core/examples/test_task_priority.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ async fn test_late_urgent_insertion(agent: &Agent) -> Result<()> {
357357
.map(|r| r.completed_at);
358358
let last_exec_completed = sorted
359359
.iter()
360-
.filter(|r| r.lane.contains("P2"))
361-
.last()
360+
.rfind(|r| r.lane.contains("P2"))
362361
.map(|r| r.completed_at);
363362

364363
if let (Some(urgent), Some(last_exec)) = (urgent_completed, last_exec_completed) {

core/examples/test_vector_rag.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55
//!
66
//! Run with: cargo run --example test_vector_rag
77
8-
use a3s_code_core::context::embedding::OpenAiEmbeddingProvider;
9-
use a3s_code_core::context::vector_store::InMemoryVectorStore;
10-
use a3s_code_core::context::{VectorContextConfig, VectorContextProvider};
118
use a3s_code_core::{Agent, SessionOptions};
129
use anyhow::Result;
1310
use std::path::PathBuf;
14-
use std::sync::Arc;
1511
use tempfile::TempDir;
1612

1713
fn find_config() -> PathBuf {

core/src/agent.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4340,7 +4340,6 @@ mod tests {
43404340
mod extra_agent_tests {
43414341
use super::*;
43424342
use crate::agent::tests::MockLlmClient;
4343-
use crate::llm::{ContentBlock, StreamEvent};
43444343
use crate::queue::SessionQueueConfig;
43454344
use crate::tools::ToolExecutor;
43464345
use std::path::PathBuf;

core/src/config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,6 @@ mod tests {
792792
assert_eq!(models.len(), 3);
793793
}
794794

795-
#[test]
796795
#[test]
797796
fn test_config_from_file_not_found() {
798797
let result = CodeConfig::from_file(Path::new("/nonexistent/config.json"));
@@ -1096,7 +1095,6 @@ mod tests {
10961095
);
10971096
}
10981097

1099-
#[test]
11001098
#[test]
11011099
fn test_code_config_default_provider_config() {
11021100
let config = CodeConfig {

core/src/llm/tests.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ mod tests {
44
use crate::llm::http::normalize_base_url;
55
use crate::llm::openai::*;
66
use crate::llm::*;
7-
use crate::retry::RetryConfig;
8-
use std::sync::Arc;
97

108
#[test]
119
fn test_secret_string_redacts_debug() {
@@ -501,8 +499,6 @@ mod extra_llm_tests {
501499
use crate::llm::http::normalize_base_url;
502500
use crate::llm::openai::*;
503501
use crate::llm::*;
504-
use crate::retry::RetryConfig;
505-
use std::sync::Arc;
506502

507503
#[test]
508504
fn test_message_assistant_text() {
@@ -2026,7 +2022,6 @@ mod extra_llm_tests3 {
20262022
use crate::llm::openai::*;
20272023
use crate::llm::*;
20282024
use crate::retry::RetryConfig;
2029-
use std::sync::Arc;
20302025

20312026
// ========================================================================
20322027
// OpenAiClient convert_messages - Additional Coverage
@@ -2776,7 +2771,7 @@ mod multimodal_tests {
27762771
fn test_attachment_from_file_jpeg() {
27772772
let dir = tempfile::tempdir().unwrap();
27782773
let path = dir.path().join("test.jpg");
2779-
std::fs::write(&path, &[0xFF, 0xD8, 0xFF]).unwrap();
2774+
std::fs::write(&path, [0xFF, 0xD8, 0xFF]).unwrap();
27802775
let a = Attachment::from_file(&path).unwrap();
27812776
assert_eq!(a.media_type, "image/jpeg");
27822777
assert_eq!(a.data, vec![0xFF, 0xD8, 0xFF]);
@@ -2786,7 +2781,7 @@ mod multimodal_tests {
27862781
fn test_attachment_from_file_png() {
27872782
let dir = tempfile::tempdir().unwrap();
27882783
let path = dir.path().join("test.png");
2789-
std::fs::write(&path, &[0x89, 0x50]).unwrap();
2784+
std::fs::write(&path, [0x89, 0x50]).unwrap();
27902785
let a = Attachment::from_file(&path).unwrap();
27912786
assert_eq!(a.media_type, "image/png");
27922787
}
@@ -2795,7 +2790,7 @@ mod multimodal_tests {
27952790
fn test_attachment_from_file_unknown_ext() {
27962791
let dir = tempfile::tempdir().unwrap();
27972792
let path = dir.path().join("test.bin");
2798-
std::fs::write(&path, &[0x00]).unwrap();
2793+
std::fs::write(&path, [0x00]).unwrap();
27992794
let a = Attachment::from_file(&path).unwrap();
28002795
assert_eq!(a.media_type, "application/octet-stream");
28012796
}

core/src/sandbox.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ mod box_impl {
103103
use std::sync::Arc;
104104
use tokio::sync::Mutex;
105105

106+
#[allow(clippy::large_enum_variant)]
106107
enum SandboxState {
107108
NotStarted,
108109
Running(Sandbox),

0 commit comments

Comments
 (0)