diff --git a/wtismycode-cli/src/commands/init.rs b/wtismycode-cli/src/commands/init.rs index 3572c6e..b110f5e 100644 --- a/wtismycode-cli/src/commands/init.rs +++ b/wtismycode-cli/src/commands/init.rs @@ -19,14 +19,13 @@ fn detect_project_name(root: &str) -> String { in_project = false; continue; } - if in_project && trimmed.starts_with("name") { - if let Some(val) = trimmed.split('=').nth(1) { + if in_project && trimmed.starts_with("name") + && let Some(val) = trimmed.split('=').nth(1) { let name = val.trim().trim_matches('"').trim_matches('\''); if !name.is_empty() { return name.to_string(); } } - } } } diff --git a/wtismycode-core/Cargo.toml b/wtismycode-core/Cargo.toml index 7912a2e..7ae8e8d 100644 --- a/wtismycode-core/Cargo.toml +++ b/wtismycode-core/Cargo.toml @@ -6,7 +6,7 @@ edition = "2024" [dependencies] serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -toml = "0.9.11+spec-1.1.0" +toml = "0.9.11" tracing = "0.1" anyhow = "1.0" thiserror = "2.0.18" diff --git a/wtismycode-core/src/cycle_detector.rs b/wtismycode-core/src/cycle_detector.rs index fc734b8..b6bdb05 100644 --- a/wtismycode-core/src/cycle_detector.rs +++ b/wtismycode-core/src/cycle_detector.rs @@ -114,8 +114,8 @@ fn deduplicate_cycles(cycles: Vec>) -> Vec> { #[cfg(test)] mod tests { use super::*; - use crate::model::{Edges, Module, ProjectModel}; - use std::collections::HashMap; + use crate::model::{Module, ProjectModel}; + fn make_module(id: &str, outbound: Vec<&str>) -> Module { Module { diff --git a/wtismycode-core/src/lib.rs b/wtismycode-core/src/lib.rs index 0200508..c67e036 100644 --- a/wtismycode-core/src/lib.rs +++ b/wtismycode-core/src/lib.rs @@ -23,7 +23,7 @@ pub use model::ProjectModel; #[cfg(test)] mod tests { - use super::*; + #[test] fn it_works() { diff --git a/wtismycode-core/src/package_classifier.rs b/wtismycode-core/src/package_classifier.rs index 016653c..2c22d5b 100644 --- a/wtismycode-core/src/package_classifier.rs +++ b/wtismycode-core/src/package_classifier.rs @@ -180,11 +180,10 @@ impl PackageClassifier { fn load_pypi_cache(&mut self, dir: &str) { let cache_path = Path::new(dir).join("pypi.json"); - if let Ok(content) = std::fs::read_to_string(&cache_path) { - if let Ok(cache) = serde_json::from_str::>>(&content) { + if let Ok(content) = std::fs::read_to_string(&cache_path) + && let Ok(cache) = serde_json::from_str::>>(&content) { self.pypi_cache = cache; } - } } fn pypi_lookup(&self, package_name: &str) -> Option { @@ -209,11 +208,10 @@ impl PackageClassifier { // Check classifiers if let Some(classifiers) = info.get("classifiers").and_then(|c: &serde_json::Value| c.as_array()) { for classifier in classifiers { - if let Some(s) = classifier.as_str() { - if let Some(cat) = classify_from_pypi_classifier(s) { + if let Some(s) = classifier.as_str() + && let Some(cat) = classify_from_pypi_classifier(s) { return Some(cat); } - } } } diff --git a/wtismycode-core/src/renderer.rs b/wtismycode-core/src/renderer.rs index 408094c..f2a9837 100644 --- a/wtismycode-core/src/renderer.rs +++ b/wtismycode-core/src/renderer.rs @@ -245,14 +245,13 @@ impl Renderer { let category_order = ["HTTP", "Database", "Queue", "Storage", "AI/ML", "Auth", "Testing", "Logging", "Internal", "Third-party"]; let mut integration_sections: Vec = Vec::new(); for cat_name in &category_order { - if let Some(pkgs) = model.classified_integrations.get(*cat_name) { - if !pkgs.is_empty() { + if let Some(pkgs) = model.classified_integrations.get(*cat_name) + && !pkgs.is_empty() { integration_sections.push(serde_json::json!({ "category": cat_name, "packages": pkgs, })); } - } } // Determine project name: config > pyproject.toml > directory name > fallback @@ -281,14 +280,13 @@ impl Renderer { in_project = false; continue; } - if in_project && trimmed.starts_with("name") { - if let Some(val) = trimmed.split('=').nth(1) { + if in_project && trimmed.starts_with("name") + && let Some(val) = trimmed.split('=').nth(1) { let name = val.trim().trim_matches('"').trim_matches('\''); if !name.is_empty() { return Some(name.to_string()); } } - } } None }) @@ -550,14 +548,13 @@ impl Renderer { let category_order = ["HTTP", "Database", "Queue", "Storage", "AI/ML", "Auth", "Testing", "Logging", "Internal", "Third-party"]; let mut integration_sections: Vec = Vec::new(); for cat_name in &category_order { - if let Some(pkgs) = model.classified_integrations.get(*cat_name) { - if !pkgs.is_empty() { + if let Some(pkgs) = model.classified_integrations.get(*cat_name) + && !pkgs.is_empty() { integration_sections.push(serde_json::json!({ "category": cat_name, "packages": pkgs, })); } - } } let data = serde_json::json!({ diff --git a/wtismycode-core/tests/caching.rs b/wtismycode-core/tests/caching.rs index 2718f10..50ea160 100644 --- a/wtismycode-core/tests/caching.rs +++ b/wtismycode-core/tests/caching.rs @@ -2,7 +2,6 @@ //! //! These tests verify that the caching functionality works correctly. -use std::path::Path; use std::fs; use tempfile::TempDir; use wtismycode_core::{Config, python_analyzer::PythonAnalyzer}; diff --git a/wtismycode-core/tests/enhanced_analysis.rs b/wtismycode-core/tests/enhanced_analysis.rs index cce526e..ac0ab2a 100644 --- a/wtismycode-core/tests/enhanced_analysis.rs +++ b/wtismycode-core/tests/enhanced_analysis.rs @@ -3,7 +3,6 @@ //! These tests verify that the enhanced analysis functionality works correctly //! with complex code that includes integrations, calls, and docstrings. -use std::fs; use std::path::Path; use wtismycode_core::{Config, scanner::FileScanner, python_analyzer::PythonAnalyzer}; diff --git a/wtismycode-core/tests/full_pipeline.rs b/wtismycode-core/tests/full_pipeline.rs index 11f2088..38f2d93 100644 --- a/wtismycode-core/tests/full_pipeline.rs +++ b/wtismycode-core/tests/full_pipeline.rs @@ -139,7 +139,7 @@ fn test_cycle_detection_no_cycles() { #[test] fn test_renderer_produces_output() { - let config = Config::default(); + let _config = Config::default(); let model = ProjectModel::new(); let renderer = Renderer::new(); let result = renderer.render_architecture_md(&model, None); diff --git a/wtismycode-core/tests/golden/mod.rs b/wtismycode-core/tests/golden/mod.rs index eb0277b..79cd58b 100644 --- a/wtismycode-core/tests/golden/mod.rs +++ b/wtismycode-core/tests/golden/mod.rs @@ -5,7 +5,6 @@ mod test_utils; -use std::fs; use std::path::Path; use wtismycode_core::{Config, scanner::FileScanner, python_analyzer::PythonAnalyzer}; diff --git a/wtismycode-core/tests/golden/test_utils.rs b/wtismycode-core/tests/golden/test_utils.rs index 5116ada..d16f329 100644 --- a/wtismycode-core/tests/golden/test_utils.rs +++ b/wtismycode-core/tests/golden/test_utils.rs @@ -1,19 +1,21 @@ //! Test utilities for golden tests use std::fs; -use std::path::Path; /// Read a file and return its contents +#[allow(dead_code)] pub fn read_test_file(path: &str) -> String { - fs::read_to_string(path).expect(&format!("Failed to read test file: {}", path)) + fs::read_to_string(path).unwrap_or_else(|_| panic!("Failed to read test file: {}", path)) } /// Write content to a file for testing +#[allow(dead_code)] pub fn write_test_file(path: &str, content: &str) { - fs::write(path, content).expect(&format!("Failed to write test file: {}", path)) + fs::write(path, content).unwrap_or_else(|_| panic!("Failed to write test file: {}", path)) } /// Compare two strings and panic if they don't match +#[allow(dead_code)] pub fn assert_strings_equal(actual: &str, expected: &str, message: &str) { if actual != expected { panic!("{}: Strings do not match\nActual:\n{}\nExpected:\n{}", message, actual, expected); diff --git a/wtismycode-core/tests/project_analysis.rs b/wtismycode-core/tests/project_analysis.rs index 66536ab..a83836b 100644 --- a/wtismycode-core/tests/project_analysis.rs +++ b/wtismycode-core/tests/project_analysis.rs @@ -35,7 +35,7 @@ fn test_project_analysis() { // Integration flags are now set during resolve_symbols, not parse_module // So we resolve and check there - let project_model = analyzer.resolve_symbols(&[core_module.clone()]).unwrap(); + let project_model = analyzer.resolve_symbols(std::slice::from_ref(&core_module)).unwrap(); let db_integration_found = project_model.symbols.values().any(|s| s.integrations_flags.db); let http_integration_found = project_model.symbols.values().any(|s| s.integrations_flags.http);