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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/// Base parameters shared by ALL analysis commands
/// This ensures consistency across all interfaces
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(default)]
pub struct BaseAnalysisContract {
/// Path to analyze - ALWAYS named 'path', never '`project_path`' or 'file'
pub path: PathBuf,
/// Output format - ALWAYS available, ALWAYS same enum
pub format: OutputFormat,
/// Output file path - ALWAYS optional
pub output: Option<PathBuf>,
/// Number of top files to show - ALWAYS same name, ALWAYS optional
pub top_files: Option<usize>,
/// Include test files - ALWAYS same behavior
pub include_tests: bool,
/// Analysis timeout in seconds - ALWAYS available
pub timeout: u64,
}
impl Default for BaseAnalysisContract {
fn default() -> Self {
Self {
path: PathBuf::from("."),
format: OutputFormat::default(),
output: None,
top_files: Some(10),
include_tests: false,
timeout: 60,
}
}
}
/// Contract for analyze complexity command
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub struct AnalyzeComplexityContract {
/// Base parameters (inherited)
#[serde(flatten, default)]
pub base: BaseAnalysisContract,
/// Maximum cyclomatic complexity threshold
#[serde(default)]
pub max_cyclomatic: Option<u32>,
/// Maximum cognitive complexity threshold
#[serde(default)]
pub max_cognitive: Option<u32>,
/// Maximum Halstead difficulty threshold
#[serde(default)]
pub max_halstead: Option<f64>,
}
/// Contract for analyze SATD command
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub struct AnalyzeSatdContract {
/// Base parameters (inherited)
#[serde(flatten, default)]
pub base: BaseAnalysisContract,
/// Filter by severity level
#[serde(default)]
pub severity: Option<SatdSeverity>,
/// Show only critical debt items
#[serde(default)]
pub critical_only: bool,
/// Use strict mode (only TODO/FIXME/HACK/BUG)
#[serde(default)]
pub strict: bool,
/// Exit with error if violations found
#[serde(default)]
pub fail_on_violation: bool,
}
/// Contract for analyze dead code command
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct AnalyzeDeadCodeContract {
/// Base parameters (inherited)
#[serde(flatten, default)]
pub base: BaseAnalysisContract,
/// Include unreachable code blocks
#[serde(default)]
pub include_unreachable: bool,
/// Minimum dead lines to report a file
#[serde(default = "default_min_dead_lines")]
pub min_dead_lines: usize,
/// Maximum allowed dead code percentage
#[serde(default = "default_max_percentage")]
pub max_percentage: f64,
/// Exit with error if violations found
#[serde(default)]
pub fail_on_violation: bool,
}
fn default_min_dead_lines() -> usize {
10
}
fn default_max_percentage() -> f64 {
15.0
}
/// Contract for analyze TDG command
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct AnalyzeTdgContract {
/// Base parameters (inherited)
#[serde(flatten, default)]
pub base: BaseAnalysisContract,
/// TDG threshold for filtering results
#[serde(default = "default_tdg_threshold")]
pub threshold: f64,
/// Include TDG component breakdown
#[serde(default)]
pub include_components: bool,
/// Show only critical files (TDG > 2.5)
#[serde(default)]
pub critical_only: bool,
}
fn default_tdg_threshold() -> f64 {
1.5
}
/// Contract for analyze lint hotspot command
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct AnalyzeLintHotspotContract {
/// Base parameters (inherited)
#[serde(flatten, default)]
pub base: BaseAnalysisContract,
/// Analyze a specific file instead of finding hotspot
#[serde(default)]
pub file: Option<PathBuf>,
/// Maximum allowed defect density
#[serde(default = "default_max_density")]
pub max_density: f64,
/// Minimum confidence for automated fixes
#[serde(default = "default_min_confidence")]
pub min_confidence: f64,
/// Enforce quality standards
#[serde(default)]
pub enforce: bool,
/// Dry run - show what would be fixed
#[serde(default)]
pub dry_run: bool,
}
fn default_max_density() -> f64 {
5.0
}
fn default_min_confidence() -> f64 {
0.8
}
/// Contract for analyze entropy command
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub struct AnalyzeEntropyContract {
/// Base parameters (inherited)
#[serde(flatten, default)]
pub base: BaseAnalysisContract,
/// Minimum severity level to report
#[serde(default)]
pub min_severity: Option<String>,
/// Maximum number of violations to show (0 = all)
#[serde(default)]
pub top_violations: Option<usize>,
/// Specific file to analyze instead of project
#[serde(default)]
pub file: Option<PathBuf>,
}
/// Contract for quality gate command
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub struct QualityGateContract {
/// Base parameters (inherited)
#[serde(flatten, default)]
pub base: BaseAnalysisContract,
/// Quality profile to use
#[serde(default)]
pub profile: QualityProfile,
/// Specific file to check (optional)
#[serde(default)]
pub file: Option<PathBuf>,
/// Exit with error if violations found
#[serde(default)]
pub fail_on_violation: bool,
/// Show verbose output
#[serde(default)]
pub verbose: bool,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Default)]
#[serde(rename_all = "lowercase")]
pub enum QualityProfile {
#[default]
Standard,
Strict,
Extreme,
Toyota,
}
/// Contract for refactor auto command
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct RefactorAutoContract {
/// File to refactor - MUST be a file, not directory
pub file: PathBuf,
/// Output format
#[serde(default)]
pub format: OutputFormat,
/// Output file path
#[serde(default)]
pub output: Option<PathBuf>,
/// Target complexity
#[serde(default = "default_target_complexity")]
pub target_complexity: u32,
/// Dry run mode
#[serde(default)]
pub dry_run: bool,
/// Analysis timeout
#[serde(default = "default_timeout")]
pub timeout: u64,
}
fn default_target_complexity() -> u32 {
10
}
fn default_timeout() -> u64 {
60
}