NMEA: removed macro 'MARNAV_NMEA_GETTER'.
[marnav.git] / bin / tidy
blob5968c2b08f6362d015ba0a62c28a46c3d6955b6b
1 #!/bin/bash -eu
3 export SCRIPT_BASE=$(dirname `readlink -f $0`)
4 export BASE=${SCRIPT_BASE}/..
6 # search for a suitable clang-tidy version
7 CLANG_TIDY_BIN=`which clang-tidy-3.9`
8 if [ ! -x ${CLANG_TIDY_BIN} ] ; then
9 echo "error: clang-tidy not found. abort."
10 exit 1
13 function exec_file()
15 echo -n "--- $1 "
16 printf '%*s\n' $((`tput cols` - 10 - ${#1})) "" | tr ' ' '-'
17 ${CLANG_TIDY_BIN} $1 \
18 -checks=cppcoreguidelines-*,modernize-*,readability-*,misc-*,clang-analyzer-*,-readability-braces-around-statements \
19 -p ${BASE}/build \
20 -- -I${BASE}/src -std=c++11
23 function exec_directory()
25 for fn in $(find $1 -name "*.[ch]pp" | sort) ; do
26 exec_file $fn
27 done
30 if [ ! -x ${CLANG_TIDY_BIN} ] ; then
31 echo "error: clang tidy not found. abort."
32 exit -1
35 if [ $# -gt 1 ] ; then
36 echo "error: invalid number of parameters: $#"
37 echo ""
38 echo "usage: $0 [directory|filename]"
39 echo ""
40 echo " if no direcory of filename is specified, the directory 'src' with all files"
41 echo " matching '*.[ch]pp' is assumed."
42 echo ""
43 exit -1
46 if [ $# -eq 0 ] ; then
47 exec_directory ${BASE}/src
48 else
49 if [ -d $1 ] ; then
50 exec_directory $1
51 elif [ -r $1 ] ; then
52 exec_file $1
53 else
54 echo "error: argument not existing directory or filename: '$1'"
55 exit -1