3 VPP_DIR=`dirname $0`/../../
10 # If the user provides --fix, then actually fix things
11 # Note: this is meant for use outside of the CI Jobs, by users cleaning things up
25 if [ "${FULL}" == "1" ]; then
26 FILELIST=$(git ls-tree -r HEAD --name-only)
28 FILELIST=$((git diff HEAD~1.. --name-only; git ls-files -m ) | sort -u)
31 # Check to make sure we have indent. Exit if we don't with an error message, but
33 command -v indent > /dev/null
35 echo "Cound not find required commend \"indent\". Checkstyle aborted"
42 for i in ${FILELIST}; do
43 if [ -f ${i} ] && [ ${i} != "build-root/scripts/checkstyle.sh" ] && [ ${i} != "extras/emacs/fix-coding-style.el" ]; then
44 grep -q "fd.io coding-style-patch-verification: ON" ${i}
46 CHECKSTYLED_FILES="${CHECKSTYLED_FILES} ${i}"
47 if [ ${FIX} == 0 ]; then
48 indent ${i} -o ${i}.out1 > /dev/null 2>&1
49 indent ${i}.out1 -o ${i}.out2 > /dev/null 2>&1
50 # Remove trailing whitespace
51 sed -i -e 's/[[:space:]]*$//' ${i}.out2
52 diff -q ${i} ${i}.out2
56 # Remove trailing whitespace
57 sed -i -e 's/[[:space:]]*$//' ${i}
62 echo "Checkstyle failed for ${i}."
63 echo "Run indent (twice!) as shown to fix the problem:"
64 echo "indent ${VPP_DIR}${i}"
65 echo "indent ${VPP_DIR}${i}"
67 if [ -f ${i}.out1 ]; then
70 if [ -f ${i}.out2 ]; then
74 UNCHECKSTYLED_FILES="${UNCHECKSTYLED_FILES} ${i}"
77 UNCHECKSTYLED_FILES="${UNCHECKSTYLED_FILES} ${i}"
81 if [ ${EXIT_CODE} == 0 ]; then
82 echo "*******************************************************************"
83 echo "* VPP CHECKSTYLE SUCCESSFULLY COMPLETED"
84 echo "*******************************************************************"
86 echo "*******************************************************************"
87 echo "* VPP CHECKSTYLE FAILED"
88 echo "* CONSULT FAILURE LOG ABOVE"
89 echo "* NOTE: Running 'build-root/scripts/checkstyle.sh --fix' *MAY* fix the issue"
90 echo "*******************************************************************"