fix(lint): resolve 35 clippy warnings across Rust codebase

Fix all clippy warnings reported by `cargo clippy --lib`:

- codex_config.rs: fix doc_overindented_list_items (3 spaces -> 2)
- commands/copilot.rs: inline format args in 2 log::error! calls
- commands/provider.rs: inline format args in 3 map_err closures
- proxy/hyper_client.rs: inline format arg in log::debug! call
- proxy/providers/copilot_auth.rs: inline format args in 16 locations
  (log macros, format! in headers, error constructors)
- proxy/thinking_optimizer.rs: inline format args in 2 log::info! calls
- services/skill.rs: inline format args in log::debug! call
- services/webdav_sync.rs: inline format args in 6 format! calls
  (version compat messages, download limit messages)
- services/webdav_sync/archive.rs: inline format args in 2 format! calls
- session_manager/providers/opencode.rs: inline format args in
  source_path format!

All fixes use the clippy::uninlined_format_args suggestion pattern:
  format!("msg: {}", var)  ->  format!("msg: {var}")
This commit is contained in:
YoVinchen
2026-03-27 15:45:09 +08:00
parent 4084b53834
commit 49f66bcc9a
10 changed files with 35 additions and 52 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ pub fn read_and_validate_codex_config_text() -> Result<String, AppError> {
///
/// Supported fields:
/// - `"base_url"`: writes to `[model_providers.<current>].base_url` if `model_provider` exists,
/// otherwise falls back to top-level `base_url`.
/// otherwise falls back to top-level `base_url`.
/// - `"model"`: writes to top-level `model` field.
///
/// Empty value removes the field.
+2 -2
View File
@@ -49,7 +49,7 @@ pub async fn copilot_poll_for_auth(
Ok(false)
}
Err(e) => {
log::error!("[CopilotAuth] 轮询失败: {}", e);
log::error!("[CopilotAuth] 轮询失败: {e}");
Err(e.to_string())
}
}
@@ -70,7 +70,7 @@ pub async fn copilot_poll_for_account(
Ok(None)
}
Err(e) => {
log::error!("[CopilotAuth] 轮询失败: {}", e);
log::error!("[CopilotAuth] 轮询失败: {e}");
Err(e.to_string())
}
}
+3 -3
View File
@@ -159,7 +159,7 @@ pub async fn queryProviderUsage(
let providers = state
.db
.get_all_providers(app_type.as_str())
.map_err(|e| format!("Failed to get providers: {}", e))?;
.map_err(|e| format!("Failed to get providers: {e}"))?;
let provider = providers.get(&providerId);
let is_copilot = provider
@@ -182,11 +182,11 @@ pub async fn queryProviderUsage(
Some(account_id) => auth_manager
.fetch_usage_for_account(account_id)
.await
.map_err(|e| format!("Failed to fetch Copilot usage: {}", e))?,
.map_err(|e| format!("Failed to fetch Copilot usage: {e}"))?,
None => auth_manager
.fetch_usage()
.await
.map_err(|e| format!("Failed to fetch Copilot usage: {}", e))?,
.map_err(|e| format!("Failed to fetch Copilot usage: {e}"))?,
};
let premium = &usage.quota_snapshots.premium_interactions;
let used = premium.entitlement - premium.remaining;
+1 -4
View File
@@ -154,10 +154,7 @@ pub async fn send_request(
// Transfer extensions from the incoming request — this carries the internal
// `HeaderCaseMap` that tells the hyper client how to case each header name.
// Debug: check extension count before transfer
log::debug!(
"[HyperClient] Transferring extensions to outgoing request (uri={})",
uri
);
log::debug!("[HyperClient] Transferring extensions to outgoing request (uri={uri})");
*req.extensions_mut() = original_extensions;
let client = global_hyper_client();
+16 -23
View File
@@ -338,7 +338,7 @@ impl CopilotAuthManager {
// 尝试从磁盘加载(同步,不发起网络请求)
if let Err(e) = manager.load_from_disk_sync() {
log::warn!("[CopilotAuth] 加载存储失败: {}", e);
log::warn!("[CopilotAuth] 加载存储失败: {e}");
}
manager
@@ -361,7 +361,7 @@ impl CopilotAuthManager {
/// 移除指定账号
pub async fn remove_account(&self, account_id: &str) -> Result<(), CopilotAuthError> {
log::info!("[CopilotAuth] 移除账号: {}", account_id);
log::info!("[CopilotAuth] 移除账号: {account_id}");
{
let mut accounts = self.accounts.write().await;
@@ -475,8 +475,7 @@ impl CopilotAuthManager {
let status = response.status();
let text = response.text().await.unwrap_or_default();
return Err(CopilotAuthError::NetworkError(format!(
"GitHub 设备码请求失败: {} - {}",
status, text
"GitHub 设备码请求失败: {status} - {text}"
)));
}
@@ -574,10 +573,7 @@ impl CopilotAuthManager {
}
// 需要刷新
log::info!(
"[CopilotAuth] 账号 {} 的 Copilot Token 需要刷新",
account_id
);
log::info!("[CopilotAuth] 账号 {account_id} 的 Copilot Token 需要刷新");
let refresh_lock = self.get_refresh_lock(account_id).await;
let _refresh_guard = refresh_lock.lock().await;
@@ -632,12 +628,12 @@ impl CopilotAuthManager {
) -> Result<Vec<CopilotModel>, CopilotAuthError> {
let copilot_token = self.get_valid_token_for_account(account_id).await?;
log::info!("[CopilotAuth] 获取账号 {} 的 Copilot 可用模型", account_id);
log::info!("[CopilotAuth] 获取账号 {account_id} 的 Copilot 可用模型");
let response = self
.http_client
.get(COPILOT_MODELS_URL)
.header("Authorization", format!("Bearer {}", copilot_token))
.header("Authorization", format!("Bearer {copilot_token}"))
.header("Content-Type", "application/json")
.header("copilot-integration-id", "vscode-chat")
.header("editor-version", COPILOT_EDITOR_VERSION)
@@ -651,8 +647,7 @@ impl CopilotAuthManager {
let status = response.status();
let text = response.text().await.unwrap_or_default();
return Err(CopilotAuthError::CopilotTokenFetchFailed(format!(
"获取模型列表失败: {} - {}",
status, text
"获取模型列表失败: {status} - {text}"
)));
}
@@ -699,12 +694,12 @@ impl CopilotAuthManager {
.ok_or_else(|| CopilotAuthError::AccountNotFound(account_id.to_string()))?
};
log::info!("[CopilotAuth] 获取账号 {} 的 Copilot 使用量", account_id);
log::info!("[CopilotAuth] 获取账号 {account_id} 的 Copilot 使用量");
let response = self
.http_client
.get(COPILOT_USAGE_URL)
.header("Authorization", format!("token {}", github_token))
.header("Authorization", format!("token {github_token}"))
.header("Content-Type", "application/json")
.header("editor-version", COPILOT_EDITOR_VERSION)
.header("editor-plugin-version", COPILOT_PLUGIN_VERSION)
@@ -721,8 +716,7 @@ impl CopilotAuthManager {
let status = response.status();
let text = response.text().await.unwrap_or_default();
return Err(CopilotAuthError::CopilotTokenFetchFailed(format!(
"获取使用量失败: {} - {}",
status, text
"获取使用量失败: {status} - {text}"
)));
}
@@ -950,7 +944,7 @@ impl CopilotAuthManager {
let response = self
.http_client
.get(GITHUB_USER_URL)
.header("Authorization", format!("token {}", github_token))
.header("Authorization", format!("token {github_token}"))
.header("User-Agent", COPILOT_USER_AGENT)
.header("Editor-Version", COPILOT_EDITOR_VERSION)
.header("Editor-Plugin-Version", COPILOT_PLUGIN_VERSION)
@@ -977,12 +971,12 @@ impl CopilotAuthManager {
github_token: &str,
account_id: &str,
) -> Result<(), CopilotAuthError> {
log::debug!("[CopilotAuth] 获取账号 {} 的 Copilot Token", account_id);
log::debug!("[CopilotAuth] 获取账号 {account_id} 的 Copilot Token");
let response = self
.http_client
.get(COPILOT_TOKEN_URL)
.header("Authorization", format!("token {}", github_token))
.header("Authorization", format!("token {github_token}"))
.header("User-Agent", COPILOT_USER_AGENT)
.header("Editor-Version", COPILOT_EDITOR_VERSION)
.header("Editor-Plugin-Version", COPILOT_PLUGIN_VERSION)
@@ -1001,8 +995,7 @@ impl CopilotAuthManager {
let status = response.status();
let text = response.text().await.unwrap_or_default();
return Err(CopilotAuthError::CopilotTokenFetchFailed(format!(
"{}: {}",
status, text
"{status}: {text}"
)));
}
@@ -1085,7 +1078,7 @@ impl CopilotAuthManager {
.fetch_copilot_token_with_github_token(&legacy_token, &account_id)
.await
{
log::warn!("[CopilotAuth] 迁移时验证 Copilot 订阅失败: {}", e);
log::warn!("[CopilotAuth] 迁移时验证 Copilot 订阅失败: {e}");
}
// 添加账号
@@ -1099,7 +1092,7 @@ impl CopilotAuthManager {
"Legacy Copilot auth migration failed: {e}"
)))
.await;
log::warn!("[CopilotAuth] 迁移失败,旧 token 可能已失效: {}", e);
log::warn!("[CopilotAuth] 迁移失败,旧 token 可能已失效: {e}");
}
}
+2 -2
View File
@@ -25,7 +25,7 @@ pub fn optimize(body: &mut Value, config: &OptimizerConfig) {
}
if model.contains("opus-4-6") || model.contains("sonnet-4-6") {
log::info!("[OPT] thinking: adaptive({})", model);
log::info!("[OPT] thinking: adaptive({model})");
body["thinking"] = json!({"type": "adaptive"});
body["output_config"] = json!({"effort": "max"});
append_beta(body, "context-1m-2025-08-07");
@@ -33,7 +33,7 @@ pub fn optimize(body: &mut Value, config: &OptimizerConfig) {
}
// legacy path
log::info!("[OPT] thinking: legacy({})", model);
log::info!("[OPT] thinking: legacy({model})");
let max_tokens = body
.get("max_tokens")
+1 -1
View File
@@ -957,7 +957,7 @@ impl SkillService {
if source_path.is_none() {
source_path = Some(skill_path);
}
log::debug!("Skill '{}' found in source '{}'", dir_name, label);
log::debug!("Skill '{dir_name}' found in source '{label}'");
}
}
+6 -13
View File
@@ -463,12 +463,10 @@ fn validate_manifest_compat(manifest: &SyncManifest, layout: RemoteLayout) -> Re
return Err(localized(
"webdav.sync.manifest_db_version_incompatible",
format!(
"远端数据库快照版本不兼容: db-v{} (本地 db-v{DB_COMPAT_VERSION})",
db_compat_version
"远端数据库快照版本不兼容: db-v{db_compat_version} (本地 db-v{DB_COMPAT_VERSION})"
),
format!(
"Remote database snapshot version is incompatible: db-v{} (local db-v{DB_COMPAT_VERSION})",
db_compat_version
"Remote database snapshot version is incompatible: db-v{db_compat_version} (local db-v{DB_COMPAT_VERSION})"
),
));
}
@@ -476,12 +474,10 @@ fn validate_manifest_compat(manifest: &SyncManifest, layout: RemoteLayout) -> Re
return Err(localized(
"webdav.sync.manifest_db_version_incompatible",
format!(
"远端数据库快照版本不兼容: db-v{} (本地最高支持 db-v{DB_COMPAT_VERSION})",
db_compat_version
"远端数据库快照版本不兼容: db-v{db_compat_version} (本地最高支持 db-v{DB_COMPAT_VERSION})"
),
format!(
"Remote database snapshot version is incompatible: db-v{} (local supports up to db-v{DB_COMPAT_VERSION})",
db_compat_version
"Remote database snapshot version is incompatible: db-v{db_compat_version} (local supports up to db-v{DB_COMPAT_VERSION})"
),
));
}
@@ -661,11 +657,8 @@ fn validate_artifact_size_limit(artifact_name: &str, size: u64) -> Result<(), Ap
let max_mb = MAX_SYNC_ARTIFACT_BYTES / 1024 / 1024;
return Err(localized(
"webdav.sync.artifact_too_large",
format!("artifact {artifact_name} 超过下载上限({} MB", max_mb),
format!(
"Artifact {artifact_name} exceeds download limit ({} MB)",
max_mb
),
format!("artifact {artifact_name} 超过下载上限({max_mb} MB"),
format!("Artifact {artifact_name} exceeds download limit ({max_mb} MB)"),
));
}
Ok(())
@@ -350,8 +350,8 @@ fn copy_entry_with_total_limit<R: Read, W: Write>(
let max_mb = max_total_bytes / 1024 / 1024;
return Err(localized(
"webdav.sync.skills_zip_too_large",
format!("skills.zip 解压后体积超过上限({} MB", max_mb),
format!("skills.zip extracted size exceeds limit ({} MB)", max_mb),
format!("skills.zip 解压后体积超过上限({max_mb} MB"),
format!("skills.zip extracted size exceeds limit ({max_mb} MB)"),
));
}
@@ -148,7 +148,7 @@ fn scan_sessions_sqlite() -> Vec<SessionMeta> {
},
created_at: Some(created),
last_active_at: Some(updated),
source_path: Some(format!("sqlite:{}:{}", db_display, session_id)),
source_path: Some(format!("sqlite:{db_display}:{session_id}")),
resume_command: Some(format!("opencode session resume {session_id}")),
});
}