CI: use staticcheck for linting
This commit switches the linter for Go code from golint to staticcheck. Golint has been deprecated since last year and staticcheck is a recommended replacement. Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit is contained in:
		
							
								
								
									
										16
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								Makefile
									
									
									
									
									
								
							| @@ -38,14 +38,14 @@ DOCS_GEN_BINARY := bin/docs-gen | |||||||
| DEEPCOPY_GEN_BINARY := bin/deepcopy-gen | DEEPCOPY_GEN_BINARY := bin/deepcopy-gen | ||||||
| INFORMER_GEN_BINARY := bin/informer-gen | INFORMER_GEN_BINARY := bin/informer-gen | ||||||
| LISTER_GEN_BINARY := bin/lister-gen | LISTER_GEN_BINARY := bin/lister-gen | ||||||
| GOLINT_BINARY := bin/golint | STATICCHECK_BINARY := bin/staticcheck | ||||||
| EMBEDMD_BINARY := bin/embedmd | EMBEDMD_BINARY := bin/embedmd | ||||||
| KIND_BINARY := $(shell pwd)/bin/kind | KIND_BINARY := $(shell pwd)/bin/kind | ||||||
| KUBECTL_BINARY := $(shell pwd)/bin/kubectl | KUBECTL_BINARY := $(shell pwd)/bin/kubectl | ||||||
| BASH_UNIT := $(shell pwd)/bin/bash_unit | BASH_UNIT := $(shell pwd)/bin/bash_unit | ||||||
| BASH_UNIT_FLAGS := | BASH_UNIT_FLAGS := | ||||||
|  |  | ||||||
| BUILD_IMAGE ?= golang:1.18 | BUILD_IMAGE ?= golang:1.18.0 | ||||||
| BASE_IMAGE ?= alpine:3.15 | BASE_IMAGE ?= alpine:3.15 | ||||||
|  |  | ||||||
| build: $(BINS) | build: $(BINS) | ||||||
| @@ -165,7 +165,7 @@ fmt: | |||||||
| 	@echo $(GO_PKGS) | 	@echo $(GO_PKGS) | ||||||
| 	gofmt -w -s $(GO_FILES) | 	gofmt -w -s $(GO_FILES) | ||||||
|  |  | ||||||
| lint: header $(GOLINT_BINARY) | lint: header $(STATICCHECK_BINARY) | ||||||
| 	@echo 'go vet $(GO_PKGS)' | 	@echo 'go vet $(GO_PKGS)' | ||||||
| 	@vet_res=$$(GO111MODULE=on go vet -mod=vendor $(GO_PKGS) 2>&1); if [ -n "$$vet_res" ]; then \ | 	@vet_res=$$(GO111MODULE=on go vet -mod=vendor $(GO_PKGS) 2>&1); if [ -n "$$vet_res" ]; then \ | ||||||
| 		echo ""; \ | 		echo ""; \ | ||||||
| @@ -174,10 +174,10 @@ lint: header $(GOLINT_BINARY) | |||||||
| 		echo "$$vet_res"; \ | 		echo "$$vet_res"; \ | ||||||
| 		exit 1; \ | 		exit 1; \ | ||||||
| 	fi | 	fi | ||||||
| 	@echo '$(GOLINT_BINARY) $(GO_PKGS)' | 	@echo '$(STATICCHECK_BINARY) $(GO_PKGS)' | ||||||
| 	@lint_res=$$($(GOLINT_BINARY) $(GO_PKGS)); if [ -n "$$lint_res" ]; then \ | 	@lint_res=$$($(STATICCHECK_BINARY) $(GO_PKGS)); if [ -n "$$lint_res" ]; then \ | ||||||
| 		echo ""; \ | 		echo ""; \ | ||||||
| 		echo "Golint found style issues. Please check the reported issues"; \ | 		echo "Staticcheck found style issues. Please check the reported issues"; \ | ||||||
| 		echo "and fix them if necessary before submitting the code for review:"; \ | 		echo "and fix them if necessary before submitting the code for review:"; \ | ||||||
| 		echo "$$lint_res"; \ | 		echo "$$lint_res"; \ | ||||||
| 		exit 1; \ | 		exit 1; \ | ||||||
| @@ -358,8 +358,8 @@ $(LISTER_GEN_BINARY): | |||||||
| $(DOCS_GEN_BINARY): cmd/docs-gen/main.go | $(DOCS_GEN_BINARY): cmd/docs-gen/main.go | ||||||
| 	go build -mod=vendor -o $@ ./cmd/docs-gen | 	go build -mod=vendor -o $@ ./cmd/docs-gen | ||||||
|  |  | ||||||
| $(GOLINT_BINARY): | $(STATICCHECK_BINARY): | ||||||
| 	go build -mod=vendor -o $@ golang.org/x/lint/golint | 	go build -mod=vendor -o $@ honnef.co/go/tools/cmd/staticcheck | ||||||
|  |  | ||||||
| $(EMBEDMD_BINARY): | $(EMBEDMD_BINARY): | ||||||
| 	go build -mod=vendor -o $@ github.com/campoy/embedmd | 	go build -mod=vendor -o $@ github.com/campoy/embedmd | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								go.mod
									
									
									
									
									
								
							| @@ -15,9 +15,9 @@ require ( | |||||||
| 	github.com/prometheus/client_golang v1.11.0 | 	github.com/prometheus/client_golang v1.11.0 | ||||||
| 	github.com/spf13/cobra v1.2.1 | 	github.com/spf13/cobra v1.2.1 | ||||||
| 	github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5 | 	github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5 | ||||||
| 	golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 |  | ||||||
| 	golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 | 	golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 | ||||||
| 	golang.zx2c4.com/wireguard/wgctrl v0.0.0-20211124212657-dd7407c86d22 | 	golang.zx2c4.com/wireguard/wgctrl v0.0.0-20211124212657-dd7407c86d22 | ||||||
|  | 	honnef.co/go/tools v0.3.1 | ||||||
| 	k8s.io/api v0.23.6 | 	k8s.io/api v0.23.6 | ||||||
| 	k8s.io/apiextensions-apiserver v0.23.6 | 	k8s.io/apiextensions-apiserver v0.23.6 | ||||||
| 	k8s.io/apimachinery v0.23.6 | 	k8s.io/apimachinery v0.23.6 | ||||||
| @@ -27,6 +27,7 @@ require ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| require ( | require ( | ||||||
|  | 	github.com/BurntSushi/toml v0.4.1 // indirect | ||||||
| 	github.com/beorn7/perks v1.0.1 // indirect | 	github.com/beorn7/perks v1.0.1 // indirect | ||||||
| 	github.com/cespare/xxhash/v2 v2.1.1 // indirect | 	github.com/cespare/xxhash/v2 v2.1.1 // indirect | ||||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||||
| @@ -62,13 +63,14 @@ require ( | |||||||
| 	github.com/spf13/pflag v1.0.5 // indirect | 	github.com/spf13/pflag v1.0.5 // indirect | ||||||
| 	github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect | 	github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect | ||||||
| 	golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect | 	golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect | ||||||
| 	golang.org/x/mod v0.4.2 // indirect | 	golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect | ||||||
|  | 	golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect | ||||||
| 	golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect | 	golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect | ||||||
| 	golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect | 	golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect | ||||||
| 	golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect | 	golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect | ||||||
| 	golang.org/x/text v0.3.7 // indirect | 	golang.org/x/text v0.3.7 // indirect | ||||||
| 	golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect | 	golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect | ||||||
| 	golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff // indirect | 	golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a // indirect | ||||||
| 	golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect | 	golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect | ||||||
| 	golang.zx2c4.com/wireguard v0.0.0-20211123210315-387f7c461a16 // indirect | 	golang.zx2c4.com/wireguard v0.0.0-20211123210315-387f7c461a16 // indirect | ||||||
| 	google.golang.org/appengine v1.6.7 // indirect | 	google.golang.org/appengine v1.6.7 // indirect | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								tools.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								tools.go
									
									
									
									
									
								
							| @@ -19,7 +19,7 @@ package main | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	_ "github.com/campoy/embedmd" | 	_ "github.com/campoy/embedmd" | ||||||
| 	_ "golang.org/x/lint/golint" | 	_ "honnef.co/go/tools/cmd/staticcheck" | ||||||
| 	_ "k8s.io/code-generator/cmd/client-gen" | 	_ "k8s.io/code-generator/cmd/client-gen" | ||||||
| 	_ "k8s.io/code-generator/cmd/deepcopy-gen" | 	_ "k8s.io/code-generator/cmd/deepcopy-gen" | ||||||
| 	_ "k8s.io/code-generator/cmd/informer-gen" | 	_ "k8s.io/code-generator/cmd/informer-gen" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user