check-style.sh 751 Bytes
Newer Older
1
2
3
4
5
6
7
8
#!/bin/bash
# 
# Script to check include/test code for common pybind11 code style errors.
# Currently just checks for tabs used instead of spaces.
# 
# Invoke as: tools/check-style.sh
#

9
10
11
12
13
errors=0
IFS=$'\n'
found=
grep $'\t' include/ tests/ docs/*.rst -rl | while read f; do
    if [ -z "$found" ]; then
14
15
        echo -e '\e[31m\e[01mError: found tabs instead of spaces in the following files:\e[0m'
        found=1
16
        errors=1
17
18
19
20
21
    fi

    echo "    $f"
done

22
23
24
25
26
27
28
29
30
31
32
33
found=
grep '\<\(if\|for\|while\)(' include/ tests/* -r --color=always | while read line; do
    if [ -z "$found" ]; then
        echo -e '\e[31m\e[01mError: found the following coding style problems:\e[0m'
        found=1
        errors=1
    fi

    echo "    $line"
done

exit $errors