//! Finds the Rust files in a tree worth looking at. use std::path::{Path, PathBuf}; use walkdir::WalkDir; /// Directories that hold code nobody here wrote, or nothing at all. const SKIP: &[&str] = &["target", "vendor", "node_modules", ".git", "pkg", "dist"]; /// Every `.rs` file under `root` with at least `min_lines` lines. pub fn rust_files(root: &Path, min_lines: usize) -> Vec<(PathBuf, usize)> { let mut out = Vec::new(); for entry in WalkDir::new(root) .into_iter() .filter_entry(|e| { !e.file_name() .to_str() .is_some_and(|n| SKIP.contains(&n) || n.starts_with(".claude")) }) .filter_map(Result::ok) { if !entry.file_type().is_file() { continue; } if entry.path().extension().and_then(|e| e.to_str()) != Some("rs") { continue; } let Ok(text) = std::fs::read_to_string(entry.path()) else { continue; }; let lines = text.lines().count(); if lines >= min_lines { out.push((entry.into_path(), lines)); } } out.sort(); out }