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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Extraction adapters for converting extracted data to analysis types.
//!
//! This module provides pure conversion functions that bridge extracted file data
//! to the existing analysis types used throughout the codebase.
//!
//! # Architecture
//!
//! The adapters layer sits between the unified extraction module and the various
//! analysis phases:
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ Source Files │
//! └─────────────────────┬───────────────────────────────────────────┘
//! │ Single Parse
//! ▼
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ UnifiedFileExtractor (spec 212) │
//! │ ExtractedFileData (spec 211) │
//! └─────────────────────┬───────────────────────────────────────────┘
//! │
//! ┌──────────────┼──────────────┬──────────────┐
//! ▼ ▼ ▼ ▼
//! ┌─────────────┐ ┌───────────┐ ┌───────────┐ ┌─────────────┐
//! │ Metrics │ │CallGraph │ │ DataFlow │ │ GodObject │
//! │ Adapter │ │ Adapter │ │ Adapter │ │ Adapter │
//! └──────┬──────┘ └─────┬─────┘ └─────┬─────┘ └──────┬──────┘
//! │ │ │ │
//! ▼ ▼ ▼ ▼
//! ┌─────────────┐ ┌───────────┐ ┌───────────┐ ┌─────────────┐
//! │Function │ │CallGraph │ │DataFlow │ │GodObject │
//! │Metrics, │ │ │ │Graph │ │Analysis │
//! │FileMetrics │ │ │ │ │ │ │
//! └─────────────┘ └───────────┘ └───────────┘ └─────────────┘
//! ```
//!
//! # Design Principles
//!
//! 1. **Pure Functions**: All adapters are pure functions with no I/O
//! 2. **O(n) Performance**: Conversions are linear in input size
//! 3. **No Parsing**: Adapters never re-parse source code
//! 4. **Testable**: Each adapter can be tested in isolation
//!
//! # Usage
//!
//! ```ignore
//! use debtmap::extraction::adapters;
//! use debtmap::extraction::UnifiedFileExtractor;
//! use std::collections::HashMap;
//!
//! // Extract all files first
//! let extracted: HashMap<PathBuf, ExtractedFileData> = files
//! .iter()
//! .filter_map(|path| {
//! let content = std::fs::read_to_string(path).ok()?;
//! UnifiedFileExtractor::extract(path, &content).ok()
//! })
//! .map(|data| (data.path.clone(), data))
//! .collect();
//!
//! // Convert to metrics
//! let all_metrics = adapters::metrics::all_metrics_from_extracted(&extracted);
//!
//! // Build call graph
//! let call_graph = adapters::call_graph::build_call_graph(&extracted);
//!
//! // Populate data flow
//! let mut data_flow = DataFlowGraph::from_call_graph(call_graph.clone());
//! adapters::data_flow::populate_data_flow(&mut data_flow, &extracted);
//!
//! // Analyze god objects
//! let god_objects = adapters::god_object::analyze_all_files(&extracted);
//! ```
//!
//! # Modules
//!
//! - [`metrics`]: Convert to `FunctionMetrics` and `FileMetrics`
//! - [`call_graph`]: Build `CallGraph` from extracted calls
//! - [`data_flow`]: Populate `DataFlowGraph` with purity, I/O, and transformations
//! - [`god_object`]: Analyze for god object patterns
// Re-export commonly used functions for convenience
pub use build_call_graph;
pub use ;
pub use ;
pub use ;