forked from OpenBazaar/OpenBazaar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkstyle.sh
executable file
·97 lines (87 loc) · 2.18 KB
/
checkstyle.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
set -o errexit
set -o pipefail
ERR=false
function python_check() {
echo "Checking python source files..."
if type pylint2 &>/dev/null; then
PYLINT=pylint2
elif type pylint &>/dev/null; then
PYLINT=pylint
else
echo "pylint not found"
return
fi
count=0;
for file in $(find . -iname "*.py" -not -path "./env/*"|grep -v pybitmessage|grep -v pysqlcipher); do
if ! $PYLINT --rcfile .pylintrc $file; then
ERR=true
fi
count=$((count+1));
done
if ! $ERR; then
echo "Successfully checked $count files."
fi
}
function js_check() {
for file in $(find . -not -path "./env/*" -and '(' -iname "*.js" ')'|grep -v pybitmessage|grep -v '.min.js'|grep -v bower_components|grep -v vendors); do
echo "Checking JS source: $file"
if ! jshint --config jshint.conf $file; then
ERR=true
fi
done
}
function new_line_check() {
for file in $(find . -not -path "./env/*" -and '(' -iname "*.html" -o -iname "*.js" ')'|grep -v pybitmessage|grep -v '.min.js'|grep -v bower_components); do
if [ "$(tail -c1 $file)" != "" ]; then
echo "$file: No new line at end of file"
ERR=true
fi
done
}
function execute_bit_check() {
echo "Test for non-executable files with execute bit set..."
for file in $(find . -not -path "./env/*" -perm -111 -and '('\
-name "LICENSE"\
-name "README"\
-o -name "*.cpp"\
-o -name "*.css"\
-o -name "*.eot"\
-o -name "*.html"\
-o -name "*.js"\
-o -name "*.json"\
-o -name "*.less"\
-o -name "*.map"\
-o -name "*.md"\
-o -name "*.png"\
-o -name "*.scss"\
-o -name "*.svg"\
-o -name "*.txt"\
-o -name "*.ttf"\
-o -name "*.woff"\
-o -name "*.yml" ')' ); do
echo "$file: Execute bit set; please remove."
ERR=true
done
echo "Done."
}
case $1 in
python)
python_check
;;
js)
js_check
;;
exc)
execute_bit_check
;;
*)
python_check
js_check
execute_bit_check
esac
if $ERR ; then
exit 1
else
exit 0
fi