fix(rust): resolve all clippy warnings treated as errors in CI

Fix 18 clippy errors across 7 files:
- lib.rs: change doc comment to regular comment (empty line after doc)
- arch_audit.rs: replace format!() with string literal, use is_none_or
- code_quality.rs: collapsible if, map_or → is_none_or
- commit.rs: collapsible match guard
- explore.rs: needless_range_loop → iterator enumerate
- skills.rs: map_or(false,...) → is_some_and
- semantic_search.rs: map_or → is_none_or, sort_by → sort_by_key,
  remove explicit type to avoid type_complexity

CI was failing with 'error: could not compile zesdex-infrastructure
due to 18 previous errors' at clippy step.
This commit is contained in:
Cyrene (Mem)
2026-07-22 14:16:56 +07:00
parent 958645ed7f
commit 6b90c7eb0d
7 changed files with 48 additions and 50 deletions
@@ -181,7 +181,7 @@ fn scan_file(
if trimmed.starts_with("use ") {
for &forbidden in forbidden {
let pattern = format!("use {forbidden}");
if trimmed.starts_with(&pattern) || trimmed.starts_with(&format!("use crate::")) {
if trimmed.starts_with(&pattern) || trimmed.starts_with("use crate::") {
// `use crate::` in domain could reference domain-only items — skip.
continue;
}
@@ -234,11 +234,11 @@ pub fn audit_layering(root: &Path) -> Result<AuditReport> {
let mut files_scanned = 0;
for entry in Walk::new(&apps_dir).flatten() {
if entry.file_type().map_or(true, |ft| !ft.is_file()) {
if entry.file_type().is_none_or(|ft| !ft.is_file()) {
continue;
}
let path = entry.path();
if path.extension().map_or(true, |e| e != "rs") {
if path.extension().is_none_or(|e| e != "rs") {
continue;
}
@@ -146,29 +146,29 @@ pub fn scan_quality_file(file_path: &Path, root: &Path) -> Vec<Finding> {
}
// ── Rule: Missing doc comments on pub items ────────────────────
if trimmed.starts_with("pub ") || trimmed.starts_with("pub(") {
if !prev_line_doc && !prev_line_empty {
// Check it's a struct/enum/fn/trait/type/const/mod
let is_item = trimmed.starts_with("pub fn ")
|| trimmed.starts_with("pub struct ")
|| trimmed.starts_with("pub enum ")
|| trimmed.starts_with("pub trait ")
|| trimmed.starts_with("pub type ")
|| trimmed.starts_with("pub const ")
|| trimmed.starts_with("pub mod ")
|| trimmed.starts_with("pub(crate) fn ")
|| trimmed.starts_with("pub(crate) struct ")
|| trimmed.starts_with("pub(crate) enum ")
|| trimmed.starts_with("pub(crate) trait ");
if is_item {
findings.push(Finding {
severity: super::arch_audit::Severity::Info,
rule: "missing-doc",
file: relative.clone(),
line: line_num,
message: format!("Missing doc comment on pub item: {trimmed}"),
});
}
if (trimmed.starts_with("pub ") || trimmed.starts_with("pub("))
&& !prev_line_doc && !prev_line_empty
{
// Check it's a struct/enum/fn/trait/type/const/mod
let is_item = trimmed.starts_with("pub fn ")
|| trimmed.starts_with("pub struct ")
|| trimmed.starts_with("pub enum ")
|| trimmed.starts_with("pub trait ")
|| trimmed.starts_with("pub type ")
|| trimmed.starts_with("pub const ")
|| trimmed.starts_with("pub mod ")
|| trimmed.starts_with("pub(crate) fn ")
|| trimmed.starts_with("pub(crate) struct ")
|| trimmed.starts_with("pub(crate) enum ")
|| trimmed.starts_with("pub(crate) trait ");
if is_item {
findings.push(Finding {
severity: super::arch_audit::Severity::Info,
rule: "missing-doc",
file: relative.clone(),
line: line_num,
message: format!("Missing doc comment on pub item: {trimmed}"),
});
}
}
@@ -217,11 +217,11 @@ pub fn scan_quality(root: &Path) -> Result<CodeQualityReport> {
let mut files_scanned = 0;
for entry in Walk::new(&apps_dir).flatten() {
if entry.file_type().map_or(true, |ft| !ft.is_file()) {
if entry.file_type().is_none_or(|ft| !ft.is_file()) {
continue;
}
let path = entry.path();
if path.extension().map_or(true, |e| e != "rs") {
if path.extension().is_none_or(|e| e != "rs") {
continue;
}
files_scanned += 1;
@@ -108,13 +108,11 @@ pub fn validate_commit_message(msg: &str) -> Result<(), Vec<String>> {
// Type-specific rules.
match type_ {
"chore" | "docs" | "refactor" | "test" | "style" | "perf" | "ci" | "build"
| "revert" => {
if scope.is_some() {
errors.push(format!(
"'{type_}' commits should not use a scope. \
Only 'feat' and 'fix' require scopes."
));
}
| "revert" if scope.is_some() => {
errors.push(format!(
"'{type_}' commits should not use a scope. \
Only 'feat' and 'fix' require scopes."
));
}
_ => {}
}
@@ -196,14 +196,14 @@ async fn run_explore_phase(
turn_events: &Arc<Mutex<VecDeque<TurnEvent>>>,
) -> Result<String> {
// ── 1. Emit Pending for all agents (appears instantly in workflow tab) ─
for i in 0..EXPLORE_AGENT_COUNT {
emit_pending(turn_events, EXPLORE_IDS[i], EXPLORE_LABELS[i]);
for (i, &id) in EXPLORE_IDS.iter().enumerate() {
emit_pending(turn_events, id, EXPLORE_LABELS[i]);
}
// ── 2. Prepare directives ───────────────────────────────────────────
let mut directives: Vec<String> = Vec::with_capacity(EXPLORE_AGENT_COUNT);
for i in 0..EXPLORE_AGENT_COUNT {
let mut d = EXPLORE_DIRECTIVES[i].to_string();
for (i, &d) in EXPLORE_DIRECTIVES.iter().enumerate() {
let mut d = d.to_string();
if i == 2 {
d.push_str(&format!("\n\nThe user's current query is: \"{query}\""));
}
@@ -35,7 +35,7 @@ impl EmbeddedSkills {
match entry {
DirEntry::Dir(sub) => walk(sub, skills),
DirEntry::File(file) => {
if file.path().file_name().map_or(false, |n| n == "SKILL.md") {
if file.path().file_name().is_some_and(|n| n == "SKILL.md") {
if let Some(parent) = file
.path()
.parent()
+2 -2
View File
@@ -54,8 +54,8 @@ pub use zesdex_domain::*;
use std::path::PathBuf;
use std::sync::Arc;
/// Which kind of caller (main agent vs. subagent vs. reviewer) is
/// invoking a tool, used to scope permissions and tag log/output paths.
// Which kind of caller (main agent vs. subagent vs. reviewer) is
// invoking a tool, used to scope permissions and tag log/output paths.
// ---------------------------------------------------------------------------
// TurnEvent & runtime types have been moved to zesdex_domain::agent
// ---------------------------------------------------------------------------
@@ -286,7 +286,7 @@ impl SymbolIndex {
let walker = ignore::Walk::new(path);
// Pre-compile per-extension dispatch table.
let ext_dispatch: HashMap<&str, fn(&str, &str) -> Vec<CodeSymbol>> = HashMap::from([
let ext_dispatch = HashMap::from([
("rs", extract_rust as fn(&str, &str) -> Vec<CodeSymbol>),
("ts", extract_typescript as fn(&str, &str) -> Vec<CodeSymbol>),
("tsx", extract_typescript as fn(&str, &str) -> Vec<CodeSymbol>),
@@ -385,9 +385,9 @@ impl SymbolIndex {
.symbols
.iter()
.filter(|s| {
language_filter.as_ref().map_or(true, |l| s.language == *l)
&& kind_filter.as_ref().map_or(true, |k| s.kind == *k)
&& file_filter.map_or(true, |f| s.file.contains(f))
language_filter.as_ref().is_none_or(|l| s.language == *l)
&& kind_filter.as_ref().is_none_or(|k| s.kind == *k)
&& file_filter.is_none_or(|f| s.file.contains(f))
})
.take(max_results)
.collect();
@@ -401,7 +401,7 @@ impl SymbolIndex {
*counts.entry(sym.language.clone()).or_default() += 1;
}
let mut sorted: Vec<(Language, usize)> = counts.into_iter().collect();
sorted.sort_by(|a, b| b.1.cmp(&a.1));
sorted.sort_by_key(|b| std::cmp::Reverse(b.1));
sorted
}
@@ -412,7 +412,7 @@ impl SymbolIndex {
*counts.entry(sym.kind.clone()).or_default() += 1;
}
let mut sorted: Vec<(SymbolKind, usize)> = counts.into_iter().collect();
sorted.sort_by(|a, b| b.1.cmp(&a.1));
sorted.sort_by_key(|b| std::cmp::Reverse(b.1));
sorted
}
}
@@ -1299,8 +1299,8 @@ impl Tool for SemanticSearch {
let filtered: Vec<&&CodeSymbol> = results
.iter()
.filter(|s| target_kind.as_ref().map_or(true, |k| s.kind == *k))
.filter(|s| target_lang.as_ref().map_or(true, |l| s.language == *l))
.filter(|s| target_kind.as_ref().is_none_or(|k| s.kind == *k))
.filter(|s| target_lang.as_ref().is_none_or(|l| s.language == *l))
.take(max_results)
.collect();