terraform-provider-kubernetes/scripts/errcheck.sh
Mauricio Alvarez Leon 6ee3f5a2d1
Add lint-type-assertion check for /manifest (#2166)
* initial type-assertion commit

* add errcheck package

* add copyright

* check all directories in manifest folder

* Apply suggestions from code review

* use go install

* Add bash header

---------

Co-authored-by: Alex Somesan <alex.somesan@gmail.com>
Co-authored-by: Aleksandr Rybolovlev <sacha.rybolovlev@hashicorp.com>
2023-07-14 07:05:13 -07:00

28 lines
882 B
Bash
Executable file

#!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
echo "==> Checking for unchecked errors..."
if ! which errcheck > /dev/null; then
echo "==> Installing errcheck..."
go install github.com/kisielk/errcheck@latest
fi
err_files=$($(go env GOPATH)/bin/errcheck -exclude scripts/errcheck_excludes.txt \
-verbose \
-ignoretests \
-ignore 'github.com/hashicorp/terraform/helper/schema:Set' \
-ignore 'bytes:.*' \
-ignore 'io:Close|Write' \
-asserts ./manifest/.../ \
)
if [[ -n ${err_files} ]]; then
echo 'Unchecked errors found in the following places:'
echo "${err_files}"
echo "Please handle returned errors. You can check directly with \`make errcheck\`"
exit 1
fi
exit 0