From 06a367d8762915f3cd5e06971c46e4d1535d3ae9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Krupa?= <pawel@krupa.net.pl>
Date: Tue, 12 Feb 2019 14:12:31 +0100
Subject: [PATCH] automatic shellchecking on .sh.in scripts (#5165)

* CI linting .sh.in files

* make linter passing
---
 .travis.yml                                   | 2 ++
 collectors/tc.plugin/tc-qos-helper.sh.in      | 1 +
 health/notifications/alarm-notify.sh.in       | 5 +++--
 tests/health_mgmtapi/health-cmdapi-test.sh.in | 3 ++-
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 248e627a26..96342b138d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -21,6 +21,8 @@ jobs:
     env: CFLAGS='-O1 -DNETDATA_INTERNAL_CHECKS=1 -DNETDATA_VERIFY_LOCKS=1'
   - name: dashboard.js
     script: cp web/gui/dashboard.js /tmp/dashboard.js && ./build/build.sh && diff /tmp/dashboard.js web/gui/dashboard.js
+  - name: lint .sh.in files
+    script: shellcheck --format=gcc $(find . -name '*.sh.in' -not -iwholename '*.git*')
   - name: coverity
     install: sudo apt-get install -y zlib1g-dev uuid-dev libipmimonitoring-dev libmnl-dev libnetfilter-acct-dev
     script: ./coverity-scan.sh || echo "Coverity failed :("
diff --git a/collectors/tc.plugin/tc-qos-helper.sh.in b/collectors/tc.plugin/tc-qos-helper.sh.in
index 01353be456..50555c8b22 100755
--- a/collectors/tc.plugin/tc-qos-helper.sh.in
+++ b/collectors/tc.plugin/tc-qos-helper.sh.in
@@ -216,6 +216,7 @@ show_fireqos_names() {
 		#shellcheck source=/dev/null
 		source "${fireqos_run_dir}/${name}.conf"
 		for n in ${interface_classes_monitor}; do
+			# shellcheck disable=SC2086
 			setclassname ${n//|/ }
 		done
 		[ -n "${interface_dev}" ] && echo "SETDEVICEGROUP ${interface_dev}"
diff --git a/health/notifications/alarm-notify.sh.in b/health/notifications/alarm-notify.sh.in
index 04c0d2e06e..6d57890991 100755
--- a/health/notifications/alarm-notify.sh.in
+++ b/health/notifications/alarm-notify.sh.in
@@ -111,7 +111,7 @@ debug() {
 
 docurl() {
 	if [ -z "${curl}" ]; then
-		error '${curl} is unset.'
+		error "${curl} is unset."
 		return 1
 	fi
 
@@ -216,7 +216,8 @@ else
 	units="${17}"              # the units of the value
 	info="${18}"               # a short description of the alarm
 	value_string="${19}"       # friendly value (with units)
-	# shellcheck disable=SC2034 variable is unused, but https://github.com/netdata/netdata/pull/5164#discussion_r255572947
+	# shellcheck disable=SC2034
+	# variable is unused, but https://github.com/netdata/netdata/pull/5164#discussion_r255572947
 	old_value_string="${20}"   # friendly old value (with units), previously named "old_value_string"
 	calc_expression="${21}"    # contains the expression that was evaluated to trigger the alarm
 	calc_param_values="${22}"  # the values of the parameters in the expression, at the time of the evaluation
diff --git a/tests/health_mgmtapi/health-cmdapi-test.sh.in b/tests/health_mgmtapi/health-cmdapi-test.sh.in
index 5e218b11e4..1bbe269d5d 100755
--- a/tests/health_mgmtapi/health-cmdapi-test.sh.in
+++ b/tests/health_mgmtapi/health-cmdapi-test.sh.in
@@ -1,4 +1,5 @@
 #!/usr/bin/env bash
+# shellcheck disable=SC1117,SC2034,SC2059,SC2086,SC2181
 
 NETDATA_USER_CONFIG_DIR="@configdir_POST@"
 NETDATA_STOCK_CONFIG_DIR="@libconfigdir_POST@"
@@ -260,4 +261,4 @@ fi
 if [ $err -gt 0 ] ; then
 	echo "$err error(s) found"
 	exit 1
-fi
\ No newline at end of file
+fi