forked from cadauxe/rastertools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arthur VINCENT
committed
Dec 17, 2024
1 parent
b17cdeb
commit 212c41b
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ] || [ -z "$2" ]; then | ||
echo "Error: You must specify a McCabe threshold and a directory to analyze." | ||
echo "Usage: $0 <threshold> <directory>" | ||
exit 1 | ||
fi | ||
|
||
threshold=$1 | ||
directory=$2 | ||
|
||
if [ ! -d "$directory" ]; then | ||
echo "Error: The directory '$directory' does not exist." | ||
exit 1 | ||
fi | ||
|
||
all_files_ok=true | ||
for file in $(find "$directory" -name "*.py"); do | ||
echo "Analyzing $file ..." | ||
output=$(python -m mccabe --min "$threshold" "$file") | ||
|
||
if [ -n "$output" ]; then | ||
echo "Error: McCabe complexity too high in $file" | ||
echo "$output" | ||
all_files_ok=false | ||
fi | ||
done | ||
|
||
if $all_files_ok; then | ||
echo "✅ All files have McCabe scores less than or equal to $threshold. ✅" | ||
else | ||
echo "❌ Some files have a complexity higher than $threshold ❌" | ||
exit 1 | ||
fi | ||
|
||
exit 0 |