]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add target to run shellcheck on test bash scripts
authorAnders F Björklund <anders.f.bjorklund@gmail.com>
Mon, 11 Jun 2018 18:25:02 +0000 (20:25 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 11 Aug 2018 08:59:11 +0000 (10:59 +0200)
dev.mk.in
misc/shellcheck-excludes.txt [new file with mode: 0644]

index fd599b8229a9de2c7012d9c0811d0e6d6ba5354b..c992466b1f9668bb4ca43cd6985034e3754892ed 100644 (file)
--- a/dev.mk.in
+++ b/dev.mk.in
@@ -7,6 +7,8 @@ A2X = a2x
 ASCIIDOC = asciidoc
 CPPCHECK = cppcheck
 CPPCHECK_SUPPRESSIONS = misc/cppcheck-suppressions.txt
+SHELLCHECK = shellcheck
+SHELLCHECK_EXCLUDES = misc/shellcheck-excludes.txt
 SCAN_BUILD = scan-build
 DOCKER = docker
 GPERF = gperf
@@ -191,6 +193,10 @@ cppcheck:
          --inline-suppr -q --enable=all --force \
          $(non_3pp_sources) src/main.c $(test_sources)
 
+.PHONY: shellcheck
+shellcheck: test/suites/*.bash
+       $(SHELLCHECK) --shell=bash --exclude=$(shell sed -e 's/:.*//' <$(SHELLCHECK_EXCLUDES) | grep -v '#' | tr '\n' ',' | sed -e 's/,$$//') $^
+
 .PHONY: uncrustify
 uncrustify:
        uncrustify -c misc/uncrustify.cfg --no-backup --replace $(filter-out $(uncrustify_exclude_files), $(base_sources)) $(test_sources)
diff --git a/misc/shellcheck-excludes.txt b/misc/shellcheck-excludes.txt
new file mode 100644 (file)
index 0000000..9c6aad6
--- /dev/null
@@ -0,0 +1,10 @@
+SC2148: Tips depend on target shell and yours is unknown. Add a shebang.
+#  the below excludes are (mostly) about bourne shell and style issues
+SC2001: See if you can use ${variable//search/replace} instead.
+SC2006: Use $(..) instead of legacy `..`.
+SC2046: Quote this to prevent word splitting.
+SC2086: Double quote to prevent globbing and word splitting.
+SC2094: Make sure not to read and write the same file in the same pipeline.
+SC2103: Consider using ( subshell ), 'cd foo||exit', or pushd/popd instead.
+SC2155: Declare and assign separately to avoid masking return values.
+SC2129: Consider using { cmd1; cmd2; } >> file instead of individual redirects.