File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ sh ../lizard.sh
2+
13cd frontend && npm run lint
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Check if lizard is installed
4+ if ! command -v lizard & > /dev/null; then
5+ echo " ❌ lizard is not installed."
6+ echo " To install lizard globally, run:"
7+ echo " pip install lizard"
8+ exit 1
9+ fi
10+
11+ # Set the complexity threshold
12+ COMPLEXITY_LIMIT=10
13+ NLOC_LIMIT=250
14+
15+ # Get the list of files staged for commit
16+ FILES=$( git diff --cached --name-only --diff-filter=ACM | grep -E ' \.tsx$|\.ts$' )
17+
18+ # Check if there are any files to analyze
19+ if [[ -z " $FILES " ]]; then
20+ echo " No Typescript files to check"
21+ exit 0 # No files to check, allow commit
22+ fi
23+
24+ echo " Running lizard check..."
25+
26+ # Initialize error list
27+ ERROR_LIST=" "
28+
29+ # Run lizard and capture output
30+ for FILE in $FILES ; do
31+ # Run lizard analysis for the file
32+ OUTPUT=$( lizard -C $COMPLEXITY_LIMIT -Tnloc=$NLOC_LIMIT -w --warning-msvs " $FILE " )
33+ ERROR_CODE=$?
34+
35+ if [[ " $ERROR_CODE " -ne 0 ]]; then
36+ ERROR_LIST+=" $OUTPUT \n"
37+ fi
38+ done
39+
40+ # Check if there were any errors
41+ if [[ -n " $ERROR_LIST " ]]; then
42+ echo " ❌ Commit aborted due to the errors in the following files:"
43+ echo " $ERROR_LIST "
44+ echo " Limits are: Code Complexity (CCN)=$COMPLEXITY_LIMIT and Number of Lines (NLOC)=$NLOC_LIMIT "
45+ exit 1
46+ else
47+ echo " ✅ Complexity check passed."
48+ exit 0
49+ fi
50+
51+
You can’t perform that action at this time.
0 commit comments