Skip to content

Commit f5d72b2

Browse files
committed
fix: resolve clippy warnings and fmt for v1.4
1 parent 5d3bc64 commit f5d72b2

4 files changed

Lines changed: 75 additions & 30 deletions

File tree

src/main.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,32 +1448,47 @@ async fn main() -> Result<()> {
14481448
}
14491449
let db_path = data_dir.join("engraph.db");
14501450
let store = store::Store::open(&db_path)?;
1451-
let vault_path_str = store.get_meta("vault_path")?.expect("no vault path in index");
1451+
let vault_path_str = store
1452+
.get_meta("vault_path")?
1453+
.expect("no vault path in index");
14521454
let vault_path = PathBuf::from(&vault_path_str);
14531455
let profile = Config::load_vault_profile().ok().flatten();
14541456

14551457
match action {
14561458
MigrateAction::Para { apply, undo } => {
14571459
if undo {
14581460
let result = engraph::migrate::undo_last(&store, &vault_path)?;
1459-
println!("Migration {} undone: {} files restored", result.migration_id, result.restored);
1461+
println!(
1462+
"Migration {} undone: {} files restored",
1463+
result.migration_id, result.restored
1464+
);
14601465
if !result.errors.is_empty() {
14611466
eprintln!("Errors:");
1462-
for e in &result.errors { eprintln!(" {}", e); }
1467+
for e in &result.errors {
1468+
eprintln!(" {}", e);
1469+
}
14631470
}
14641471
} else if apply {
14651472
let preview = engraph::migrate::load_preview(&data_dir)?;
1466-
let result = engraph::migrate::apply_preview(&preview, &store, &vault_path)?;
1467-
println!("Migration {} applied: {} files moved", result.migration_id, result.moved);
1473+
let result =
1474+
engraph::migrate::apply_preview(&preview, &store, &vault_path)?;
1475+
println!(
1476+
"Migration {} applied: {} files moved",
1477+
result.migration_id, result.moved
1478+
);
14681479
if !result.errors.is_empty() {
14691480
eprintln!("Errors:");
1470-
for e in &result.errors { eprintln!(" {}", e); }
1481+
for e in &result.errors {
1482+
eprintln!(" {}", e);
1483+
}
14711484
}
14721485
} else {
14731486
// Generate preview
14741487
println!("Scanning vault for PARA classification...");
14751488
let preview = engraph::migrate::generate_preview(
1476-
&store, &vault_path, profile.as_ref(),
1489+
&store,
1490+
&vault_path,
1491+
profile.as_ref(),
14771492
)?;
14781493
engraph::migrate::save_preview(&preview, &data_dir)?;
14791494
println!();

src/migrate.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,13 @@ pub fn classify_heuristic(
181181

182182
// Rule 10: Area keywords in filename or first 200 chars of content
183183
let area_keywords = [
184-
"health", "finance", "career", "learning", "fitness", "nutrition", "budget",
184+
"health",
185+
"finance",
186+
"career",
187+
"learning",
188+
"fitness",
189+
"nutrition",
190+
"budget",
185191
];
186192
let filename_lower = filename.to_lowercase();
187193
let content_prefix: String = content.chars().take(200).collect::<String>().to_lowercase();
@@ -252,7 +258,9 @@ fn suggest_path(current_path: &str, category: &Category, profile: Option<&VaultP
252258
let trimmed = folder.trim_end_matches('/');
253259

254260
// If the file is already under the target folder, keep it where it is.
255-
if current_path.starts_with(&format!("{}/", trimmed)) || current_path.starts_with(&format!("{}/", folder)) {
261+
if current_path.starts_with(&format!("{}/", trimmed))
262+
|| current_path.starts_with(&format!("{}/", folder))
263+
{
256264
return current_path.to_string();
257265
}
258266

@@ -420,10 +428,7 @@ pub fn format_preview_markdown(preview: &MigrationPreview) -> String {
420428
"| {} | {} | {} | {:.0}% | {} |\n",
421429
basename(&f.path),
422430
folder(&f.path),
423-
f.classification
424-
.suggested_path
425-
.as_deref()
426-
.unwrap_or("?"),
431+
f.classification.suggested_path.as_deref().unwrap_or("?"),
427432
f.classification.confidence * 100.0,
428433
f.classification.signal,
429434
));
@@ -657,13 +662,7 @@ mod tests {
657662

658663
#[test]
659664
fn test_skip_template() {
660-
let c = classify_heuristic(
661-
"# Template\n",
662-
"05-Templates/Daily Note.md",
663-
None,
664-
0,
665-
false,
666-
);
665+
let c = classify_heuristic("# Template\n", "05-Templates/Daily Note.md", None, 0, false);
667666
assert_eq!(c.category, Category::Skip);
668667
}
669668

src/serve.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,10 @@ impl EngraphServer {
701701
name = "migrate_preview",
702702
description = "Generate PARA migration preview. Classifies all notes into Projects/Areas/Resources/Archive and returns proposed moves with confidence scores."
703703
)]
704-
async fn migrate_preview(&self, _params: Parameters<MigratePreviewParams>) -> Result<CallToolResult, McpError> {
704+
async fn migrate_preview(
705+
&self,
706+
_params: Parameters<MigratePreviewParams>,
707+
) -> Result<CallToolResult, McpError> {
705708
let store = self.store.lock().await;
706709
let profile_ref = self.profile.as_ref().as_ref();
707710
let preview = crate::migrate::generate_preview(&store, &self.vault_path, profile_ref)
@@ -713,7 +716,10 @@ impl EngraphServer {
713716
name = "migrate_apply",
714717
description = "Apply a PARA migration preview. Moves files to their classified PARA locations. Reversible via migrate_undo."
715718
)]
716-
async fn migrate_apply(&self, params: Parameters<MigrateApplyParams>) -> Result<CallToolResult, McpError> {
719+
async fn migrate_apply(
720+
&self,
721+
params: Parameters<MigrateApplyParams>,
722+
) -> Result<CallToolResult, McpError> {
717723
let store = self.store.lock().await;
718724
let preview: crate::migrate::MigrationPreview = serde_json::from_value(params.0.preview)
719725
.map_err(|e| mcp_err(&anyhow::anyhow!("Invalid preview JSON: {e}")))?;
@@ -726,10 +732,13 @@ impl EngraphServer {
726732
name = "migrate_undo",
727733
description = "Undo the most recent PARA migration, restoring all moved files to their original locations."
728734
)]
729-
async fn migrate_undo(&self, _params: Parameters<MigrateUndoParams>) -> Result<CallToolResult, McpError> {
735+
async fn migrate_undo(
736+
&self,
737+
_params: Parameters<MigrateUndoParams>,
738+
) -> Result<CallToolResult, McpError> {
730739
let store = self.store.lock().await;
731-
let result = crate::migrate::undo_last(&store, &self.vault_path)
732-
.map_err(|e| mcp_err(&e))?;
740+
let result =
741+
crate::migrate::undo_last(&store, &self.vault_path).map_err(|e| mcp_err(&e))?;
733742
to_json_result(&result)
734743
}
735744

src/store.rs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,8 +3402,24 @@ mod tests {
34023402
#[test]
34033403
fn test_migration_log_insert_and_query() {
34043404
let store = Store::open_memory().unwrap();
3405-
store.log_migration("mig-001", "old/note.md", "01-Projects/note.md", "project", 0.9).unwrap();
3406-
store.log_migration("mig-001", "old/ref.md", "03-Resources/ref.md", "resource", 0.85).unwrap();
3405+
store
3406+
.log_migration(
3407+
"mig-001",
3408+
"old/note.md",
3409+
"01-Projects/note.md",
3410+
"project",
3411+
0.9,
3412+
)
3413+
.unwrap();
3414+
store
3415+
.log_migration(
3416+
"mig-001",
3417+
"old/ref.md",
3418+
"03-Resources/ref.md",
3419+
"resource",
3420+
0.85,
3421+
)
3422+
.unwrap();
34073423
let entries = store.get_migration("mig-001").unwrap();
34083424
assert_eq!(entries.len(), 2);
34093425
assert_eq!(entries[0].old_path, "old/note.md");
@@ -3412,16 +3428,22 @@ mod tests {
34123428
#[test]
34133429
fn test_migration_log_get_last() {
34143430
let store = Store::open_memory().unwrap();
3415-
store.log_migration("mig-001", "a.md", "01-Projects/a.md", "project", 0.9).unwrap();
3416-
store.log_migration("mig-002", "b.md", "02-Areas/b.md", "area", 0.8).unwrap();
3431+
store
3432+
.log_migration("mig-001", "a.md", "01-Projects/a.md", "project", 0.9)
3433+
.unwrap();
3434+
store
3435+
.log_migration("mig-002", "b.md", "02-Areas/b.md", "area", 0.8)
3436+
.unwrap();
34173437
let last_id = store.get_last_migration_id().unwrap();
34183438
assert_eq!(last_id.as_deref(), Some("mig-002"));
34193439
}
34203440

34213441
#[test]
34223442
fn test_migration_log_delete() {
34233443
let store = Store::open_memory().unwrap();
3424-
store.log_migration("mig-001", "a.md", "01-Projects/a.md", "project", 0.9).unwrap();
3444+
store
3445+
.log_migration("mig-001", "a.md", "01-Projects/a.md", "project", 0.9)
3446+
.unwrap();
34253447
store.delete_migration("mig-001").unwrap();
34263448
assert!(store.get_migration("mig-001").unwrap().is_empty());
34273449
}

0 commit comments

Comments
 (0)