From a2ced263ab20123a67b850f397d737e86d7af85c Mon Sep 17 00:00:00 2001 From: Jan-Tarek Butt Date: Sat, 14 Dec 2019 22:18:58 +0100 Subject: [PATCH] build: add make targets lint, lint-sh, lint-lua [Matthias Schiffer: minor script improvements] --- Makefile | 7 +++++++ scripts/lint-lua.sh | 5 +++++ scripts/lint-sh.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100755 scripts/lint-lua.sh create mode 100755 scripts/lint-sh.sh diff --git a/Makefile b/Makefile index a9849104..34343356 100644 --- a/Makefile +++ b/Makefile @@ -103,6 +103,13 @@ endef list-targets: FORCE @$(foreach target,$(GLUON_TARGETS),echo '$(target)';) +lint: lint-lua lint-sh + +lint-lua: FORCE + @scripts/lint-lua.sh + +lint-sh: FORCE + @scripts/lint-sh.sh GLUON_DEFAULT_PACKAGES := hostapd-mini diff --git a/scripts/lint-lua.sh b/scripts/lint-lua.sh new file mode 100755 index 00000000..e958e3f1 --- /dev/null +++ b/scripts/lint-lua.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -e + +luacheck package scripts targets diff --git a/scripts/lint-sh.sh b/scripts/lint-sh.sh new file mode 100755 index 00000000..71ce5463 --- /dev/null +++ b/scripts/lint-sh.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +is_scriptfile() { + echo "$1" | grep -qE '.*\.sh$' || head -n1 "$1" | grep -qE '^#.*(sh|bash)$' +} + +find contrib -type f | while read -r file; do + is_scriptfile "$file" || continue + + echo "Checking $file" + shellcheck -f gcc "$file" +done + +find package -type f | while read -r file; do + is_scriptfile "$file" || continue + + echo "Checking $file" + shellcheck -f gcc -x -s sh -e SC2039,SC1091,SC2155,SC2034 "$file" +done + +find scripts -type f | while read -r file; do + is_scriptfile "$file" || continue + + echo "Checking $file" + shellcheck -f gcc -x -e SC2154,SC1090,SC2181,SC2155,SC2148,SC2034,SC2148 "$file" +done