1use serde::{Deserialize, Serialize};
8
9use crate::effort::CocomoReport;
10
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct DerivedReport {
13 pub totals: DerivedTotals,
14 pub doc_density: RatioReport,
15 pub whitespace: RatioReport,
16 pub verbosity: RateReport,
17 pub max_file: MaxFileReport,
18 pub lang_purity: LangPurityReport,
19 pub nesting: NestingReport,
20 pub test_density: TestDensityReport,
21 pub boilerplate: BoilerplateReport,
22 pub polyglot: PolyglotReport,
23 pub distribution: DistributionReport,
24 pub histogram: Vec<HistogramBucket>,
25 pub top: TopOffenders,
26 pub tree: Option<String>,
27 pub reading_time: ReadingTimeReport,
28 pub context_window: Option<ContextWindowReport>,
29 pub cocomo: Option<CocomoReport>,
30 pub todo: Option<TodoReport>,
31 pub integrity: IntegrityReport,
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct DerivedTotals {
36 pub files: usize,
37 pub code: usize,
38 pub comments: usize,
39 pub blanks: usize,
40 pub lines: usize,
41 pub bytes: usize,
42 pub tokens: usize,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct RatioReport {
47 pub total: RatioRow,
48 pub by_lang: Vec<RatioRow>,
49 pub by_module: Vec<RatioRow>,
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct RatioRow {
54 pub key: String,
55 pub numerator: usize,
56 pub denominator: usize,
57 pub ratio: f64,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct RateReport {
62 pub total: RateRow,
63 pub by_lang: Vec<RateRow>,
64 pub by_module: Vec<RateRow>,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
68pub struct RateRow {
69 pub key: String,
70 pub numerator: usize,
71 pub denominator: usize,
72 pub rate: f64,
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct MaxFileReport {
77 pub overall: FileStatRow,
78 pub by_lang: Vec<MaxFileRow>,
79 pub by_module: Vec<MaxFileRow>,
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
83pub struct MaxFileRow {
84 pub key: String,
85 pub file: FileStatRow,
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
89pub struct FileStatRow {
90 pub path: String,
91 pub module: String,
92 pub lang: String,
93 pub code: usize,
94 pub comments: usize,
95 pub blanks: usize,
96 pub lines: usize,
97 pub bytes: usize,
98 pub tokens: usize,
99 pub doc_pct: Option<f64>,
100 pub bytes_per_line: Option<f64>,
101 pub depth: usize,
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize)]
105pub struct LangPurityReport {
106 pub rows: Vec<LangPurityRow>,
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
110pub struct LangPurityRow {
111 pub module: String,
112 pub lang_count: usize,
113 pub dominant_lang: String,
114 pub dominant_lines: usize,
115 pub dominant_pct: f64,
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
119pub struct NestingReport {
120 pub max: usize,
121 pub avg: f64,
122 pub by_module: Vec<NestingRow>,
123}
124
125#[derive(Debug, Clone, Serialize, Deserialize)]
126pub struct NestingRow {
127 pub key: String,
128 pub max: usize,
129 pub avg: f64,
130}
131
132#[derive(Debug, Clone, Serialize, Deserialize)]
133pub struct TestDensityReport {
134 pub test_lines: usize,
135 pub prod_lines: usize,
136 pub test_files: usize,
137 pub prod_files: usize,
138 pub ratio: f64,
139}
140
141#[derive(Debug, Clone, Serialize, Deserialize)]
142pub struct BoilerplateReport {
143 pub infra_lines: usize,
144 pub logic_lines: usize,
145 pub ratio: f64,
146 pub infra_langs: Vec<String>,
147}
148
149#[derive(Debug, Clone, Serialize, Deserialize)]
150pub struct PolyglotReport {
151 pub lang_count: usize,
152 pub entropy: f64,
153 pub dominant_lang: String,
154 pub dominant_lines: usize,
155 pub dominant_pct: f64,
156}
157
158#[derive(Debug, Clone, Serialize, Deserialize)]
159pub struct DistributionReport {
160 pub count: usize,
161 pub min: usize,
162 pub max: usize,
163 pub mean: f64,
164 pub median: f64,
165 pub p90: f64,
166 pub p99: f64,
167 pub gini: f64,
168}
169
170#[derive(Debug, Clone, Serialize, Deserialize)]
171pub struct HistogramBucket {
172 pub label: String,
173 pub min: usize,
174 pub max: Option<usize>,
175 pub files: usize,
176 pub pct: f64,
177}
178
179#[derive(Debug, Clone, Serialize, Deserialize)]
180pub struct TopOffenders {
181 pub largest_lines: Vec<FileStatRow>,
182 pub largest_tokens: Vec<FileStatRow>,
183 pub largest_bytes: Vec<FileStatRow>,
184 pub least_documented: Vec<FileStatRow>,
185 pub most_dense: Vec<FileStatRow>,
186}
187
188#[derive(Debug, Clone, Serialize, Deserialize)]
189pub struct ReadingTimeReport {
190 pub minutes: f64,
191 pub lines_per_minute: usize,
192 pub basis_lines: usize,
193}
194
195#[derive(Debug, Clone, Serialize, Deserialize)]
196pub struct TodoReport {
197 pub total: usize,
198 pub density_per_kloc: f64,
199 pub tags: Vec<TodoTagRow>,
200}
201
202#[derive(Debug, Clone, Serialize, Deserialize)]
203pub struct TodoTagRow {
204 pub tag: String,
205 pub count: usize,
206}
207
208#[derive(Debug, Clone, Serialize, Deserialize)]
209pub struct ContextWindowReport {
210 pub window_tokens: usize,
211 pub total_tokens: usize,
212 pub pct: f64,
213 pub fits: bool,
214}
215
216#[derive(Debug, Clone, Serialize, Deserialize)]
217pub struct IntegrityReport {
218 pub algo: String,
219 pub hash: String,
220 pub entries: usize,
221}