Skip to content

Commit 5136822

Browse files
committed
fix: resolve clippy warnings across v1.1 modules
1 parent b4bc368 commit 5136822

7 files changed

Lines changed: 254 additions & 145 deletions

File tree

src/main.rs

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -572,17 +572,9 @@ async fn main() -> Result<()> {
572572
// AI agent detection
573573
let home = dirs::home_dir().unwrap_or_default();
574574
let agent_configs: &[(&str, &str, &str)] = &[
575-
(
576-
"Claude Code",
577-
"claude-code",
578-
".claude/settings.json",
579-
),
575+
("Claude Code", "claude-code", ".claude/settings.json"),
580576
("Cursor", "cursor", ".cursor/mcp.json"),
581-
(
582-
"Windsurf",
583-
"windsurf",
584-
".codeium/windsurf/mcp_config.json",
585-
),
577+
("Windsurf", "windsurf", ".codeium/windsurf/mcp_config.json"),
586578
];
587579

588580
let mut detected: Vec<(&str, &str, String)> = Vec::new();
@@ -1190,8 +1182,7 @@ async fn main() -> Result<()> {
11901182
mode: edit_mode,
11911183
modified_by: "cli".into(),
11921184
};
1193-
let result =
1194-
engraph::writer::edit_note(&store, &vault_path, &input, None)?;
1185+
let result = engraph::writer::edit_note(&store, &vault_path, &input, None)?;
11951186
if cli.json {
11961187
println!("{}", serde_json::to_string_pretty(&result)?);
11971188
} else {
@@ -1212,15 +1203,18 @@ async fn main() -> Result<()> {
12121203
preserve_frontmatter,
12131204
modified_by: "cli".into(),
12141205
};
1215-
let result =
1216-
engraph::writer::rewrite_note(&store, &vault_path, &input)?;
1206+
let result = engraph::writer::rewrite_note(&store, &vault_path, &input)?;
12171207
if cli.json {
12181208
println!("{}", serde_json::to_string_pretty(&result)?);
12191209
} else {
12201210
println!(
12211211
"Rewrote: {} (frontmatter {})",
12221212
result.path,
1223-
if preserve_frontmatter { "preserved" } else { "replaced" }
1213+
if preserve_frontmatter {
1214+
"preserved"
1215+
} else {
1216+
"replaced"
1217+
}
12241218
);
12251219
}
12261220
}
@@ -1232,28 +1226,56 @@ async fn main() -> Result<()> {
12321226
let op = raw.get("op").and_then(|v| v.as_str()).unwrap_or("");
12331227
match op {
12341228
"set" => {
1235-
let key = raw.get("key").and_then(|v| v.as_str()).unwrap_or("").to_string();
1236-
let value = raw.get("value").and_then(|v| v.as_str()).unwrap_or("").to_string();
1229+
let key = raw
1230+
.get("key")
1231+
.and_then(|v| v.as_str())
1232+
.unwrap_or("")
1233+
.to_string();
1234+
let value = raw
1235+
.get("value")
1236+
.and_then(|v| v.as_str())
1237+
.unwrap_or("")
1238+
.to_string();
12371239
ops.push(engraph::writer::FrontmatterOp::Set(key, value));
12381240
}
12391241
"remove" => {
1240-
let key = raw.get("key").and_then(|v| v.as_str()).unwrap_or("").to_string();
1242+
let key = raw
1243+
.get("key")
1244+
.and_then(|v| v.as_str())
1245+
.unwrap_or("")
1246+
.to_string();
12411247
ops.push(engraph::writer::FrontmatterOp::Remove(key));
12421248
}
12431249
"add_tag" => {
1244-
let value = raw.get("value").and_then(|v| v.as_str()).unwrap_or("").to_string();
1250+
let value = raw
1251+
.get("value")
1252+
.and_then(|v| v.as_str())
1253+
.unwrap_or("")
1254+
.to_string();
12451255
ops.push(engraph::writer::FrontmatterOp::AddTag(value));
12461256
}
12471257
"remove_tag" => {
1248-
let value = raw.get("value").and_then(|v| v.as_str()).unwrap_or("").to_string();
1258+
let value = raw
1259+
.get("value")
1260+
.and_then(|v| v.as_str())
1261+
.unwrap_or("")
1262+
.to_string();
12491263
ops.push(engraph::writer::FrontmatterOp::RemoveTag(value));
12501264
}
12511265
"add_alias" => {
1252-
let value = raw.get("value").and_then(|v| v.as_str()).unwrap_or("").to_string();
1266+
let value = raw
1267+
.get("value")
1268+
.and_then(|v| v.as_str())
1269+
.unwrap_or("")
1270+
.to_string();
12531271
ops.push(engraph::writer::FrontmatterOp::AddAlias(value));
12541272
}
12551273
"remove_alias" => {
1256-
let value = raw.get("value").and_then(|v| v.as_str()).unwrap_or("").to_string();
1274+
let value = raw
1275+
.get("value")
1276+
.and_then(|v| v.as_str())
1277+
.unwrap_or("")
1278+
.to_string();
12571279
ops.push(engraph::writer::FrontmatterOp::RemoveAlias(value));
12581280
}
12591281
_ => {
@@ -1266,8 +1288,7 @@ async fn main() -> Result<()> {
12661288
operations: ops,
12671289
modified_by: "cli".into(),
12681290
};
1269-
let result =
1270-
engraph::writer::edit_frontmatter(&store, &vault_path, &input)?;
1291+
let result = engraph::writer::edit_frontmatter(&store, &vault_path, &input)?;
12711292
if cli.json {
12721293
println!("{}", serde_json::to_string_pretty(&result)?);
12731294
} else {

src/markdown.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ pub fn find_section(content: &str, heading_text: &str) -> Option<Section> {
4747
let target = heading_text.trim().to_lowercase();
4848
let lines: Vec<&str> = content.lines().collect();
4949

50-
let idx = headings.iter().position(|h| h.text.to_lowercase() == target)?;
50+
let idx = headings
51+
.iter()
52+
.position(|h| h.text.to_lowercase() == target)?;
5153
let h = &headings[idx];
5254
let body_start = h.line + 1;
5355
let body_end = headings[idx + 1..]

src/obsidian.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ impl ObsidianCli {
6060
/// or when the Obsidian process isn't running.
6161
pub fn should_delegate(&mut self) -> bool {
6262
// If Open, check cooldown
63-
if matches!(self.state, CircuitState::Open) {
64-
if let Some(until) = self.open_until {
65-
if Instant::now() < until {
66-
return false;
67-
}
68-
// Cooldown expired — transition to Degraded for a retry
69-
self.state = CircuitState::Degraded;
70-
self.failures = 1;
71-
self.open_until = None;
63+
if matches!(self.state, CircuitState::Open)
64+
&& let Some(until) = self.open_until
65+
{
66+
if Instant::now() < until {
67+
return false;
7268
}
69+
// Cooldown expired — transition to Degraded for a retry
70+
self.state = CircuitState::Degraded;
71+
self.failures = 1;
72+
self.open_until = None;
7373
}
7474

7575
// Check if Obsidian process is running (cached for CHECK_TTL)
@@ -98,18 +98,20 @@ impl ObsidianCli {
9898
}
9999

100100
/// Set a property on a vault note via Obsidian CLI.
101-
pub async fn property_set(
102-
&mut self,
103-
file: &str,
104-
name: &str,
105-
value: &str,
106-
) -> Result<String> {
107-
self.run_cli(&["property:set", &format!("name={name}"), &format!("value={value}"), &format!("file={file}")]).await
101+
pub async fn property_set(&mut self, file: &str, name: &str, value: &str) -> Result<String> {
102+
self.run_cli(&[
103+
"property:set",
104+
&format!("name={name}"),
105+
&format!("value={value}"),
106+
&format!("file={file}"),
107+
])
108+
.await
108109
}
109110

110111
/// Append content to today's daily note via Obsidian CLI.
111112
pub async fn daily_append(&mut self, content: &str) -> Result<String> {
112-
self.run_cli(&["daily:append", &format!("content={content}")]).await
113+
self.run_cli(&["daily:append", &format!("content={content}")])
114+
.await
113115
}
114116

115117
/// Execute an Obsidian CLI command with a 3-second timeout.

src/serve.rs

Lines changed: 70 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -216,27 +216,24 @@ fn to_json_result<T: serde::Serialize>(value: &T) -> Result<CallToolResult, McpE
216216

217217
/// Record a recently-written file path + mtime so the watcher can skip re-indexing it.
218218
async fn record_write(recent_writes: &RecentWrites, path: &Path) {
219-
if let Ok(meta) = std::fs::metadata(path) {
220-
if let Ok(mtime) = meta.modified() {
221-
recent_writes.lock().await.insert(path.to_path_buf(), mtime);
222-
}
219+
if let Ok(meta) = std::fs::metadata(path)
220+
&& let Ok(mtime) = meta.modified()
221+
{
222+
recent_writes.lock().await.insert(path.to_path_buf(), mtime);
223223
}
224224
}
225225

226226
/// Parse a JSON operations array into `Vec<FrontmatterOp>`.
227227
fn parse_frontmatter_ops(operations: &[serde_json::Value]) -> Result<Vec<FrontmatterOp>, McpError> {
228228
let mut ops = Vec::with_capacity(operations.len());
229229
for op_val in operations {
230-
let op_str = op_val
231-
.get("op")
232-
.and_then(|v| v.as_str())
233-
.ok_or_else(|| {
234-
McpError::new(
235-
rmcp::model::ErrorCode::INVALID_PARAMS,
236-
"each operation must have an \"op\" string field",
237-
None::<serde_json::Value>,
238-
)
239-
})?;
230+
let op_str = op_val.get("op").and_then(|v| v.as_str()).ok_or_else(|| {
231+
McpError::new(
232+
rmcp::model::ErrorCode::INVALID_PARAMS,
233+
"each operation must have an \"op\" string field",
234+
None::<serde_json::Value>,
235+
)
236+
})?;
240237
match op_str {
241238
"set" => {
242239
let key = op_val.get("key").and_then(|v| v.as_str()).ok_or_else(|| {
@@ -246,13 +243,16 @@ fn parse_frontmatter_ops(operations: &[serde_json::Value]) -> Result<Vec<Frontma
246243
None::<serde_json::Value>,
247244
)
248245
})?;
249-
let value = op_val.get("value").and_then(|v| v.as_str()).ok_or_else(|| {
250-
McpError::new(
251-
rmcp::model::ErrorCode::INVALID_PARAMS,
252-
"\"set\" operation requires a \"value\" field",
253-
None::<serde_json::Value>,
254-
)
255-
})?;
246+
let value = op_val
247+
.get("value")
248+
.and_then(|v| v.as_str())
249+
.ok_or_else(|| {
250+
McpError::new(
251+
rmcp::model::ErrorCode::INVALID_PARAMS,
252+
"\"set\" operation requires a \"value\" field",
253+
None::<serde_json::Value>,
254+
)
255+
})?;
256256
ops.push(FrontmatterOp::Set(key.to_string(), value.to_string()));
257257
}
258258
"remove" => {
@@ -266,43 +266,55 @@ fn parse_frontmatter_ops(operations: &[serde_json::Value]) -> Result<Vec<Frontma
266266
ops.push(FrontmatterOp::Remove(key.to_string()));
267267
}
268268
"add_tag" => {
269-
let value = op_val.get("value").and_then(|v| v.as_str()).ok_or_else(|| {
270-
McpError::new(
271-
rmcp::model::ErrorCode::INVALID_PARAMS,
272-
"\"add_tag\" operation requires a \"value\" field",
273-
None::<serde_json::Value>,
274-
)
275-
})?;
269+
let value = op_val
270+
.get("value")
271+
.and_then(|v| v.as_str())
272+
.ok_or_else(|| {
273+
McpError::new(
274+
rmcp::model::ErrorCode::INVALID_PARAMS,
275+
"\"add_tag\" operation requires a \"value\" field",
276+
None::<serde_json::Value>,
277+
)
278+
})?;
276279
ops.push(FrontmatterOp::AddTag(value.to_string()));
277280
}
278281
"remove_tag" => {
279-
let value = op_val.get("value").and_then(|v| v.as_str()).ok_or_else(|| {
280-
McpError::new(
281-
rmcp::model::ErrorCode::INVALID_PARAMS,
282-
"\"remove_tag\" operation requires a \"value\" field",
283-
None::<serde_json::Value>,
284-
)
285-
})?;
282+
let value = op_val
283+
.get("value")
284+
.and_then(|v| v.as_str())
285+
.ok_or_else(|| {
286+
McpError::new(
287+
rmcp::model::ErrorCode::INVALID_PARAMS,
288+
"\"remove_tag\" operation requires a \"value\" field",
289+
None::<serde_json::Value>,
290+
)
291+
})?;
286292
ops.push(FrontmatterOp::RemoveTag(value.to_string()));
287293
}
288294
"add_alias" => {
289-
let value = op_val.get("value").and_then(|v| v.as_str()).ok_or_else(|| {
290-
McpError::new(
291-
rmcp::model::ErrorCode::INVALID_PARAMS,
292-
"\"add_alias\" operation requires a \"value\" field",
293-
None::<serde_json::Value>,
294-
)
295-
})?;
295+
let value = op_val
296+
.get("value")
297+
.and_then(|v| v.as_str())
298+
.ok_or_else(|| {
299+
McpError::new(
300+
rmcp::model::ErrorCode::INVALID_PARAMS,
301+
"\"add_alias\" operation requires a \"value\" field",
302+
None::<serde_json::Value>,
303+
)
304+
})?;
296305
ops.push(FrontmatterOp::AddAlias(value.to_string()));
297306
}
298307
"remove_alias" => {
299-
let value = op_val.get("value").and_then(|v| v.as_str()).ok_or_else(|| {
300-
McpError::new(
301-
rmcp::model::ErrorCode::INVALID_PARAMS,
302-
"\"remove_alias\" operation requires a \"value\" field",
303-
None::<serde_json::Value>,
304-
)
305-
})?;
308+
let value = op_val
309+
.get("value")
310+
.and_then(|v| v.as_str())
311+
.ok_or_else(|| {
312+
McpError::new(
313+
rmcp::model::ErrorCode::INVALID_PARAMS,
314+
"\"remove_alias\" operation requires a \"value\" field",
315+
None::<serde_json::Value>,
316+
)
317+
})?;
306318
ops.push(FrontmatterOp::RemoveAlias(value.to_string()));
307319
}
308320
unknown => {
@@ -594,10 +606,7 @@ impl EngraphServer {
594606
name = "health",
595607
description = "Vault health report: orphans, broken links, stale notes, tag hygiene, index freshness."
596608
)]
597-
async fn health(
598-
&self,
599-
_params: Parameters<HealthParams>,
600-
) -> Result<CallToolResult, McpError> {
609+
async fn health(&self, _params: Parameters<HealthParams>) -> Result<CallToolResult, McpError> {
601610
let store = self.store.lock().await;
602611
let profile_ref = self.profile.as_ref().as_ref();
603612
let config = crate::health::HealthConfig {
@@ -692,8 +701,14 @@ impl EngraphServer {
692701
.as_ref()
693702
.and_then(|p| p.structure.folders.archive.as_deref())
694703
.unwrap_or("04-Archive");
695-
crate::writer::delete_note(&store, &self.vault_path, &params.0.file, mode, archive_folder)
696-
.map_err(|e| mcp_err(&e))?;
704+
crate::writer::delete_note(
705+
&store,
706+
&self.vault_path,
707+
&params.0.file,
708+
mode,
709+
archive_folder,
710+
)
711+
.map_err(|e| mcp_err(&e))?;
697712
let result = serde_json::json!({
698713
"deleted": params.0.file,
699714
"mode": params.0.mode.as_deref().unwrap_or("soft"),

src/store.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,10 +1528,7 @@ impl Store {
15281528
use strsim::levenshtein;
15291529

15301530
// Normalize query: strip .md, lowercase.
1531-
let query_stem = query
1532-
.strip_suffix(".md")
1533-
.unwrap_or(query)
1534-
.to_lowercase();
1531+
let query_stem = query.strip_suffix(".md").unwrap_or(query).to_lowercase();
15351532

15361533
// Collect all (path, basename_stem) pairs from the store.
15371534
let mut stmt = self.conn.prepare("SELECT path FROM files")?;

0 commit comments

Comments
 (0)