*: resolve shellcheck errors.

This commit is contained in:
Sam Batschelet 2018-10-25 17:53:05 -04:00
parent 38da00be33
commit 78d01140ff
2 changed files with 14 additions and 14 deletions

2
build
View File

@ -15,7 +15,7 @@ GO_LDFLAGS="$GO_LDFLAGS -X ${REPO_PATH}/version.GitSHA=${GIT_SHA}"
# enable/disable failpoints # enable/disable failpoints
toggle_failpoints() { toggle_failpoints() {
mode="$1" mode="$1"
if which gofail >/dev/null 2>&1; then if command -v gofail >/dev/null 2>&1; then
gofail "$mode" etcdserver/ mvcc/backend/ gofail "$mode" etcdserver/ mvcc/backend/
elif [[ "$mode" != "disable" ]]; then elif [[ "$mode" != "disable" ]]; then
echo "FAILPOINTS set but gofail not found" echo "FAILPOINTS set but gofail not found"

26
test
View File

@ -234,7 +234,7 @@ function cov_pass {
echo "Running code coverage..." echo "Running code coverage..."
# install gocovmerge before running code coverage from github.com/wadey/gocovmerge # install gocovmerge before running code coverage from github.com/wadey/gocovmerge
# gocovmerge merges coverage files # gocovmerge merges coverage files
if ! which gocovmerge >/dev/null; then if ! command -v gocovmerge >/dev/null; then
echo "gocovmerge not installed" echo "gocovmerge not installed"
exit 255 exit 255
fi fi
@ -369,7 +369,7 @@ function release_pass {
} }
function shellcheck_pass { function shellcheck_pass {
if which shellcheck >/dev/null; then if command -v shellcheck >/dev/null; then
shellcheckResult=$(shellcheck -fgcc build test scripts/*.sh 2>&1 || true) shellcheckResult=$(shellcheck -fgcc build test scripts/*.sh 2>&1 || true)
if [ -n "${shellcheckResult}" ]; then if [ -n "${shellcheckResult}" ]; then
echo -e "shellcheck checking failed:\\n${shellcheckResult}" echo -e "shellcheck checking failed:\\n${shellcheckResult}"
@ -389,7 +389,7 @@ function markdown_you_pass {
function markdown_marker_pass { function markdown_marker_pass {
# TODO: check other markdown files when marker handles headers with '[]' # TODO: check other markdown files when marker handles headers with '[]'
if which marker >/dev/null; then if command -v marker >/dev/null; then
markerResult=$(marker --skip-http --root ./Documentation 2>&1 || true) markerResult=$(marker --skip-http --root ./Documentation 2>&1 || true)
if [ -n "${markerResult}" ]; then if [ -n "${markerResult}" ]; then
echo -e "marker checking failed:\\n${markerResult}" echo -e "marker checking failed:\\n${markerResult}"
@ -401,7 +401,7 @@ function markdown_marker_pass {
} }
function goword_pass { function goword_pass {
if which goword >/dev/null; then if command -v goword >/dev/null; then
# get all go files to process # get all go files to process
gofiles=$(find "${FMT[@]}" -iname '*.go' 2>/dev/null) gofiles=$(find "${FMT[@]}" -iname '*.go' 2>/dev/null)
# shellcheck disable=SC2206 # shellcheck disable=SC2206
@ -456,7 +456,7 @@ function govet_shadow_pass {
} }
function gosimple_pass { function gosimple_pass {
if which gosimple >/dev/null; then if command -v gosimple >/dev/null; then
gosimpleResult=$(gosimple "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true) gosimpleResult=$(gosimple "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
if [ -n "${gosimpleResult}" ]; then if [ -n "${gosimpleResult}" ]; then
echo -e "gosimple checking failed:\\n${gosimpleResult}" echo -e "gosimple checking failed:\\n${gosimpleResult}"
@ -468,7 +468,7 @@ function gosimple_pass {
} }
function unused_pass { function unused_pass {
if which unused >/dev/null; then if command -v unused >/dev/null; then
unusedResult=$(unused "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true) unusedResult=$(unused "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
if [ -n "${unusedResult}" ]; then if [ -n "${unusedResult}" ]; then
echo -e "unused checking failed:\\n${unusedResult}" echo -e "unused checking failed:\\n${unusedResult}"
@ -480,7 +480,7 @@ function unused_pass {
} }
function unparam_pass { function unparam_pass {
if which unparam >/dev/null; then if command -v unparam >/dev/null; then
unparamResult=$(unparam "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true) unparamResult=$(unparam "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
if [ -n "${unparamResult}" ]; then if [ -n "${unparamResult}" ]; then
echo -e "unparam checking failed:\\n${unparamResult}" echo -e "unparam checking failed:\\n${unparamResult}"
@ -492,7 +492,7 @@ function unparam_pass {
} }
function staticcheck_pass { function staticcheck_pass {
if which staticcheck >/dev/null; then if command -v staticcheck >/dev/null; then
staticcheckResult=$(staticcheck "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true) staticcheckResult=$(staticcheck "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
if [ -n "${staticcheckResult}" ]; then if [ -n "${staticcheckResult}" ]; then
# TODO: resolve these after go1.8 migration # TODO: resolve these after go1.8 migration
@ -512,7 +512,7 @@ function staticcheck_pass {
} }
function revive_pass { function revive_pass {
if which revive >/dev/null; then if command -v revive >/dev/null; then
reviveResult=$(revive -config ./tests/revive.toml -exclude "vendor/..." ./... 2>&1 || true) reviveResult=$(revive -config ./tests/revive.toml -exclude "vendor/..." ./... 2>&1 || true)
if [ -n "${reviveResult}" ]; then if [ -n "${reviveResult}" ]; then
echo -e "revive checking failed:\\n${reviveResult}" echo -e "revive checking failed:\\n${reviveResult}"
@ -524,7 +524,7 @@ function revive_pass {
} }
function unconvert_pass { function unconvert_pass {
if which unconvert >/dev/null; then if command -v unconvert >/dev/null; then
unconvertResult=$(unconvert -v "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true) unconvertResult=$(unconvert -v "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
if [ -n "${unconvertResult}" ]; then if [ -n "${unconvertResult}" ]; then
echo -e "unconvert checking failed:\\n${unconvertResult}" echo -e "unconvert checking failed:\\n${unconvertResult}"
@ -536,7 +536,7 @@ function unconvert_pass {
} }
function ineffassign_pass { function ineffassign_pass {
if which ineffassign >/dev/null; then if command -v ineffassign >/dev/null; then
ineffassignResult=$(ineffassign "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true) ineffassignResult=$(ineffassign "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
if [ -n "${ineffassignResult}" ]; then if [ -n "${ineffassignResult}" ]; then
echo -e "ineffassign checking failed:\\n${ineffassignResult}" echo -e "ineffassign checking failed:\\n${ineffassignResult}"
@ -548,7 +548,7 @@ function ineffassign_pass {
} }
function nakedret_pass { function nakedret_pass {
if which nakedret >/dev/null; then if command -v nakedret >/dev/null; then
nakedretResult=$(nakedret "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true) nakedretResult=$(nakedret "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
if [ -n "${nakedretResult}" ]; then if [ -n "${nakedretResult}" ]; then
echo -e "nakedret checking failed:\\n${nakedretResult}" echo -e "nakedret checking failed:\\n${nakedretResult}"
@ -642,7 +642,7 @@ function fmt_pass {
} }
function bom_pass { function bom_pass {
if ! which license-bill-of-materials >/dev/null; then if ! command -v license-bill-of-materials >/dev/null; then
return return
fi fi
echo "Checking bill of materials..." echo "Checking bill of materials..."