gnuboot/tests/lint

70 lines
2.0 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
#
# Various code quality tests to avoid regressions in code quality.
#
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
report()
{
ret=$?
message="$1"
if [ ${ret} -eq 0 ] ; then
echo "[ OK ] ${message}"
else
echo "[ !! ] ${message} failed"
exit ${ret}
fi
}
run_shellcheck()
{
for path in "$@" ; do
shellcheck -x "${path}" ; report "${path}"
done
}
printf "+---------------------+\n"
printf "| Running lint tests: |\n"
printf "+---------------------+\n"
run_shellcheck \
autogen.sh \
build \
download \
modify \
2023-11-28 17:37:25 +01:00
update \
resources/packages/coreboot/distclean \
resources/packages/descriptors/distclean \
resources/packages/flashrom/distclean \
resources/packages/grub/distclean \
resources/packages/ich9utils/distclean \
resources/packages/memtest86plus/distclean \
resources/packages/payloads/distclean \
resources/packages/rom_images/distclean \
resources/packages/roms/distclean \
resources/packages/seabios/distclean \
resources/packages/src/distclean \
resources/packages/u-boot-libre/distclean \
resources/packages/website/distclean \
scripts: misc: guix.sh: make it pass shellcheck. Without this fix, running shellcheck -x on resources/scripts/misc/guix.sh returns many errors. For each guix version declaration we have something like that: In resources/scripts/misc/guix.sh line 21: guix_v0_0="6365068393254e1131ab80eb0d68a759e7fd2256" ^-------^ SC2034 (warning): guix_v0_0 appears unused. Verify use (or export if used externally). and here the variables are actually used in this code: guix_version_commit() { version="$1" eval echo "$(echo \$guix_"${version}" | sed 's#\.#_#g')" } so we workaround by disabling that test for each version declaration. Then shellcheck cannot find "$GUIX_PROFILE"/etc/profile: In resources/scripts/misc/guix.sh line 91: . "$GUIX_PROFILE"/etc/profile ^-------------------------^ SC1091 (info): Not following: ./etc/profile: openBinaryFile: does not exist (No such file or directory) so we disabled that test for this line. After that we have many issues with quoting like this one: In resources/scripts/misc/guix.sh line 104: eval echo $(echo \$guix_"${version}" | sed 's#\.#_#g') ^-- SC2046 (warning): Quote this to prevent word splitting. or this one: In resources/scripts/misc/guix.sh line 233: major="$(echo ${version} | awk -F . '{print $1}')" ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting. these were fixed. We also improved a test by using grep -q: In resources/scripts/misc/guix.sh line 272: elif [ -n "$(echo ${revision} | grep '\.')" ] ; then ^-- SC2143 (style): Use grep -q instead of comparing output with [ -n .. ] And finally in guix_version_commit a sed was avoided by using bash replacement, and when that was not possible (in guix_next_version), the shellcheck test for that was disabled. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> Acked-by: Adrien 'neox' Bourmault <neox@gnu.org>
2024-01-30 23:49:43 +01:00
resources/scripts/misc/guix.sh \
resources/scripts/tasks/distclean.sh \
tests/distclean \
tests/lint
printf "+---------------------+\n"
printf "| Lint tests done |\n"
printf "+---------------------+\n"