Skip to content

Commit ec4e4f4

Browse files
committed
cleanup: remove dead code and unnecessary allow(dead_code) annotations
1 parent d201070 commit ec4e4f4

3 files changed

Lines changed: 1 addition & 116 deletions

File tree

src/cortex-app-server/src/storage.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ pub struct StoredToolCall {
4747

4848
/// Session storage manager.
4949
pub struct SessionStorage {
50-
#[allow(dead_code)]
51-
base_dir: PathBuf,
5250
sessions_dir: PathBuf,
5351
history_dir: PathBuf,
5452
}
@@ -66,7 +64,6 @@ impl SessionStorage {
6664
info!("Session storage initialized at {:?}", base_dir);
6765

6866
Ok(Self {
69-
base_dir,
7067
sessions_dir,
7168
history_dir,
7269
})

src/cortex-apply-patch/src/hunk.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@ pub struct SearchReplace {
250250
pub search: String,
251251
/// The text to replace with.
252252
pub replace: String,
253-
/// Replace all occurrences (true) or just the first (false).
254-
#[allow(dead_code)]
255-
pub replace_all: bool,
256253
}
257254

258255
impl SearchReplace {
@@ -266,16 +263,8 @@ impl SearchReplace {
266263
path: path.into(),
267264
search: search.into(),
268265
replace: replace.into(),
269-
replace_all: false,
270266
}
271267
}
272-
273-
/// Set whether to replace all occurrences.
274-
#[allow(dead_code)]
275-
pub fn with_replace_all(mut self, replace_all: bool) -> Self {
276-
self.replace_all = replace_all;
277-
self
278-
}
279268
}
280269

281270
#[cfg(test)]

src/cortex-mcp-client/src/transport.rs

Lines changed: 1 addition & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ use cortex_mcp_types::{
2020
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
2121
use tokio::process::{Child, Command};
2222
use tokio::sync::{Mutex, RwLock};
23-
use tokio::time::sleep;
24-
use tracing::{debug, error, info, warn};
23+
use tracing::{debug, info, warn};
2524

2625
// ============================================================================
2726
// Transport Trait
@@ -199,61 +198,6 @@ impl StdioTransport {
199198
Ok(())
200199
}
201200

202-
/// Reconnect with exponential backoff.
203-
///
204-
/// Properly cleans up existing connections before each attempt to prevent
205-
/// file descriptor leaks (#2198).
206-
#[allow(dead_code)]
207-
async fn reconnect(&self) -> Result<()> {
208-
if !self.reconnect_config.enabled {
209-
return Err(anyhow!("Reconnection disabled"));
210-
}
211-
212-
let mut attempt = 0;
213-
let mut delay = self.reconnect_config.initial_delay;
214-
215-
while attempt < self.reconnect_config.max_attempts {
216-
attempt += 1;
217-
info!(
218-
attempt,
219-
max = self.reconnect_config.max_attempts,
220-
"Attempting reconnection"
221-
);
222-
223-
// Clean up any existing connection before attempting reconnect
224-
// This prevents file descriptor leaks on repeated failures (#2198)
225-
{
226-
let mut process_guard = self.process.lock().await;
227-
if let Some(mut child) = process_guard.take() {
228-
// Kill the process and wait for it to clean up
229-
let _ = child.kill().await;
230-
// Wait a short time for resources to be released
231-
drop(child);
232-
}
233-
self.connected.store(false, Ordering::SeqCst);
234-
}
235-
236-
// Clear any stale pending responses
237-
self.pending_responses.write().await.clear();
238-
239-
match self.connect().await {
240-
Ok(()) => {
241-
info!("Reconnection successful");
242-
return Ok(());
243-
}
244-
Err(e) => {
245-
error!(error = %e, attempt, "Reconnection failed");
246-
if attempt < self.reconnect_config.max_attempts {
247-
sleep(delay).await;
248-
delay = (delay * 2).min(self.reconnect_config.max_delay);
249-
}
250-
}
251-
}
252-
}
253-
254-
Err(anyhow!("Failed to reconnect after {} attempts", attempt))
255-
}
256-
257201
/// Send a request and wait for response.
258202
async fn send_request(&self, request: JsonRpcRequest) -> Result<JsonRpcResponse> {
259203
// Ensure connected
@@ -516,51 +460,6 @@ impl HttpTransport {
516460
fn next_request_id(&self) -> RequestId {
517461
RequestId::Number(self.request_id.fetch_add(1, Ordering::SeqCst) as i64)
518462
}
519-
520-
/// Test connection.
521-
#[allow(dead_code)]
522-
async fn test_connection(&self) -> Result<()> {
523-
let request = JsonRpcRequest::new(self.next_request_id(), methods::PING);
524-
self.send_request(request).await?;
525-
Ok(())
526-
}
527-
528-
/// Reconnect with exponential backoff.
529-
#[allow(dead_code)]
530-
async fn reconnect(&self) -> Result<()> {
531-
if !self.reconnect_config.enabled {
532-
return Err(anyhow!("Reconnection disabled"));
533-
}
534-
535-
let mut attempt = 0;
536-
let mut delay = self.reconnect_config.initial_delay;
537-
538-
while attempt < self.reconnect_config.max_attempts {
539-
attempt += 1;
540-
info!(
541-
attempt,
542-
max = self.reconnect_config.max_attempts,
543-
"Attempting HTTP reconnection"
544-
);
545-
546-
match self.test_connection().await {
547-
Ok(()) => {
548-
info!("HTTP reconnection successful");
549-
self.connected.store(true, Ordering::SeqCst);
550-
return Ok(());
551-
}
552-
Err(e) => {
553-
error!(error = %e, attempt, "HTTP reconnection failed");
554-
if attempt < self.reconnect_config.max_attempts {
555-
sleep(delay).await;
556-
delay = (delay * 2).min(self.reconnect_config.max_delay);
557-
}
558-
}
559-
}
560-
}
561-
562-
Err(anyhow!("Failed to reconnect after {} attempts", attempt))
563-
}
564463
}
565464

566465
#[async_trait]

0 commit comments

Comments
 (0)