Skip to content

Commit f5fabfb

Browse files
committed
refactor(dedup): reduce code duplication from 97 to 10 groups
Eliminated 89 duplicate groups (-2807 lines) across 4 parallel fixer batches: - Centralized VulnerabilityFinding construction and inline blocks - Extracted shared test helpers (create_test_finding, create_test_config, fixtures) - Consolidated internal duplicates in llm.rs, llm_metrics.rs, tickets/, indexer.rs, agent/executor.rs, root_cause_dedup.rs, phase/helpers.rs - Removed production<->test mirror groups where safe CI gate: fmt clean, clippy clean, 2395 tests pass. Final state: 10 groups / 631 lines (0.6%) — meets ≤10 target.
1 parent 6b7fa1b commit f5fabfb

58 files changed

Lines changed: 1259 additions & 1540 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Cargo.lock‎

Lines changed: 73 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/agent/executor.rs‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,30 @@ mod tests {
183183
use crate::agent::sandbox::ToolSandbox;
184184
use crate::agent::tool_schema::ToolRegistry;
185185
use crate::agent::ToolCall;
186+
use crate::llm::{ChatMessage, ChatResponse};
186187
use std::sync::Arc;
187188

189+
async fn setup_tool_execution_test(
190+
registry: &ToolRegistry,
191+
sandbox: &ToolSandbox,
192+
response: &ChatResponse,
193+
messages: Vec<ChatMessage>,
194+
progress_cb: &ProgressCallback,
195+
tmpdir_path: &std::path::Path,
196+
) -> (Vec<String>, Option<std::path::PathBuf>, Option<std::path::PathBuf>, Vec<ChatMessage>) {
197+
execute_tool_calls(
198+
registry,
199+
sandbox,
200+
response,
201+
messages,
202+
progress_cb,
203+
tmpdir_path,
204+
1,
205+
10,
206+
"Turn",
207+
)
208+
.await
209+
}
188210
#[test]
189211
fn test_create_empty_finding() {
190212
let finding = create_empty_finding(
@@ -271,18 +293,14 @@ mod tests {
271293

272294
let messages = vec![ChatMessage::user("test")];
273295

274-
let (tools_used, test_path, compile_path, messages) = execute_tool_calls(
296+
let (tools_used, test_path, compile_path, messages) = setup_tool_execution_test(
275297
&registry,
276298
&sandbox,
277299
&response,
278300
messages,
279301
&progress_cb,
280302
tmpdir.path(),
281-
1,
282-
10,
283-
"Turn",
284-
)
285-
.await;
303+
).await;
286304

287305
assert_eq!(tools_used, vec!["file_read".to_string()]);
288306
assert!(test_path.is_none());
@@ -560,18 +578,14 @@ mod tests {
560578

561579
let messages = vec![ChatMessage::user("test")];
562580

563-
let (tools_used, test_path, compile_path, messages) = execute_tool_calls(
581+
let (tools_used, test_path, compile_path, messages) = setup_tool_execution_test(
564582
&registry,
565583
&sandbox,
566584
&response,
567585
messages,
568586
&progress_cb,
569587
tmpdir.path(),
570-
1,
571-
10,
572-
"Turn",
573-
)
574-
.await;
588+
).await;
575589

576590
assert!(tools_used.is_empty());
577591
assert!(test_path.is_none());

0 commit comments

Comments
 (0)