chore: workspace-wide cleanup — clippy::pedantic baseline + auto-fix
cut PR v0.18.0 전 마지막 정리. 사용자 요청: "전체 코드베이스를 깔끔하고 알아보기 쉽게".
## Workspace lints
- `Cargo.toml` 의 `[workspace.lints.clippy]` 에 `pedantic = "warn"` (priority -1) + 의도적 allow-list 추가:
- cast_possible_truncation / cast_possible_wrap / cast_sign_loss / cast_precision_loss — ONNX i64 / hash modular reduction 등 의도적 truncation.
- doc_markdown / missing_errors_doc / missing_panics_doc — cosmetic doc style.
- too_many_lines / module_name_repetitions / must_use_candidate / needless_pass_by_value / manual_let_else / items_after_statements / similar_names — informational only.
- format_collect / match_wildcard_for_single_variants / trivially_copy_pass_by_ref / unnecessary_wraps — intentional patterns (exhaustive match, future Result variants 등).
- default_trait_access — `Foo::default()` 가 idiomatic.
- float_cmp — NLI / RRF score 의 explicit threshold 비교 의도.
- struct_excessive_bools / case_sensitive_file_extension_comparisons / naive_bytecount / ignore_without_reason — domain-specific 의도.
- format_push_string / return_self_not_must_use / match_same_arms — builder / wire-label / hot-path 패턴 보존.
- needless_continue / used_underscore_binding / nonminimal_bool / unreadable_literal / many_single_char_names / doc_link_with_quotes / assigning_clones / collapsible_str_replace / trivial_regex / elidable_lifetime_names / range_plus_one / explicit_iter_loop / implicit_hasher / ref_option — remaining low-value style.
- 각 24 crate `Cargo.toml` 에 `[lints] workspace = true` 추가.
## Auto-fix
`cargo clippy --workspace --all-targets --fix` 적용 — 128 files changed, 552 insertions / 472 deletions. 주로:
- uninlined_format_args (~18): `format!("{}", x)` → `format!("{x}")`.
- redundant_closure_for_method_calls (~33): `.map(|x| x.foo())` → `.map(T::foo)`.
- 그 외 mechanical refactor.
## 검증
- `cargo clippy --workspace --all-targets -j 1 -- -D warnings` clean (pedantic + 모든 lint group).
- `cargo test --workspace --no-fail-fast -j 1` — **1293 tests pass + 1 pre-existing flaky fail** (`kebab-mcp::tools_call_ask_multi_hop::ask_tool_routes_multi_hop_true_to_decompose_first`, HOTFIX candidate, cleanup 무관). 회귀 0.
Wire 영향: 없음.
Behavior 영향: 없음 (mechanical refactor only).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -63,7 +63,7 @@ impl SqliteStore {
|
||||
answer.retrieval.trace_id.0,
|
||||
query,
|
||||
answer.answer,
|
||||
if answer.grounded { 1_i64 } else { 0_i64 },
|
||||
i64::from(answer.grounded),
|
||||
refusal_label,
|
||||
answer.model.id,
|
||||
answer.model.provider,
|
||||
@@ -72,15 +72,15 @@ impl SqliteStore {
|
||||
answer.prompt_template_version.0,
|
||||
mode_label,
|
||||
answer.retrieval.k as i64,
|
||||
answer.retrieval.score_gate as f64,
|
||||
answer.retrieval.top_score as f64,
|
||||
answer.retrieval.chunks_returned as i64,
|
||||
answer.retrieval.chunks_used as i64,
|
||||
f64::from(answer.retrieval.score_gate),
|
||||
f64::from(answer.retrieval.top_score),
|
||||
i64::from(answer.retrieval.chunks_returned),
|
||||
i64::from(answer.retrieval.chunks_used),
|
||||
citations_json,
|
||||
packed_chunks_json,
|
||||
answer.usage.prompt_tokens as i64,
|
||||
answer.usage.completion_tokens as i64,
|
||||
answer.usage.latency_ms as i64,
|
||||
i64::from(answer.usage.prompt_tokens),
|
||||
i64::from(answer.usage.completion_tokens),
|
||||
i64::from(answer.usage.latency_ms),
|
||||
created_at,
|
||||
],
|
||||
)
|
||||
|
||||
@@ -270,12 +270,12 @@ impl kebab_core::DocumentStore for SqliteStore {
|
||||
) -> Result<Option<kebab_core::RawAsset>> {
|
||||
let conn = self.lock_conn();
|
||||
let result = conn.query_row(
|
||||
r#"SELECT
|
||||
r"SELECT
|
||||
asset_id, source_uri, workspace_path, media_type,
|
||||
byte_len, checksum, storage_kind, storage_path,
|
||||
discovered_at
|
||||
FROM assets
|
||||
WHERE asset_id = ?"#,
|
||||
WHERE asset_id = ?",
|
||||
rusqlite::params![id.0.as_str()],
|
||||
asset_from_row,
|
||||
);
|
||||
@@ -292,12 +292,12 @@ impl kebab_core::DocumentStore for SqliteStore {
|
||||
) -> Result<Option<kebab_core::RawAsset>> {
|
||||
let conn = self.lock_conn();
|
||||
let result = conn.query_row(
|
||||
r#"SELECT
|
||||
r"SELECT
|
||||
asset_id, source_uri, workspace_path, media_type,
|
||||
byte_len, checksum, storage_kind, storage_path,
|
||||
discovered_at
|
||||
FROM assets
|
||||
WHERE workspace_path = ?"#,
|
||||
WHERE workspace_path = ?",
|
||||
rusqlite::params![path.0.as_str()],
|
||||
asset_from_row,
|
||||
);
|
||||
@@ -456,7 +456,7 @@ impl kebab_core::DocumentStore for SqliteStore {
|
||||
let mut stmt = conn.prepare(&sql).map_err(StoreError::from)?;
|
||||
let rows = stmt
|
||||
.query_map(
|
||||
rusqlite::params_from_iter(params_dyn.iter().map(|b| b.as_ref())),
|
||||
rusqlite::params_from_iter(params_dyn.iter().map(std::convert::AsRef::as_ref)),
|
||||
doc_summary_from_sql,
|
||||
)
|
||||
.map_err(StoreError::from)?;
|
||||
@@ -774,8 +774,8 @@ fn upsert_document(
|
||||
source_type,
|
||||
trust_level,
|
||||
doc.parser_version.0,
|
||||
doc.doc_version as i64,
|
||||
doc.schema_version as i64,
|
||||
i64::from(doc.doc_version),
|
||||
i64::from(doc.schema_version),
|
||||
metadata_json,
|
||||
provenance_json,
|
||||
created_at,
|
||||
|
||||
@@ -224,7 +224,7 @@ impl SqliteStore {
|
||||
.context("kb-store-sqlite::filter_chunks: prepare SQL")?;
|
||||
let rows = stmt
|
||||
.query_map(
|
||||
params_from_iter(bind.iter().map(|b| b.as_ref())),
|
||||
params_from_iter(bind.iter().map(std::convert::AsRef::as_ref)),
|
||||
|row| {
|
||||
let chunk_id: String = row.get(0)?;
|
||||
let workspace_path: String = row.get(1)?;
|
||||
@@ -594,7 +594,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let mut got: Vec<&str> = out.iter().map(|c| c.0.as_str()).collect();
|
||||
got.sort();
|
||||
got.sort_unstable();
|
||||
assert_eq!(got, vec![chunks[0].0, chunks[2].0, chunks[3].0]);
|
||||
|
||||
// + lang=en → drops c3.
|
||||
@@ -610,7 +610,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let mut got: Vec<&str> = out.iter().map(|c| c.0.as_str()).collect();
|
||||
got.sort();
|
||||
got.sort_unstable();
|
||||
assert_eq!(got, vec![chunks[0].0, chunks[3].0]);
|
||||
|
||||
// + trust_min=Secondary → drops c4 (generated < secondary).
|
||||
@@ -641,7 +641,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let mut got: Vec<&str> = out.iter().map(|c| c.0.as_str()).collect();
|
||||
got.sort();
|
||||
got.sort_unstable();
|
||||
assert_eq!(got, vec![chunks[0].0, chunks[1].0, chunks[2].0]);
|
||||
}
|
||||
|
||||
@@ -795,7 +795,7 @@ mod tests {
|
||||
seed_committed_with_metadata(
|
||||
&store, c3, "d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3",
|
||||
"README.md", r#""markdown""#,
|
||||
r#"{}"#,
|
||||
r"{}",
|
||||
);
|
||||
|
||||
let f = SearchFilters {
|
||||
|
||||
@@ -69,12 +69,12 @@ impl SqliteStore {
|
||||
params![
|
||||
row.run_id,
|
||||
row.scope_json,
|
||||
row.scanned as i64,
|
||||
row.new_count as i64,
|
||||
row.updated_count as i64,
|
||||
row.skipped_count as i64,
|
||||
row.error_count as i64,
|
||||
row.duration_ms as i64,
|
||||
i64::from(row.scanned),
|
||||
i64::from(row.new_count),
|
||||
i64::from(row.updated_count),
|
||||
i64::from(row.skipped_count),
|
||||
i64::from(row.error_count),
|
||||
i64::from(row.duration_ms),
|
||||
started,
|
||||
finished,
|
||||
row.items_json,
|
||||
@@ -191,7 +191,7 @@ impl kebab_core::JobRepo for SqliteStore {
|
||||
let mut stmt = conn.prepare(&sql).map_err(StoreError::from)?;
|
||||
let rows = stmt
|
||||
.query_map(
|
||||
rusqlite::params_from_iter(params_dyn.iter().map(|b| b.as_ref())),
|
||||
rusqlite::params_from_iter(params_dyn.iter().map(std::convert::AsRef::as_ref)),
|
||||
job_row_from_sql,
|
||||
)
|
||||
.map_err(StoreError::from)?;
|
||||
|
||||
@@ -163,7 +163,7 @@ impl SqliteStore {
|
||||
/// safe to reuse — we simply unwrap the inner guard rather than
|
||||
/// propagate the panic to every subsequent call.
|
||||
pub(crate) fn lock_conn(&self) -> MutexGuard<'_, Connection> {
|
||||
self.conn.lock().unwrap_or_else(|p| p.into_inner())
|
||||
self.conn.lock().unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
}
|
||||
|
||||
/// Read-only borrow of the connection.
|
||||
@@ -179,7 +179,7 @@ impl SqliteStore {
|
||||
///
|
||||
/// Poisoning is recovered the same way as [`Self::lock_conn`].
|
||||
pub fn read_conn(&self) -> MutexGuard<'_, Connection> {
|
||||
self.conn.lock().unwrap_or_else(|p| p.into_inner())
|
||||
self.conn.lock().unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
}
|
||||
|
||||
/// Persist a `RawAsset` *with its raw bytes*: row goes into `assets`,
|
||||
@@ -359,9 +359,7 @@ fn temp_path_for(dest: &Path) -> PathBuf {
|
||||
let n = TEMP_SUFFIX_COUNTER.fetch_add(1, Ordering::Relaxed);
|
||||
let parent = dest.parent().unwrap_or_else(|| Path::new("."));
|
||||
let file_name = dest
|
||||
.file_name()
|
||||
.map(|s| s.to_string_lossy().into_owned())
|
||||
.unwrap_or_else(|| "asset".to_string());
|
||||
.file_name().map_or_else(|| "asset".to_string(), |s| s.to_string_lossy().into_owned());
|
||||
parent.join(format!("{file_name}.tmp.{pid}.{n}"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user