-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Code Quality Analysis via golangci-lint tool, fix detected issues
- Loading branch information
Showing
6 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
issues: | ||
exclude: | ||
# Check this issue for more info: https://github.com/kyoh86/scopelint/issues/4 | ||
- Using the variable on range scope `tc` in function literal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
# standard bash error handling | ||
set -o nounset # treat unset variables as an error and exit immediately. | ||
set -o errexit # exit immediately when a command fails. | ||
set -E # needs to be set if we want the ERR trap | ||
|
||
readonly CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
readonly ROOT_PATH=${CURRENT_DIR}/../.. | ||
readonly GOLANGCI_LINT_VERSION="v1.21.0" | ||
|
||
source "${CURRENT_DIR}/utilities.sh" || { echo 'Cannot load CI utilities.'; exit 1; } | ||
|
||
golangci::install() { | ||
shout "Install the golangci-lint in version ${GOLANGCI_LINT_VERSION}" | ||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b "$GOPATH"/bin ${GOLANGCI_LINT_VERSION} | ||
|
||
echo -e "${GREEN}√ install golangci-lint${NC}" | ||
} | ||
|
||
golangci::run_checks() { | ||
shout "Run golangci-lint checks" | ||
LINTS=( | ||
# default golangci-lint lints | ||
deadcode errcheck gosimple govet ineffassign staticcheck \ | ||
structcheck typecheck unused varcheck \ | ||
# additional lints | ||
golint gofmt misspell gochecknoinits unparam scopelint gosec | ||
) | ||
|
||
ENABLE=$(sed 's/ /,/g' <<< "${LINTS[@]}") | ||
|
||
golangci-lint --disable-all --enable="${ENABLE}" run ./pkg/... ./cmd/... . | ||
|
||
echo -e "${GREEN}√ run golangci-lint${NC}" | ||
} | ||
|
||
main() { | ||
if [[ "${RUN_ON_CI:-x}" == "true" ]]; then | ||
golangci::install | ||
fi | ||
|
||
golangci::run_checks | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,3 @@ func SetFS(newFs afero.Fs) func() { | |
|
||
return revert | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters