allframe 0.1.28

Complete Rust web framework with built-in HTTP/2 server, REST/GraphQL/gRPC, compile-time DI, CQRS - TDD from day zero
Documentation
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# Compiler Warnings Cleanup Plan

**Created**: 2025-11-26
**Status**: In Progress
**Goal**: Zero warnings in all tests and code

---

## Summary

**Total Warnings**: ~65
**Categories**:
- Dead code (unused fields, structs, functions): ~55
- Unused imports: ~5
- Never constructed: ~5

**Strategy**: Fix by making code useful OR add `#[allow(dead_code)]` with justification

---

## Test Files with Warnings

### 1. tests/03_api_handler.rs (16 warnings)

**Issue**: Macro test examples that define structs/functions but don't call them

**Warnings**:
- CreateUserRequest, CreateUserResponse (never constructed)
- create_user function (never used)
- ListUsersQuery, User (never constructed)
- list_users (never used)
- UserResponse (never constructed)
- get_user (never used)
- SuccessResponse, ErrorResponse (never constructed)
- validate_data (never used)
- health_check (never used)
- ValidatedRequest (never constructed)
- register_user (never used)
- get_users, get_posts (never used)

**Fix Strategy**: These are testing macro expansion, not actual usage
- Option A: Add actual test calls
- Option B: Add `#[allow(dead_code)]` to test module with explanation

**Recommended**: Option B - These test macro expansion, not runtime behavior

```rust
#[cfg(test)]
#[allow(dead_code)] // Testing macro expansion, not runtime usage
mod test_api_handler_macro {
    // ... existing code
}
```

---

### 2. tests/03_api_handler_simple.rs (4 warnings)

**Issue**: Similar to above - macro tests without calls

**Warnings**:
- health_check (never used)
- CreateRequest (never constructed)
- create_user (never used)
- status (never used)

**Fix Strategy**: Same as #1

```rust
#[cfg(test)]
#[allow(dead_code)] // Testing macro expansion
mod test_simple_handlers {
    // ... existing code
}
```

---

### 3. tests/05_arch_integration.rs (3 warnings)

**Issue**: Test structs with unused fields

**Warnings**:
- User.name (never read)
- User.email (never read)
- Post.id (never read)

**Fix Strategy**: These fields ARE part of the test domain model
- Option A: Use the fields in assertions
- Option B: Prefix with `_` if truly test fixtures
- Option C: Add `#[allow(dead_code)]` if modeling architecture

**Recommended**: Option A - Add assertions that use these fields

```rust
#[test]
fn test_domain_layer() {
    #[domain]
    #[derive(Clone)]
    struct User {
        id: String,
        name: String,
        email: String,
    }

    let user = User {
        id: "123".to_string(),
        name: "Test".to_string(),
        email: "test@example.com".to_string(),
    };

    // FIX: Add assertions
    assert_eq!(user.id, "123");
    assert_eq!(user.name, "Test");
    assert_eq!(user.email, "test@example.com");
}
```

---

### 4. tests/05_arch_layers.rs (12 warnings)

**Issue**: Clean Architecture layer testing with unused types

**Warnings**:
- Multiple User structs (never constructed)
- UserRepository trait (never used)
- GetUserUseCase (never constructed)
- GetUserHandler (never constructed)
- Various methods (find, new) never used

**Fix Strategy**: These are testing layer markers, not functionality
- Add `#[allow(dead_code)]` to each test module

```rust
#[test]
fn test_domain_layer_marker() {
    #[allow(dead_code)] // Testing #[domain] marker, not usage
    #[domain]
    struct User {
        id: String,
        email: String,
    }

    // This test validates the marker compiles
}
```

---

### 5. tests/06_cqrs_commands.rs (5 warnings)

**Issue**: Command handler tests with unused code

**Warnings**:
- CreateUserCommand.name (never read)
- CreateUserCommand (never constructed)
- UpdateUserCommand (never constructed)
- handle_create, handle_update (never used)

**Fix Strategy**: These test command handler macros
- Either use them OR mark as test-only

```rust
#[test]
fn test_command_handler_macro() {
    #[allow(dead_code)] // Testing #[command_handler] macro expansion
    #[command_handler]
    async fn handle_create(_cmd: CreateUserCommand) -> Result<Vec<UserEvent>, String> {
        Ok(vec![])
    }
}
```

---

### 6. tests/06_cqrs_events.rs (4 warnings)

**Issue**: Event versioning tests with unused fields

**Warnings**:
- UserEvent::Deleted (never constructed)
- UserCreatedV1.version (never read)
- UserCreatedV2.user_id, email (never read)
- StreamUserEvent::Created.user_id (never read)

**Fix Strategy**: Test data that's part of the domain model
- Use the fields in assertions

```rust
#[test]
fn test_versioned_event() {
    struct UserCreatedV1 {
        version: u32,
        user_id: String,
        email: String,
    }

    let event = UserCreatedV1 {
        version: 1,
        user_id: "123".to_string(),
        email: "test@example.com".to_string(),
    };

    // FIX: Assert fields are used
    assert_eq!(event.version, 1);
    assert_eq!(event.user_id, "123");
    assert_eq!(event.email, "test@example.com");
}
```

---

### 7. tests/06_cqrs_integration.rs (5 warnings)

**Issue**: Integration test domain models with unused code

**Warnings**:
- UserEvent::Deleted (never constructed)
- User.id (never read)
- ArchUser (never constructed)
- ArchUserEvent::Created fields (never read)
- GetArchUserQuery.user_id (never read)

**Fix Strategy**: Add assertions or mark as test fixtures

---

### 8. tests/06_cqrs_queries.rs (1 warning)

**Issue**: User.id never read

**Fix**: Add assertion

```rust
let user = User { id: "123".to_string(), ... };
assert_eq!(user.id, "123"); // FIX
```

---

### 9. tests/06_cqrs_property.rs (1 warning)

**Issue**: User.id never read

**Fix**: Same as #8

---

### 10. tests/07_otel_integration.rs (2 warnings)

**Issue**: User.id, UserEvent::Created.user_id never read

**Fix**: Add assertions

---

### 11. tests/07_otel_tracing.rs (1 warning)

**Issue**: Unused import SpanRecorder

**Fix**: Either use it or remove it

```rust
// Current:
use allframe_core::otel::{traced, SpanRecorder};

// Option A: Use it
let recorder = SpanRecorder::new();

// Option B: Remove it
use allframe_core::otel::traced;
```

---

### 12. tests/02_di_container.rs (1 warning)

**Issue**: Counter.count never read

**Fix**: Add assertion

```rust
let counter = Counter { name: "test".to_string(), count: 0 };
assert_eq!(counter.count, 0); // FIX
```

---

## Fix Plan

### Phase 1: Macro Tests (tests with #[allow(dead_code)])

**Files**:
- tests/03_api_handler.rs
- tests/03_api_handler_simple.rs
- tests/05_arch_layers.rs
- tests/06_cqrs_commands.rs

**Action**: Add `#[allow(dead_code)]` to test modules that test macro expansion

**Justification**: These tests validate that macros compile correctly, not that code is used

---

### Phase 2: Add Assertions (tests where fields should be validated)

**Files**:
- tests/05_arch_integration.rs
- tests/06_cqrs_events.rs
- tests/06_cqrs_integration.rs
- tests/06_cqrs_queries.rs
- tests/06_cqrs_property.rs
- tests/07_otel_integration.rs
- tests/02_di_container.rs

**Action**: Add assertions that use the "unused" fields

**Justification**: These are domain models - fields should be validated

---

### Phase 3: Fix Unused Imports

**Files**:
- tests/07_otel_tracing.rs

**Action**: Remove or use SpanRecorder

---

## Implementation

### Step 1: Run Tests to Get Current State

```bash
cargo test --all-features 2>&1 | grep warning | wc -l
# Baseline: ~65 warnings
```

---

### Step 2: Fix Macro Tests

**File: tests/03_api_handler.rs**

```rust
#[cfg(test)]
mod test_api_handler_macro {
    use allframe_macros::api_handler;

    // Testing macro expansion, not runtime usage
    #[allow(dead_code)]
    struct CreateUserRequest {
        email: String,
        name: String,
    }

    #[allow(dead_code)]
    struct CreateUserResponse {
        id: String,
        email: String,
    }

    #[allow(dead_code)]
    #[api_handler]
    async fn create_user(req: CreateUserRequest) -> CreateUserResponse {
        CreateUserResponse {
            id: "123".to_string(),
            email: req.email,
        }
    }

    // ... rest of file
}
```

**Repeat for**:
- tests/03_api_handler_simple.rs
- tests/05_arch_layers.rs
- tests/06_cqrs_commands.rs

---

### Step 3: Add Assertions

**Example: tests/05_arch_integration.rs**

```rust
#[test]
fn test_domain_layer() {
    #[domain]
    #[derive(Clone)]
    struct User {
        id: String,
        name: String,
        email: String,
    }

    let user = User {
        id: "123".to_string(),
        name: "Test User".to_string(),
        email: "test@example.com".to_string(),
    };

    // ADD THESE ASSERTIONS
    assert_eq!(user.id, "123");
    assert_eq!(user.name, "Test User");
    assert_eq!(user.email, "test@example.com");
}
```

**Repeat pattern for all other test files**

---

### Step 4: Fix Imports

**File: tests/07_otel_tracing.rs**

```rust
// Remove unused import
use allframe_core::otel::traced;
// Removed: SpanRecorder
```

---

### Step 5: Verify

```bash
cargo test --all-features 2>&1 | grep warning
# Should show 0 warnings
```

---

## Expected Outcome

**Before**:
- ~65 warnings
- Unclear which code is intentionally unused
- Noisy test output

**After**:
- 0 warnings
- Clear documentation (via `#[allow(dead_code)]` comments) of why code exists
- Clean test output
- Better test coverage (assertions validate domain models)

---

## Implementation Order

1. ✅ Document all warnings (this file)
2. ⏳ Phase 1: Macro tests (add `#[allow(dead_code)]`)
3. ⏳ Phase 2: Domain model tests (add assertions)
4. ⏳ Phase 3: Fix imports
5. ⏳ Verify zero warnings
6. ✅ Update CI/CD to enforce `-D warnings`

---

## CI/CD Enforcement

Add to `.github/workflows/test.yml`:

```yaml
- name: Check for warnings
  run: cargo clippy --all-features -- -D warnings

- name: Test with warnings as errors
  run: RUSTFLAGS="-D warnings" cargo test --all-features
```

This ensures NO warnings ever merge to main.

---

**Status**: Ready to implement
**Estimated Time**: 1-2 hours
**Priority**: P1 (should do before Phase 6)