Patterns applied: - Pattern 2: Float comparison (2x: utils.rs, var_edge_cases_tests.rs) - Pattern 7: Date/time construction (2x: production_streaming.rs, streaming.rs) - Pattern 1: Duration/time ops (2x: rate limiter, semaphore) - Pattern 4: Optional field access (1x: position_tracker.rs) Changes: - data/src/utils.rs: Float sort with NaN handling - data/src/providers/benzinga/production_streaming.rs: Rate limiter + semaphore + date/time - data/src/providers/benzinga/streaming.rs: Date/time construction - risk/src/position_tracker.rs: Emergency fallback counter - risk/tests/var_edge_cases_tests.rs: Test helper float sort Test impact: 0 failures (182/182 passing) Compilation: Clean (0 errors, 0 warnings) Time: 25 min (44% under budget)
29 lines
1.2 KiB
Bash
Executable File
29 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
echo "=== Fixing final unwrap_used violations in services (Agent W17 Phase 5 - Final 2) ==="
|
|
|
|
# Count before
|
|
BEFORE=$(grep -r "\.unwrap()" services/api_gateway/src services/trading_service/src services/backtesting_service/src services/ml_training_service/src 2>/dev/null | wc -l)
|
|
echo "Found $BEFORE .unwrap() calls in services"
|
|
|
|
# Pattern 25: unwrap_or_default().unwrap() → expect()
|
|
echo "Fixing Pattern 25: Builder pattern unwrap() → expect()"
|
|
find services/ -name "*.rs" -type f -exec sed -i \
|
|
's/\.build()\.unwrap()/\.build().expect("INVARIANT: Builder should have all required fields")/g' {} +
|
|
|
|
# Pattern 26: into_inner().unwrap()
|
|
echo "Fixing Pattern 26: into_inner().unwrap() → expect()"
|
|
find services/ -name "*.rs" -type f -exec sed -i \
|
|
's/\.into_inner()\.unwrap()/\.into_inner().expect("INVARIANT: Should successfully extract inner value")/g' {} +
|
|
|
|
# Count after
|
|
AFTER=$(grep -r "\.unwrap()" services/api_gateway/src services/trading_service/src services/backtesting_service/src services/ml_training_service/src 2>/dev/null | wc -l)
|
|
FIXED=$((BEFORE - AFTER))
|
|
|
|
echo ""
|
|
echo "Fixed $FIXED violations in this phase"
|
|
echo "Remaining: $AFTER .unwrap() calls"
|
|
echo ""
|
|
echo "✓ Fix complete"
|