diff --git a/src/analysis.rs b/src/analysis.rs index e651443..369ba13 100644 --- a/src/analysis.rs +++ b/src/analysis.rs @@ -78,7 +78,7 @@ impl WikiGraph { ); } - println!(""); + println!(); // Edges for (source, targets) in &self.edges { diff --git a/src/changelog.rs b/src/changelog.rs index 8481b1b..1051a9c 100644 --- a/src/changelog.rs +++ b/src/changelog.rs @@ -106,10 +106,11 @@ async fn update_from_git(changelog_path: &Path, git_dir: &Path, wiki_root: &Path for line in stdout.lines() { if line.starts_with("---ENTRY---|") { // Push previous - if let Some(entry) = current_entry.take() { - if !entry.files.is_empty() && !existing_hashes.contains(&entry.hash) { - new_entries.push(entry); - } + if let Some(entry) = current_entry.take() + && !entry.files.is_empty() + && !existing_hashes.contains(&entry.hash) + { + new_entries.push(entry); } // Parse new @@ -132,31 +133,32 @@ async fn update_from_git(changelog_path: &Path, git_dir: &Path, wiki_root: &Path let raw_path = line.trim(); // Check if file belongs to the wiki directory - if prefix.is_empty() || raw_path.starts_with(&prefix) { - if let Some(entry) = current_entry.as_mut() { - // Strip the prefix to get the relative path inside the wiki - let clean_path = if prefix.is_empty() { - raw_path.to_string() - } else { - raw_path - .strip_prefix(&prefix) - .unwrap_or(raw_path) - .to_string() - }; + if (prefix.is_empty() || raw_path.starts_with(&prefix)) + && let Some(entry) = current_entry.as_mut() + { + // Strip the prefix to get the relative path inside the wiki + let clean_path = if prefix.is_empty() { + raw_path.to_string() + } else { + raw_path + .strip_prefix(&prefix) + .unwrap_or(raw_path) + .to_string() + }; - if clean_path != "changelog.toml" { - entry.files.push(clean_path); - } + if clean_path != "changelog.toml" { + entry.files.push(clean_path); } } } } // Push last - if let Some(entry) = current_entry { - if !entry.files.is_empty() && !existing_hashes.contains(&entry.hash) { - new_entries.push(entry); - } + if let Some(entry) = current_entry + && !entry.files.is_empty() + && !existing_hashes.contains(&entry.hash) + { + new_entries.push(entry); } if new_entries.is_empty() { @@ -180,12 +182,11 @@ async fn update_from_git(changelog_path: &Path, git_dir: &Path, wiki_root: &Path pub async fn load_changelog(root_dir: &Path) -> Vec { let path = root_dir.join("_changelog.toml"); - if path.exists() { - if let Ok(content) = fs::read_to_string(path).await { - if let Ok(config) = toml::from_str::(&content) { - return config.entries; - } - } + if path.exists() + && let Ok(content) = fs::read_to_string(path).await + && let Ok(config) = toml::from_str::(&content) + { + return config.entries; } Vec::new() } diff --git a/src/entry.rs b/src/entry.rs index 306503e..bccdbcf 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -1,5 +1,6 @@ use anyhow::{Context, Result, anyhow}; use colored::Colorize; +use std::path::Path; use std::path::PathBuf; use tokio::fs; @@ -59,7 +60,7 @@ async fn list_entries(root: &PathBuf) -> Result<()> { Ok(()) } -fn check_file_status(root: &PathBuf, filename: Option) -> String { +fn check_file_status(root: &Path, filename: Option) -> String { match filename { Some(f) => { let path = root.join("images").join(&f); @@ -73,7 +74,7 @@ fn check_file_status(root: &PathBuf, filename: Option) -> String { } } -async fn create_entry(root: &PathBuf, title: &str, category: Option) -> Result<()> { +async fn create_entry(root: &Path, title: &str, category: Option) -> Result<()> { let slug: String = title .trim() .to_lowercase() @@ -139,7 +140,7 @@ content_file = "{}" Ok(()) } -async fn remove_entry(root: &PathBuf, name: &str) -> Result<()> { +async fn remove_entry(root: &Path, name: &str) -> Result<()> { let toml_path = root.join(format!("{}.toml", name)); if !toml_path.exists() { @@ -176,7 +177,7 @@ async fn remove_entry(root: &PathBuf, name: &str) -> Result<()> { Ok(()) } -async fn inspect_entry(root: &PathBuf, name: &str) -> Result<()> { +async fn inspect_entry(root: &Path, name: &str) -> Result<()> { let toml_path = root.join(format!("{}.toml", name)); if !toml_path.exists() { return Err(anyhow!("Entry '{}' not found", name)); diff --git a/src/main.rs b/src/main.rs index 5a6ee60..5bf2754 100644 --- a/src/main.rs +++ b/src/main.rs @@ -114,7 +114,7 @@ async fn main() -> anyhow::Result<()> { .route("/changelog", get(render_changelog_handler)) .nest_service( "/images", - tower_http::services::ServeDir::new(&shared_state.docs_dir.join("images")), + tower_http::services::ServeDir::new(shared_state.docs_dir.join("images")), ) .nest_service( "/assets", diff --git a/src/rendering.rs b/src/rendering.rs index 737dad2..3c1162a 100644 --- a/src/rendering.rs +++ b/src/rendering.rs @@ -85,7 +85,7 @@ impl<'a> Iterator for Renderer<'a> { Event::Start(Tag::CodeBlock(kind)) => { let mut code_content = String::new(); - while let Some(inner_event) = self.inner.next() { + for inner_event in self.inner.by_ref() { match inner_event { Event::End(TagEnd::CodeBlock) => break, Event::Text(code) => code_content.push_str(&code), @@ -111,7 +111,7 @@ impl<'a> Iterator for Renderer<'a> { ); Some(Event::Html(CowStr::Boxed(rendered_html.into_boxed_str()))) } - _ => return Some(event), + _ => Some(event), } } }