1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// File collection methods for DependencyGraphBuilder
// Extracted from builder.rs
impl DependencyGraphBuilder {
/// Collect all source files from workspace
/// Complexity: 6 (directory traversal)
fn collect_source_files(&self, root: &Path) -> Result<Vec<PathBuf>> {
let mut files = Vec::new();
self.collect_files_recursive(root, &mut files)?;
Ok(files)
}
/// Recursively collect source files
/// Complexity: 8 (recursive with early exit)
fn collect_files_recursive(&self, dir: &Path, files: &mut Vec<PathBuf>) -> Result<()> {
if !dir.is_dir() {
return Ok(());
}
for entry in fs::read_dir(dir)? {
let entry = entry?;
let path = entry.path();
if path.is_dir() {
// Skip common non-source directories
let dir_name = path.file_name().and_then(|n| n.to_str()).unwrap_or("");
if !dir_name.starts_with('.') && dir_name != "target" && dir_name != "node_modules"
{
self.collect_files_recursive(&path, files)?;
}
} else if Self::is_source_file(&path) {
files.push(path);
}
}
Ok(())
}
/// Check if file is a source file we can analyze
/// Complexity: 3
fn is_source_file(path: &Path) -> bool {
matches!(
path.extension().and_then(|s| s.to_str()),
Some("rs")
| Some("py")
| Some("js")
| Some("jsx")
| Some("ts")
| Some("tsx")
| Some("go")
| Some("java")
| Some("c")
| Some("cpp")
| Some("cc")
| Some("h")
| Some("hpp")
)
}
}