-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_static_analysis.sh
More file actions
executable file
·85 lines (75 loc) · 2.39 KB
/
run_static_analysis.sh
File metadata and controls
executable file
·85 lines (75 loc) · 2.39 KB
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
#!/bin/bash
# Static analysis runner for JFlutter.
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
if [ -z "$REPO_ROOT" ]; then
REPO_ROOT="$SCRIPT_DIR"
fi
if command -v flutter >/dev/null 2>&1; then
FLUTTER_BIN="$(command -v flutter)"
elif [ -x /opt/homebrew/bin/flutter ]; then
FLUTTER_BIN="/opt/homebrew/bin/flutter"
else
FLUTTER_BIN=""
fi
echo "========================================="
echo "JFLUTTER STATIC ANALYSIS"
echo "========================================="
echo "Repository: $REPO_ROOT"
echo ""
# Check if Flutter SDK is available
if [ -z "$FLUTTER_BIN" ]; then
export SKIP_STATIC_ANALYSIS="true"
echo "ERROR: Flutter SDK not found in PATH"
echo ""
echo "Please ensure Flutter is installed and in your PATH:"
echo " export PATH=\"\$PATH:/path/to/flutter/bin\""
echo ""
echo "Or ensure it is available at /opt/homebrew/bin/flutter"
echo ""
echo "SKIP: Flutter not available, static analysis skipped."
exit 0
fi
echo "Flutter SDK found: $("$FLUTTER_BIN" --version | head -1)"
echo ""
cd "$REPO_ROOT"
echo "Running static analysis..."
echo "Command: $FLUTTER_BIN analyze"
echo ""
# Run flutter analyze
if "$FLUTTER_BIN" analyze; then
echo ""
echo "========================================="
echo "STATIC ANALYSIS PASSED"
echo "========================================="
echo ""
echo "No analysis errors found!"
echo ""
echo "Next steps:"
echo " 1. Verify code formatting: dart format --set-exit-if-changed ."
echo " 2. Run full test suite: flutter test"
echo " 3. Review changes: git diff"
echo ""
exit 0
else
EXIT_CODE=$?
echo ""
echo "========================================="
echo "STATIC ANALYSIS FAILED"
echo "========================================="
echo ""
echo "Analysis errors detected. Please review the output above."
echo ""
echo "Common fixes:"
echo " - Unused imports: Remove them"
echo " - Missing types: Add explicit type annotations"
echo " - Unused variables: Remove or prefix with underscore (_variable)"
echo " - Dead code: Remove unreachable code"
echo " - TODO comments: Address or suppress with // ignore: todo"
echo ""
echo "After fixing:"
echo " ./run_static_analysis.sh"
echo ""
exit $EXIT_CODE
fi