From ba48f90f8818e1aecbcd255d8550690a1152d4cf Mon Sep 17 00:00:00 2001 From: Soren Martius Date: Tue, 26 May 2020 20:29:59 +0200 Subject: [PATCH 1/2] align with SC2155 and declare local variables first before setting values --- pre_commit_hooks/make/phony-targets.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pre_commit_hooks/make/phony-targets.sh b/pre_commit_hooks/make/phony-targets.sh index d24cf7c..2e06cf5 100755 --- a/pre_commit_hooks/make/phony-targets.sh +++ b/pre_commit_hooks/make/phony-targets.sh @@ -5,9 +5,13 @@ set -e EXITCODE=0 validate_phony_targets() { - local file=$1 - local source=$(make -npq -f "${file}" | grep -E '^.PHONY:') - local targets=$(sed -n 's#^.PHONY:\(.*\)#\1#p' <<< "${source}") + local file + local source + local targets + + file=$1 + source=$(make -npq -f "${file}" | grep -E '^.PHONY:') + targets=$(sed -n 's#^.PHONY:\(.*\)#\1#p' <<<"${source}") for target in $targets; do # The q command for setting exit codes if a pattern doesn't match, From 43c33257dfd94fb91d6c38ce76f0d77df362c18f Mon Sep 17 00:00:00 2001 From: Soren Martius Date: Wed, 27 May 2020 07:48:12 +0200 Subject: [PATCH 2/2] align syntax --- pre_commit_hooks/make/phony-targets.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pre_commit_hooks/make/phony-targets.sh b/pre_commit_hooks/make/phony-targets.sh index 2e06cf5..313d417 100755 --- a/pre_commit_hooks/make/phony-targets.sh +++ b/pre_commit_hooks/make/phony-targets.sh @@ -5,11 +5,10 @@ set -e EXITCODE=0 validate_phony_targets() { - local file + local file=$1 local source local targets - file=$1 source=$(make -npq -f "${file}" | grep -E '^.PHONY:') targets=$(sed -n 's#^.PHONY:\(.*\)#\1#p' <<<"${source}")