|
| 1 | +#!/bin/bash |
| 2 | +# Auto-fix all code quality violations |
| 3 | +# Usage: |
| 4 | +# ./scripts/auto_fix_all.sh --dry-run # Preview what would be fixed |
| 5 | +# ./scripts/auto_fix_all.sh # Apply all auto-fixes |
| 6 | + |
| 7 | +set -e |
| 8 | + |
| 9 | +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 10 | +repo_root="$(cd "$script_dir/.." && pwd)" |
| 11 | +cd "$repo_root" |
| 12 | + |
| 13 | +DRY_RUN=false |
| 14 | +if [[ "$1" == "--dry-run" ]]; then |
| 15 | + DRY_RUN=true |
| 16 | +fi |
| 17 | + |
| 18 | +echo "===================================" |
| 19 | +echo "🔧 Auto-fixing Code Quality Issues" |
| 20 | +echo "===================================" |
| 21 | +echo |
| 22 | + |
| 23 | +# Track fixes applied |
| 24 | +fixes_applied=0 |
| 25 | + |
| 26 | +if [[ "$DRY_RUN" == "true" ]]; then |
| 27 | + echo "DRY RUN MODE - No changes will be made" |
| 28 | + echo |
| 29 | + echo "Would run the following fixes:" |
| 30 | + echo "1. Comment spacing fixes" |
| 31 | + echo "2. TODO format fixes" |
| 32 | + echo "3. One-line if brace removal" |
| 33 | + echo "4. File/directory renaming" |
| 34 | + echo "5. Dart formatting" |
| 35 | + echo |
| 36 | + exit 0 |
| 37 | +fi |
| 38 | + |
| 39 | +echo "🔍 1. Fixing comment spacing..." |
| 40 | +if bash scripts/comment_space.sh --fix; then |
| 41 | + echo "✅ Comment spacing fixes completed" |
| 42 | + fixes_applied=$((fixes_applied + 1)) |
| 43 | +else |
| 44 | + echo "❌ Comment spacing fixes failed" |
| 45 | +fi |
| 46 | +echo |
| 47 | + |
| 48 | +echo "🔍 2. Fixing TODO comment formats..." |
| 49 | +if bash scripts/todo_date_check.sh --fix; then |
| 50 | + echo "✅ TODO format fixes completed" |
| 51 | + fixes_applied=$((fixes_applied + 1)) |
| 52 | +else |
| 53 | + echo "❌ TODO format fixes failed" |
| 54 | +fi |
| 55 | +echo |
| 56 | + |
| 57 | +echo "🔍 3. Fixing one-line if statement braces..." |
| 58 | +if bash scripts/no_braces_one_line_if.sh --fix; then |
| 59 | + echo "✅ One-line if brace fixes completed" |
| 60 | + fixes_applied=$((fixes_applied + 1)) |
| 61 | +else |
| 62 | + echo "❌ One-line if brace fixes failed" |
| 63 | +fi |
| 64 | +echo |
| 65 | + |
| 66 | +echo "🔍 4. Fixing file and directory naming..." |
| 67 | +if bash scripts/file_dir_snake_case.sh --fix; then |
| 68 | + echo "✅ File/directory naming fixes completed" |
| 69 | + fixes_applied=$((fixes_applied + 1)) |
| 70 | +else |
| 71 | + echo "❌ File/directory naming fixes failed" |
| 72 | +fi |
| 73 | +echo |
| 74 | + |
| 75 | +echo "🎨 5. Running dart format..." |
| 76 | +if bash scripts/dart_format_files.sh; then |
| 77 | + echo "✅ Dart formatting completed" |
| 78 | +else |
| 79 | + echo "❌ Dart formatting failed" |
| 80 | +fi |
| 81 | +echo |
| 82 | + |
| 83 | +echo "===============================" |
| 84 | +echo "🎯 Auto-fix Summary" |
| 85 | +echo "===============================" |
| 86 | +echo "Fix operations completed: $fixes_applied/4" |
| 87 | +echo |
| 88 | + |
| 89 | +if [[ $fixes_applied -gt 0 ]]; then |
| 90 | + echo "📊 Changes made - you can now commit them:" |
| 91 | + echo " git add -A" |
| 92 | + echo " git commit -m 'Auto-fix: Code quality improvements'" |
| 93 | + echo |
| 94 | + |
| 95 | + echo "🔍 Final quality check..." |
| 96 | + echo |
| 97 | + |
| 98 | + echo "Comment spacing status:" |
| 99 | + bash scripts/comment_space.sh | tail -2 |
| 100 | + echo |
| 101 | + |
| 102 | + echo "TODO format status:" |
| 103 | + bash scripts/todo_date_check.sh | tail -2 |
| 104 | + echo |
| 105 | + |
| 106 | + echo "One-line if braces status:" |
| 107 | + bash scripts/no_braces_one_line_if.sh | tail -2 |
| 108 | + echo |
| 109 | + |
| 110 | + echo "File/directory naming status:" |
| 111 | + bash scripts/file_dir_snake_case.sh | tail -2 |
| 112 | +else |
| 113 | + echo "No fixes were needed or all fixes failed." |
| 114 | +fi |
| 115 | + |
| 116 | +echo |
| 117 | +echo "✨ Auto-fix process completed!" |
0 commit comments