Add checks for zombie sourcecode problems

This adds checks for zombie sourcecode problems, i.e. problems
we have tried to eliminate but which might be or have been
resurrected.

The example check is for the problematic

    #include "ac_cfg.h"

with double quotes instead of <> which were identified as a
problem in https://github.com/avrdudes/avrdude/issues/1706
and then fixed.
This commit is contained in:
Hans Ulrich Niedermann
2024-08-24 14:36:02 +02:00
parent 9e9825c988
commit 5176d7b818
2 changed files with 77 additions and 0 deletions

53
tools/check-sourcecode Executable file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# check-sourcecode -- check the avrdude source code for zombie mistakes
# Copyright (C) 2024 Hans Ulrich Niedermann <hun@n-dimensional.de>
# SPDX-License-Identifier: GPL-2.0-or-later
set -e
prog="$(basename "$0")"
cd "$(dirname "$0")"
cd ..
test -s README.md
test -s COPYING
test -s build.sh
test -d .git/refs/heads
declare -a checks=()
fail=0
succ=0
checks+=(check_ac_cfg)
check_ac_cfg() {
if git grep -E '#include\s+"ac_cfg\.h"'
then
echo "Error: Found #include \"ac_cfg.h\" with double quotes \"\". Should be <>."
echo " See https://github.com/avrdudes/avrdude/issues/1706 for details."
return 1
fi
}
for check in "${checks[@]}"
do
if "$check"; then
succ=$(( "$succ" + 1 ))
status="SUCC"
else
fail=$(( "$fail" + 1 ))
status="FAIL"
fi
echo "$status $check"
done
total=$(( "$succ" + "$fail" ))
echo "$prog: Summary: $fail checks failed, $succ checks succeeded. $total checks in total."
if [[ "$fail" -gt 0 ]]; then
exit 1
else
exit 0
fi