#!/bin/bash # Automatic fix script for crud-pricing # # Automatically fixes formatting and some linting issues. # Run this before committing to ensure code quality. set -e # Exit on any error echo "========================================" echo " CRUD-PRICING AUTO-FIX" echo "========================================" echo "" # Color codes GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # 1. Auto-format code echo -e "${YELLOW}Auto-formatting code with rustfmt...${NC}" cargo fmt echo -e "${GREEN}✓ Code formatted${NC}" echo "" # 2. Auto-fix clippy warnings echo -e "${YELLOW}Auto-fixing clippy warnings...${NC}" cargo clippy --all-targets --all-features --fix --allow-dirty --allow-staged echo -e "${GREEN}✓ Clippy warnings fixed (where possible)${NC}" echo "" # 3. Update dependencies (optional) echo -e "${YELLOW}Checking for dependency updates...${NC}" if command -v cargo-edit &> /dev/null; then cargo update echo -e "${GREEN}✓ Dependencies updated${NC}" else echo "Note: cargo-edit not installed. Skipping dependency updates." echo "Install with: cargo install cargo-edit" fi echo "" echo "========================================" echo -e "${GREEN}✓ AUTO-FIX COMPLETE${NC}" echo "========================================" echo "" echo "Next steps:" echo "1. Review changes: git diff" echo "2. Run quality checks: ./check-quality.sh" echo "3. Run tests: cargo test" echo "4. Commit changes: git add . && git commit"