11#! /bin/bash
22
33# Check if lizard is installed
4- if ! command -v lizard & > /dev/null; then
4+ if command -v lizard & > /dev/null; then
5+ echo " ✅ lizard found in PATH"
6+ elif [ -x ~ /.local/bin/lizard ]; then
7+ echo " ✅ lizard found in user bin, adding to PATH"
8+ export PATH=" $HOME /.local/bin:$PATH "
9+ elif [ -x /usr/local/bin/lizard ]; then
10+ echo " ✅ lizard found in system bin, adding to PATH"
11+ export PATH=" /usr/local/bin:$PATH "
12+ else
513 echo " ❌ lizard is not installed."
614 echo " To install lizard globally, run:"
715 echo " pip install lizard"
@@ -16,7 +24,7 @@ NLOC_LIMIT=250
1624FILES=$( git diff --cached --name-only --diff-filter=ACM | grep -E ' \.tsx$|\.ts$' )
1725
1826# Check if there are any files to analyze
19- if [[ -z " $FILES " ] ]; then
27+ if [ -z " $FILES " ]; then
2028 echo " No Typescript files to check"
2129 exit 0 # No files to check, allow commit
2230fi
@@ -32,13 +40,13 @@ for FILE in $FILES; do
3240 OUTPUT=$( lizard -C $COMPLEXITY_LIMIT -Tnloc=$NLOC_LIMIT -w --warning-msvs " $FILE " )
3341 ERROR_CODE=$?
3442
35- if [[ " $ERROR_CODE " -ne 0 ] ]; then
43+ if [ " $ERROR_CODE " -ne 0 ]; then
3644 ERROR_LIST+=" $OUTPUT \n"
3745 fi
3846done
3947
4048# Check if there were any errors
41- if [[ -n " $ERROR_LIST " ] ]; then
49+ if [ -n " $ERROR_LIST " ]; then
4250 echo " ❌ Commit aborted due to the errors in the following files:"
4351 echo " $ERROR_LIST "
4452 echo " Limits are: Code Complexity (CCN)=$COMPLEXITY_LIMIT and Number of Lines (NLOC)=$NLOC_LIMIT "
0 commit comments