fix: add --all to cargo fmt in script/test and autoformat codebase

cargo fmt without --all fails with "Failed to find targets" in
workspace repos. This was blocking every story's gates. Also ran
cargo fmt --all to fix all existing formatting issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dave
2026-04-13 14:07:08 +00:00
parent ed2526ce41
commit 845b85e7a7
128 changed files with 3566 additions and 2395 deletions
+105 -35
View File
@@ -165,12 +165,16 @@ fn is_bug_item(stem: &str) -> bool {
/// Extract bug name from content (heading or front matter).
fn extract_bug_name_from_content(content: &str) -> Option<String> {
// Try front matter first.
if let Ok(meta) = parse_front_matter(content) && let Some(name) = meta.name {
if let Ok(meta) = parse_front_matter(content)
&& let Some(name) = meta.name
{
return Some(name);
}
// Fallback: heading.
for line in content.lines() {
if let Some(rest) = line.strip_prefix("# Bug ") && let Some(colon_pos) = rest.find(": ") {
if let Some(rest) = line.strip_prefix("# Bug ")
&& let Some(colon_pos) = rest.find(": ")
{
return Some(rest[colon_pos + 2..].to_string());
}
}
@@ -184,16 +188,19 @@ pub fn list_bug_files(_root: &Path) -> Result<Vec<(String, String)>, String> {
let mut bugs = Vec::new();
for item in crate::pipeline_state::read_all_typed() {
if !matches!(item.stage, crate::pipeline_state::Stage::Backlog) || !is_bug_item(&item.story_id.0) {
if !matches!(item.stage, crate::pipeline_state::Stage::Backlog)
|| !is_bug_item(&item.story_id.0)
{
continue;
}
let sid = item.story_id.0;
let name = if item.name.is_empty() { None } else { Some(item.name) }
.or_else(|| {
crate::db::read_content(&sid)
.and_then(|c| extract_bug_name_from_content(&c))
})
.unwrap_or_else(|| sid.clone());
let name = if item.name.is_empty() {
None
} else {
Some(item.name)
}
.or_else(|| crate::db::read_content(&sid).and_then(|c| extract_bug_name_from_content(&c)))
.unwrap_or_else(|| sid.clone());
bugs.push((sid, name));
}
@@ -214,17 +221,23 @@ pub fn list_refactor_files(_root: &Path) -> Result<Vec<(String, String)>, String
let mut refactors = Vec::new();
for item in crate::pipeline_state::read_all_typed() {
if !matches!(item.stage, crate::pipeline_state::Stage::Backlog) || !is_refactor_item(&item.story_id.0) {
if !matches!(item.stage, crate::pipeline_state::Stage::Backlog)
|| !is_refactor_item(&item.story_id.0)
{
continue;
}
let sid = item.story_id.0;
let name = if item.name.is_empty() { None } else { Some(item.name) }
.or_else(|| {
crate::db::read_content(&sid)
.and_then(|c| parse_front_matter(&c).ok())
.and_then(|m| m.name)
})
.unwrap_or_else(|| sid.clone());
let name = if item.name.is_empty() {
None
} else {
Some(item.name)
}
.or_else(|| {
crate::db::read_content(&sid)
.and_then(|c| parse_front_matter(&c).ok())
.and_then(|m| m.name)
})
.unwrap_or_else(|| sid.clone());
refactors.push((sid, name));
}
@@ -278,7 +291,11 @@ mod tests {
fs::write(backlog.join("3_bug_another.md"), "").unwrap();
// Also write to content store so next_item_number sees them.
crate::db::write_item_with_content("1_bug_crash", "1_backlog", "---\nname: Crash\n---\n");
crate::db::write_item_with_content("3_bug_another", "1_backlog", "---\nname: Another\n---\n");
crate::db::write_item_with_content(
"3_bug_another",
"1_backlog",
"---\nname: Another\n---\n",
);
assert!(super::super::next_item_number(tmp.path()).unwrap() >= 4);
}
@@ -323,7 +340,11 @@ mod tests {
);
let result = list_bug_files(tmp.path()).unwrap();
assert!(result.iter().any(|(id, name)| id == "7001_bug_open" && name == "Open Bug"));
assert!(
result
.iter()
.any(|(id, name)| id == "7001_bug_open" && name == "Open Bug")
);
assert!(!result.iter().any(|(id, _)| id == "7002_bug_closed"));
}
@@ -349,9 +370,18 @@ mod tests {
let result = list_bug_files(tmp.path()).unwrap();
// Find positions of our three bugs in the sorted result.
let pos_first = result.iter().position(|(id, _)| id == "7011_bug_first").unwrap();
let pos_second = result.iter().position(|(id, _)| id == "7012_bug_second").unwrap();
let pos_third = result.iter().position(|(id, _)| id == "7013_bug_third").unwrap();
let pos_first = result
.iter()
.position(|(id, _)| id == "7011_bug_first")
.unwrap();
let pos_second = result
.iter()
.position(|(id, _)| id == "7012_bug_second")
.unwrap();
let pos_third = result
.iter()
.position(|(id, _)| id == "7013_bug_third")
.unwrap();
assert!(pos_first < pos_second);
assert!(pos_second < pos_third);
}
@@ -379,12 +409,17 @@ mod tests {
)
.unwrap();
assert!(bug_id.ends_with("_bug_login_crash"), "expected ID to end with _bug_login_crash, got: {bug_id}");
assert!(
bug_id.ends_with("_bug_login_crash"),
"expected ID to end with _bug_login_crash, got: {bug_id}"
);
// Check content exists (either in DB or filesystem).
let contents = crate::db::read_content(&bug_id)
.or_else(|| {
let filepath = tmp.path().join(format!(".huskies/work/1_backlog/{bug_id}.md"));
let filepath = tmp
.path()
.join(format!(".huskies/work/1_backlog/{bug_id}.md"));
fs::read_to_string(filepath).ok()
})
.expect("bug content should exist");
@@ -393,7 +428,10 @@ mod tests {
contents.starts_with("---\nname: \"Login Crash\"\n---"),
"bug file must start with YAML front matter"
);
assert!(contents.contains("Login Crash"), "content should mention bug name");
assert!(
contents.contains("Login Crash"),
"content should mention bug name"
);
assert!(contents.contains("## Description"));
assert!(contents.contains("The login page crashes on submit."));
assert!(contents.contains("## How to Reproduce"));
@@ -409,7 +447,15 @@ mod tests {
#[test]
fn create_bug_file_rejects_empty_name() {
let tmp = tempfile::tempdir().unwrap();
let result = create_bug_file(tmp.path(), "!!!", "desc", "steps", "actual", "expected", None);
let result = create_bug_file(
tmp.path(),
"!!!",
"desc",
"steps",
"actual",
"expected",
None,
);
assert!(result.is_err());
assert!(result.unwrap_err().contains("alphanumeric"));
}
@@ -453,11 +499,16 @@ mod tests {
let spike_id =
create_spike_file(tmp.path(), "Filesystem Watcher Architecture", None).unwrap();
assert!(spike_id.ends_with("_spike_filesystem_watcher_architecture"), "expected ID to end with _spike_filesystem_watcher_architecture, got: {spike_id}");
assert!(
spike_id.ends_with("_spike_filesystem_watcher_architecture"),
"expected ID to end with _spike_filesystem_watcher_architecture, got: {spike_id}"
);
let contents = crate::db::read_content(&spike_id)
.or_else(|| {
let filepath = tmp.path().join(format!(".huskies/work/1_backlog/{spike_id}.md"));
let filepath = tmp
.path()
.join(format!(".huskies/work/1_backlog/{spike_id}.md"));
fs::read_to_string(filepath).ok()
})
.expect("spike content should exist");
@@ -466,7 +517,10 @@ mod tests {
contents.starts_with("---\nname: \"Filesystem Watcher Architecture\"\n---"),
"spike file must start with YAML front matter"
);
assert!(contents.contains("Filesystem Watcher Architecture"), "content should mention spike name");
assert!(
contents.contains("Filesystem Watcher Architecture"),
"content should mention spike name"
);
assert!(contents.contains("## Question"));
assert!(contents.contains("## Hypothesis"));
assert!(contents.contains("## Timebox"));
@@ -480,11 +534,14 @@ mod tests {
let tmp = tempfile::tempdir().unwrap();
let description = "What is the best approach for watching filesystem events?";
let spike_id = create_spike_file(tmp.path(), "FS Watcher Spike", Some(description)).unwrap();
let spike_id =
create_spike_file(tmp.path(), "FS Watcher Spike", Some(description)).unwrap();
let contents = crate::db::read_content(&spike_id)
.or_else(|| {
let filepath = tmp.path().join(format!(".huskies/work/1_backlog/{spike_id}.md"));
let filepath = tmp
.path()
.join(format!(".huskies/work/1_backlog/{spike_id}.md"));
fs::read_to_string(filepath).ok()
})
.expect("spike content should exist");
@@ -498,7 +555,9 @@ mod tests {
let contents = crate::db::read_content(&spike_id)
.or_else(|| {
let filepath = tmp.path().join(format!(".huskies/work/1_backlog/{spike_id}.md"));
let filepath = tmp
.path()
.join(format!(".huskies/work/1_backlog/{spike_id}.md"));
fs::read_to_string(filepath).ok()
})
.expect("spike content should exist");
@@ -544,8 +603,19 @@ mod tests {
);
let spike_id = create_spike_file(tmp.path(), "My Spike", None).unwrap();
assert!(spike_id.ends_with("_spike_my_spike"), "expected ID to end with _spike_my_spike, got: {spike_id}");
let num: u32 = spike_id.chars().take_while(|c| c.is_ascii_digit()).collect::<String>().parse().unwrap();
assert!(num >= 7051, "expected spike number >= 7051, got: {spike_id}");
assert!(
spike_id.ends_with("_spike_my_spike"),
"expected ID to end with _spike_my_spike, got: {spike_id}"
);
let num: u32 = spike_id
.chars()
.take_while(|c| c.is_ascii_digit())
.collect::<String>()
.parse()
.unwrap();
assert!(
num >= 7051,
"expected spike number >= 7051, got: {spike_id}"
);
}
}