-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlinter.sh
executable file
·42 lines (35 loc) · 986 Bytes
/
linter.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
#!/bin/bash
#
# Linter implemented via uncrustify tool.
#
# Takes an optional parameter to specify the folders to parse.
# Checks that are missing in uncrustify
mycheck()
{
file=$1
# Detect multibytes
if [[ ! -z $(file $file | grep UTF-8) ]]
then
echo "> Found multibyte character"
grep --color='auto' -P -n "[^\x00-\x7F]" $file
fi
# Add whitespace before and after comments
sed -i 's|\([^[:space:]]\)\*\/|\1 \*\/|g' $file
sed -i 's|\/\*\*\([^[:space:]<]\)|\/\*\* \1|g' $file
sed -i 's|\/\*\([^[:space:]*]\)|\/\* \1|g' $file
# Remove extra whitespaces before pointers
sed -i 's|\([a-zA-Z0-9]\) *\(\*[\^s]\)|\1 \2|g' $file
}
dirs=$1
if [[ $dirs == "" ]]
then
dirs="../include ../src ../test"
fi
echo "Checking $dirs"
files=$(find $dirs -type f | grep -E ".(h|c)$")
for file in $files
do
mycheck $file
uncrustify -c uncrustify.cfg --no-backup -f $file -o $file
#clang-format -style=file -i -verbose
done