Files
foxhunt/CLIPPY_COMMAND_REFERENCE.md
jgrusewski 7a199afc45 fix(ml): Fix varmap quantized weight save/load test
- Add missing TFTConfig import to qat_tft.rs
- Add missing DType import to qat_tft.rs and temporal_attention.rs
- Test now passes: test_save_and_load_quantized_weights

The test was failing due to compilation errors in unrelated files that
prevented the ml crate from compiling. The varmap_quantization.rs code
itself was already correct after previous fixes to use .get(0) before
.to_scalar() for extracting scale and zero_point values from tensors.
2025-10-23 13:53:16 +02:00

4.1 KiB

CLIPPY COMMAND REFERENCE

Quick reference for clippy validation and fixes


🔍 Run Full Validation

# Full workspace check (what we ran for validation)
cargo clippy --workspace --all-targets --all-features -- -D warnings 2>&1 | tee /tmp/clippy_results.txt

# Count errors
grep -c "^error:" /tmp/clippy_results.txt

# Count warnings
grep -c "^warning:" /tmp/clippy_results.txt

🔨 Phase 0: Immediate Fixes (10 min)

Fix 1: stress_tests

vim services/stress_tests/src/metrics.rs +144

# Change line 144:
# FROM: let mean_u64 = (mean_micros as u64).min(u64::MAX);
# TO:   let mean_u64 = mean_micros as u64;

Fix 2: trading-data

vim trading-data/src/models.rs +98

# Replace line 98 with:
const EPSILON: f64 = 1e-6;
let actual = order.quantity.to_f64();
let expected = 100_000.0;
assert!(
    (actual - expected).abs() < EPSILON,
    "Expected {}, got {}", expected, actual
);

Verify

cargo clippy --workspace --all-targets --all-features -- -D warnings

⚙️ Phase 1: Configuration Fix (30 min)

Edit Cargo.toml

vim Cargo.toml +785

# Add these to [workspace.lints.clippy] section:
float_arithmetic = "allow"
default_numeric_fallback = "allow"
as_conversions = "allow"
print_stdout = "allow"
print_stderr = "allow"
arithmetic_side_effects = "allow"

# Change these from "warn" to these:
indexing_slicing = "warn"
unwrap_used = "warn"
panic = "warn"
undocumented_unsafe_blocks = "warn"

Test

# Should compile with ~380 warnings (no errors)
cargo clippy --workspace --all-targets --all-features 2>&1 | tee /tmp/phase1_results.txt
grep -c "warning:" /tmp/phase1_results.txt

📊 Analysis Commands

Count errors by category

grep "^error:" /tmp/clippy_results.txt | \
    sed 's/^error: //' | sed 's/-->.*//' | \
    sort | uniq -c | sort -rn | head -20

List affected crates

grep "^error: could not compile" /tmp/clippy_results.txt | \
    sed 's/error: could not compile `//' | sed 's/`.*//' | sort -u

Find files with most errors

grep "^\s*-->" /tmp/clippy_results.txt | \
    sed 's/.*--> //' | sed 's/:.*//' | \
    sort | uniq -c | sort -rn | head -20

🔄 CI/CD Integration

Baseline Warning Count

# After Phase 1, set up baseline tracking
cargo clippy --workspace --all-targets --all-features 2>&1 | \
    grep -c "warning:" > .clippy_baseline.txt

echo "380" > .clippy_baseline.txt  # Initial baseline

CI Check Script

#!/bin/bash
cargo clippy --workspace --all-targets --all-features 2>&1 | tee clippy.txt
CURRENT=$(grep -c "warning:" clippy.txt || echo 0)
BASELINE=$(cat .clippy_baseline.txt || echo 380)

if [ "$CURRENT" -gt "$BASELINE" ]; then
    echo "ERROR: Clippy warnings increased ($CURRENT > $BASELINE)"
    exit 1
fi

echo "✅ Clippy warnings: $CURRENT (baseline: $BASELINE)"

📈 Progress Tracking

Compare to baseline

# Check current count vs baseline
CURRENT=$(cargo clippy --workspace --all-targets --all-features 2>&1 | grep -c "warning:")
BASELINE=380
echo "Progress: $CURRENT warnings (baseline: $BASELINE, improvement: $((BASELINE - CURRENT)))"

Update baseline (quarterly)

# After successful cleanup sprint
CURRENT=$(cargo clippy --workspace --all-targets --all-features 2>&1 | grep -c "warning:")
echo $CURRENT > .clippy_baseline.txt
git add .clippy_baseline.txt
git commit -m "chore: Update clippy baseline to $CURRENT warnings"

🎯 Target Checks (Phase 2+)

Check specific lint categories

# Only check critical safety lints
cargo clippy --workspace --all-targets --all-features -- \
    -D clippy::unwrap_used \
    -D clippy::expect_used \
    -D clippy::panic \
    -D clippy::out_of_bounds_indexing

# Check specific file
cargo clippy -p trading_engine --all-targets -- -D warnings

  • Full V2 Report: FINAL_CLIPPY_VALIDATION_V2.md
  • Quick Fix Guide: CLIPPY_QUICK_FIX_V2.md
  • Summary: CLIPPY_VALIDATION_SUMMARY.md
  • Raw Output: /tmp/final_clippy_results.txt

Generated: 2025-10-23 Status: 2,288 errors → 40 min to ~380 warnings