From 065bf5d75bfd81d439ea42434463f796128d08f1 Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Fri, 5 Jul 2019 14:02:37 +0200 Subject: add shellcheck to the makeffile and .travis.yml and fix the scripts to have no error with it --- .travis.yml | 1 + GNUmakefile | 3 +++ scripts/changelog-links.sh | 20 ++++++++++---------- scripts/errcheck.sh | 4 ++-- scripts/gofmtcheck.sh | 2 +- scripts/gogetcookie.sh | 9 +++++---- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 82f7e25..72fe3c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ script: - make test - make vet - make website-test +- make shellcheck matrix: fast_finish: true diff --git a/GNUmakefile b/GNUmakefile index f5f0c29..7750632 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -25,6 +25,9 @@ vet: exit 1; \ fi +shellcheck: + shellcheck scripts/* + fmt: gofmt -w $(GOFMT_FILES) diff --git a/scripts/changelog-links.sh b/scripts/changelog-links.sh index 303341b..83e918e 100755 --- a/scripts/changelog-links.sh +++ b/scripts/changelog-links.sh @@ -11,21 +11,21 @@ set -e if [[ ! -f CHANGELOG.md ]]; then - echo "ERROR: CHANGELOG.md not found in pwd." - echo "Please run this from the root of the terraform provider repository" - exit 1 + echo "ERROR: CHANGELOG.md not found in pwd." + echo "Please run this from the root of the terraform provider repository" + exit 1 fi -if [[ `uname` == "Darwin" ]]; then - echo "Using BSD sed" - SED="sed -i.bak -E -e" +if [[ $(uname) == "Darwin" ]]; then + echo "Using BSD sed" + SED="sed -i.bak -E -e" else - echo "Using GNU sed" - SED="sed -i.bak -r -e" + echo "Using GNU sed" + SED="sed -i.bak -r -e" fi -PROVIDER_URL="https:\/\/github.com\/terraform-providers\/terraform-provider-statuscake\/issues" +PROVIDER_URL="https:\\/\\/github.com\\/terraform-providers\\/terraform-provider-statuscake\\/issues" -$SED "s/GH-([0-9]+)/\[#\1\]\($PROVIDER_URL\/\1\)/g" -e 's/\[\[#(.+)([0-9])\)]$/(\[#\1\2))/g' CHANGELOG.md +$SED "s/GH-([0-9]+)/\\[#\\1\\]\\($PROVIDER_URL\\/\\1\\)/g" -e 's/\[\[#(.+)([0-9])\)]$/(\[#\1\2))/g' CHANGELOG.md rm CHANGELOG.md.bak diff --git a/scripts/errcheck.sh b/scripts/errcheck.sh index 15464f5..ebcc7b3 100755 --- a/scripts/errcheck.sh +++ b/scripts/errcheck.sh @@ -3,7 +3,7 @@ # Check gofmt echo "==> Checking for unchecked errors..." -if ! which errcheck > /dev/null; then +if ! command -v errcheck > /dev/null; then echo "==> Installing errcheck..." go get -u github.com/kisielk/errcheck fi @@ -12,7 +12,7 @@ err_files=$(errcheck -ignoretests \ -ignore 'github.com/hashicorp/terraform/helper/schema:Set' \ -ignore 'bytes:.*' \ -ignore 'io:Close|Write' \ - $(go list ./...| grep -v /vendor/)) + "$(go list ./...| grep -v /vendor/)") if [[ -n ${err_files} ]]; then echo 'Unchecked errors found in the following places:' diff --git a/scripts/gofmtcheck.sh b/scripts/gofmtcheck.sh index 1c05581..3856e52 100755 --- a/scripts/gofmtcheck.sh +++ b/scripts/gofmtcheck.sh @@ -2,7 +2,7 @@ # Check gofmt echo "==> Checking that code complies with gofmt requirements..." -gofmt_files=$(gofmt -l `find . -name '*.go' | grep -v vendor`) +gofmt_files=$(gofmt -l "$(find . -name '*.go' | grep -v vendor)") if [[ -n ${gofmt_files} ]]; then echo 'gofmt needs running on the following files:' echo "${gofmt_files}" diff --git a/scripts/gogetcookie.sh b/scripts/gogetcookie.sh index 37955fc..5ab7e93 100755 --- a/scripts/gogetcookie.sh +++ b/scripts/gogetcookie.sh @@ -1,9 +1,10 @@ #!/bin/bash - touch ~/.gitcookies - chmod 0600 ~/.gitcookies +touch ~/.gitcookies +chmod 0600 ~/.gitcookies - git config --global http.cookiefile ~/.gitcookies +git config --global http.cookiefile ~/.gitcookies - tr , \\t <<\__END__ >>~/.gitcookies +tr , \\t <<\__END__ >>~/.gitcookies .googlesource.com,TRUE,/,TRUE,2147483647,o,git-alexandre.namebla.gmail.com=1/OtfvUDYg3VAHfIxaqjAuv8MJqu6--gSU_zSkD8YkKPc +__END__ -- cgit v1.2.3