forked from jsbattig/code-indexer
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlint.sh
More file actions
executable file
·77 lines (62 loc) · 1.87 KB
/
lint.sh
File metadata and controls
executable file
·77 lines (62 loc) · 1.87 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
#!/bin/bash
#
# Comprehensive linting script that runs ruff, black, and mypy on all code including tests.
#
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to run a command and report results
run_command() {
local cmd="$1"
local description="$2"
echo -e "${BLUE}Running ${description}...${NC}"
if $cmd; then
echo -e "${GREEN}✅ ${description} passed${NC}"
return 0
else
echo -e "${RED}❌ ${description} failed${NC}"
return 1
fi
}
# Main function
main() {
echo -e "${BLUE}🔍 Running comprehensive linting...${NC}"
# Define paths to lint
local src_path="src"
local tests_path="tests"
# Check if paths exist
if [[ ! -d "$src_path" ]]; then
echo -e "${RED}❌ Source path $src_path not found${NC}"
exit 1
fi
if [[ ! -d "$tests_path" ]]; then
echo -e "${RED}❌ Tests path $tests_path not found${NC}"
exit 1
fi
local all_passed=true
# Run ruff check
if ! run_command "ruff check $src_path $tests_path" "ruff check"; then
all_passed=false
fi
# Run ruff format check
if ! run_command "ruff format --check $src_path $tests_path" "ruff format check"; then
all_passed=false
fi
# Run mypy with explicit package bases (moderate strictness) - exclude problematic test file
if ! run_command "mypy --explicit-package-bases --check-untyped-defs $src_path $tests_path --exclude=tests/unit/services/test_vector_data_structures_thread_safety.py" "mypy type check"; then
all_passed=false
fi
if $all_passed; then
echo -e "${GREEN}🎉 All linting checks passed!${NC}"
exit 0
else
echo -e "${RED}💥 Some linting checks failed${NC}"
exit 1
fi
}
# Run main function
main "$@"