-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic_analysis.sh
executable file
·65 lines (57 loc) · 1.53 KB
/
static_analysis.sh
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
#!/bin/bash
error_count=0
declare -a error_list
# Run black in check mode
echo "Running black..."
black --check algorithms/ 2>&1
black_exit_code=$?
if [ $black_exit_code -ne 0 ]; then
((error_count++))
error_list+=("black")
fi
# Run mypy for type checking
# Note: mypy is disabled for now as it is not yet fully supported by the codebase
# echo "Running mypy..."
# mypy --config-file pyproject.toml algorithms/ 2>&1
# mypy_exit_code=$?
# if [ $mypy_exit_code -ne 0 ]; then
# ((error_count++))
# error_list+=("mypy")
# fi
# Run pylint for linting
# Note: pylint is disabled for now as it is not yet fully supported by the codebase
# echo "Running pylint..."
# pylint algorithms/ 2>&1
# pylint_exit_code=$?
# if [ $pylint_exit_code -ne 0 ]; then
# ((error_count++))
# error_list+=("pylint")
# fi
# Run isort in check mode
echo "Running isort in check mode..."
isort --check-only algorithms/ 2>&1
isort_exit_code=$?
if [ $isort_exit_code -ne 0 ]; then
((error_count++))
error_list+=("isort")
fi
# Define color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
# Define a separator line
SEPARATOR="========================================"
# Check if any errors were found
if [ $error_count -ne 0 ]; then
echo -e "${RED}${SEPARATOR}"
echo -e "Static analysis found errors."
echo -e "Errors found by:"
for tool in "${error_list[@]}"; do
echo -e "- $tool"
done
echo -e "${SEPARATOR}${NC}"
else
echo -e "${GREEN}${SEPARATOR}"
echo -e "All static analysis checks passed successfully."
echo -e "${SEPARATOR}${NC}"
fi