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:
@@ -60,18 +60,15 @@ pub fn parse_blocks(
|
||||
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
parse_blocks_inner(body, body_offset_lines)
|
||||
}));
|
||||
match result {
|
||||
Ok(out) => Ok(out),
|
||||
Err(_) => {
|
||||
tracing::warn!("parse_blocks panicked on adversarial input; returning empty");
|
||||
Ok((
|
||||
Vec::new(),
|
||||
vec![Warning {
|
||||
kind: WarningKind::ExtractFailed,
|
||||
note: "pulldown-cmark panicked; body discarded".to_string(),
|
||||
}],
|
||||
))
|
||||
}
|
||||
if let Ok(out) = result { Ok(out) } else {
|
||||
tracing::warn!("parse_blocks panicked on adversarial input; returning empty");
|
||||
Ok((
|
||||
Vec::new(),
|
||||
vec![Warning {
|
||||
kind: WarningKind::ExtractFailed,
|
||||
note: "pulldown-cmark panicked; body discarded".to_string(),
|
||||
}],
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,9 +99,7 @@ fn parse_blocks_inner(body: &[u8], body_offset_lines: u32) -> (Vec<ParsedBlock>,
|
||||
// possibly-inverted spans would be more harmful than dropping output.
|
||||
if state.overflow_detected {
|
||||
let at = state
|
||||
.overflow_at_body_line
|
||||
.map(|n| n.to_string())
|
||||
.unwrap_or_else(|| "?".to_string());
|
||||
.overflow_at_body_line.map_or_else(|| "?".to_string(), |n| n.to_string());
|
||||
return (
|
||||
Vec::new(),
|
||||
vec![Warning {
|
||||
@@ -339,10 +334,10 @@ impl InlineBuf {
|
||||
// `Inline::Link.text` field. Code/strong/emph inside a link are
|
||||
// collapsed to their plain text — `Inline::Link` doesn't model
|
||||
// formatting inside the link.
|
||||
let flat = if !text.is_empty() {
|
||||
text
|
||||
} else {
|
||||
let flat = if text.is_empty() {
|
||||
flatten_inlines_to_text(&kids)
|
||||
} else {
|
||||
text
|
||||
};
|
||||
self.push_inline(Inline::Link { text: flat, href });
|
||||
}
|
||||
@@ -364,10 +359,10 @@ impl InlineBuf {
|
||||
InlineFrame::Strong(kids) => self.push_inline(Inline::Strong { children: kids }),
|
||||
InlineFrame::Emph(kids) => self.push_inline(Inline::Emph { children: kids }),
|
||||
InlineFrame::Link { href, text, kids } => {
|
||||
let flat = if !text.is_empty() {
|
||||
text
|
||||
} else {
|
||||
let flat = if text.is_empty() {
|
||||
flatten_inlines_to_text(&kids)
|
||||
} else {
|
||||
text
|
||||
};
|
||||
self.push_inline(Inline::Link { text: flat, href });
|
||||
}
|
||||
@@ -528,20 +523,17 @@ impl<'a> WalkState<'a> {
|
||||
// inverted span. Without this guard, debug builds panic with
|
||||
// "attempt to add with overflow" (caught by `catch_unwind`, masking
|
||||
// the real cause) and release builds wrap to `start > end`.
|
||||
match (
|
||||
if let (Some(start), Some(end)) = (
|
||||
start_body.checked_add(self.body_offset_lines),
|
||||
end_body.checked_add(self.body_offset_lines),
|
||||
) {
|
||||
(Some(start), Some(end)) => SourceSpan::Line { start, end },
|
||||
_ => {
|
||||
if !self.overflow_detected {
|
||||
self.overflow_detected = true;
|
||||
self.overflow_at_body_line = Some(start_body);
|
||||
}
|
||||
SourceSpan::Line {
|
||||
start: start_body.saturating_add(self.body_offset_lines),
|
||||
end: end_body.saturating_add(self.body_offset_lines),
|
||||
}
|
||||
) { SourceSpan::Line { start, end } } else {
|
||||
if !self.overflow_detected {
|
||||
self.overflow_detected = true;
|
||||
self.overflow_at_body_line = Some(start_body);
|
||||
}
|
||||
SourceSpan::Line {
|
||||
start: start_body.saturating_add(self.body_offset_lines),
|
||||
end: end_body.saturating_add(self.body_offset_lines),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -677,11 +669,11 @@ impl<'a> WalkState<'a> {
|
||||
}
|
||||
Event::Start(Tag::Strong) => {
|
||||
self.flag_non_image_in_paragraph();
|
||||
self.with_current_inlines(|buf| buf.open_strong());
|
||||
self.with_current_inlines(InlineBuf::open_strong);
|
||||
}
|
||||
Event::Start(Tag::Emphasis) => {
|
||||
self.flag_non_image_in_paragraph();
|
||||
self.with_current_inlines(|buf| buf.open_emph());
|
||||
self.with_current_inlines(InlineBuf::open_emph);
|
||||
}
|
||||
Event::Start(Tag::Link { dest_url, .. }) => {
|
||||
self.flag_non_image_in_paragraph();
|
||||
@@ -991,13 +983,13 @@ impl<'a> WalkState<'a> {
|
||||
}
|
||||
}
|
||||
Event::End(TagEnd::Strong) => {
|
||||
self.with_current_inlines(|buf| buf.close_strong());
|
||||
self.with_current_inlines(InlineBuf::close_strong);
|
||||
}
|
||||
Event::End(TagEnd::Emphasis) => {
|
||||
self.with_current_inlines(|buf| buf.close_emph());
|
||||
self.with_current_inlines(InlineBuf::close_emph);
|
||||
}
|
||||
Event::End(TagEnd::Link) => {
|
||||
self.with_current_inlines(|buf| buf.close_link());
|
||||
self.with_current_inlines(InlineBuf::close_link);
|
||||
}
|
||||
Event::End(TagEnd::Image) => {
|
||||
if let Some(Frame::Paragraph { image_depth, .. }) = self.frames.last_mut() {
|
||||
@@ -1480,8 +1472,7 @@ mod tests {
|
||||
inl,
|
||||
Inline::Text { .. } | Inline::Code { .. } | Inline::Link { .. } | Inline::Strong { .. } | Inline::Emph { .. }
|
||||
),
|
||||
"unexpected inline kind: {:?}",
|
||||
inl
|
||||
"unexpected inline kind: {inl:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1503,7 +1494,7 @@ mod tests {
|
||||
// First item should contain "a" plus a flattened rendering
|
||||
// of the nested sub-list.
|
||||
let flat = flatten_inlines_to_text(&items[0]);
|
||||
assert!(flat.contains("a"), "first item missing 'a': {flat:?}");
|
||||
assert!(flat.contains('a'), "first item missing 'a': {flat:?}");
|
||||
assert!(flat.contains("- x"), "first item missing '- x': {flat:?}");
|
||||
assert!(flat.contains("- y"), "first item missing '- y': {flat:?}");
|
||||
let flat2 = flatten_inlines_to_text(&items[1]);
|
||||
|
||||
Reference in New Issue
Block a user