diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 000000000..7f1373979 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,13 @@ +linters: + # https://golangci-lint.run/usage/linters/#enabled-by-default-linters + enable: + # default linters + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + # optional linters + - goimports + diff --git a/Makefile b/Makefile index 1242635a0..82d0a9a41 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ manifests: # Run go fmt against code .PHONY: fmt fmt: - hack/goimports.sh + go fmt ./... # Run go vet against code .PHONY: vet @@ -69,7 +69,7 @@ vet: # Run golangci-lint against code .PHONY: lint lint: - ( GOLANGCI_LINT_CACHE=$(PROJECT_DIR)/.cache $(GOLANGCI_LINT) run --timeout 10m ) + ( GOLANGCI_LINT_CACHE=$(PROJECT_DIR)/.cache $(GOLANGCI_LINT) run --timeout 10m -v) # Run go mod .PHONY: vendor diff --git a/hack/goimports.sh b/hack/goimports.sh deleted file mode 100755 index 132cc91ad..000000000 --- a/hack/goimports.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -set -o errexit -set -o pipefail - -REPO_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")/..") - -function runGoimports() { - local GOIMPORTS_PATH=$REPO_ROOT/bin/goimports - GOBIN="$REPO_ROOT"/bin go install -mod=readonly golang.org/x/tools/cmd/goimports@latest - - local LOCAL_PACKAGE="github.com/openshift/cluster-cloud-controller-manager-operator" - local GOIMPORTS_ARGS=("-local $LOCAL_PACKAGE -w $REPO_ROOT/cmd $REPO_ROOT/pkg") - - if [[ $# -ne 0 ]] ; then - GOIMPORTS_ARGS="$@" - fi - echo "Run goimports:" - (set -x; $GOIMPORTS_PATH $GOIMPORTS_ARGS) -} - -runGoimports "$@"