Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to golangci-lint #1443

Merged
merged 7 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .docker/build_image_manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"github.com/kevinburke/go-bindata v3.15.0+incompatible"
"github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5"
"github.com/weaveworks/github-release v0.6.2"
"golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac"
"golang.org/x/tools v0.0.0-20191010075000-0337d82405ff"
"k8s.io/code-generator v0.0.0-20190831074504-732c9ca86353"
"k8s.io/code-generator v0.0.0-20190831074504-732c9ca86353"
"k8s.io/code-generator v0.0.0-20190831074504-732c9ca86353"
"k8s.io/code-generator v0.0.0-20190831074504-732c9ca86353"
"k8s.io/code-generator v0.0.0-20190831074504-732c9ca86353"
"github.com/golangci/golangci-lint v1.21.0"
100644 blob bb0ec393bec64fc65e97fde82edcbc22935f42bd Dockerfile
100644 blob 5377f63387890fa432473075d18c2a9cd23fcbd9 .requirements
100755 blob 63eeb505fa28cdddfd37b150c6e3c8103f791c02 install-build-deps.sh
100644 blob 07cb4cecc51d2b5015230d01a1ab699d6969dd56 .requirements
100755 blob 7b867a5b4a1ea544385441ecf9c1c1e5a1cce7e1 install-build-deps.sh
2 changes: 1 addition & 1 deletion .docker/image_tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15647ccf908a62f62a0539cad240b1f23bcf524d
9967465486cdded70c8609524c322c47f950955f
36 changes: 25 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ run:
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 5m
timeout: 5m
sayboras marked this conversation as resolved.
Show resolved Hide resolved

# exit code when at least one issue was found, default is 1
issues-exit-code: 1
Expand All @@ -27,6 +27,7 @@ run:
- ^pkg\/eks\/mocks$
- \/usr\/local\/go
- ^pkg\/testutils
- ^pkg\/drain

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
Expand All @@ -35,7 +36,12 @@ run:
skip-files:
# - ".*\\.my\\.go$"
# - lib/bad.go
- pkg/nodebootstrap/assets.go
- ^pkg\/nodebootstrap\/assets.go
- ^pkg\/testutils\/(ginkgo|client).go
- ^pkg\/testutils\/mockprovider\/mock_provider.go
- ^pkg\/cfn\/template\/matchers\/matchers.go
- ^integration\/matchers\/matchers.go
- ^integration\/runner\/runner.go


# output configuration options
Expand All @@ -62,7 +68,7 @@ linters-settings:
check-blank: false
govet:
# report about shadowed variables
check-shadowing: true
check-shadowing: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this one changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this lint is to check shadow declaration of variable. Lot of times we re-declare err by using := operator.

Let me know if you want to fix it, I can make the changes.

time "/Users/tammach/go/bin/golangci-lint" run
pkg/gitops/flux/installer.go:166:5         govet  shadow: declaration of "err" shadows declaration at line 133
pkg/gitops/flux/installer.go:172:6         govet  shadow: declaration of "err" shadows declaration at line 133
pkg/gitops/flux/installer.go:182:5         govet  shadow: declaration of "err" shadows declaration at line 133
pkg/gitops/profile.go:52:5                 govet  shadow: declaration of "err" shadows declaration at line 46
pkg/addons/vpc_controller.go:98:7          govet  shadow: declaration of "err" shadows declaration at line 87
pkg/nodebootstrap/userdata.go:104:5        govet  shadow: declaration of "err" shadows declaration at line 96
pkg/kubernetes/client.go:313:6             govet  shadow: declaration of "err" shadows declaration at line 308
pkg/kubernetes/client.go:357:6             govet  shadow: declaration of "err" shadows declaration at line 351
pkg/kubernetes/client.go:395:6             govet  shadow: declaration of "err" shadows declaration at line 351
pkg/eks/api.go:206:5                       govet  shadow: declaration of "err" shadows declaration at line 196
pkg/ctl/create/cluster.go:112:5            govet  shadow: declaration of "err" shadows declaration at line 94
pkg/ctl/create/cluster.go:116:5            govet  shadow: declaration of "err" shadows declaration at line 94
pkg/ctl/create/cluster.go:134:7            govet  shadow: declaration of "err" shadows declaration at line 94
pkg/ctl/create/cluster.go:375:7            govet  shadow: declaration of "err" shadows declaration at line 346
pkg/ctl/create/cluster.go:381:7            govet  shadow: declaration of "err" shadows declaration at line 346
pkg/ctl/create/cluster.go:384:7            govet  shadow: declaration of "err" shadows declaration at line 346
pkg/ctl/create/fargate.go:65:5             govet  shadow: declaration of "err" shadows declaration at line 61
pkg/ctl/create/fargate.go:69:9             govet  shadow: declaration of "err" shadows declaration at line 61
pkg/ctl/create/fargate.go:81:5             govet  shadow: declaration of "err" shadows declaration at line 61
pkg/ctl/create/iamidentitymapping.go:56:5  govet  shadow: declaration of "err" shadows declaration at line 51
pkg/ctl/create/iamidentitymapping.go:68:5  govet  shadow: declaration of "err" shadows declaration at line 51
pkg/ctl/create/iamidentitymapping.go:76:9  govet  shadow: declaration of "err" shadows declaration at line 51
pkg/ctl/create/iamserviceaccount.go:71:5   govet  shadow: declaration of "err" shadows declaration at line 65
pkg/ctl/create/iamserviceaccount.go:75:9   govet  shadow: declaration of "err" shadows declaration at line 65
pkg/ctl/create/nodegroup.go:86:5           govet  shadow: declaration of "err" shadows declaration at line 80
pkg/ctl/create/nodegroup.go:90:9           govet  shadow: declaration of "err" shadows declaration at line 80
pkg/ctl/create/nodegroup.go:94:5           govet  shadow: declaration of "err" shadows declaration at line 80
pkg/ctl/delete/cluster.go:92:5             govet  shadow: declaration of "err" shadows declaration at line 86
pkg/ctl/delete/cluster.go:97:5             govet  shadow: declaration of "err" shadows declaration at line 86
pkg/ctl/delete/cluster.go:101:9            govet  shadow: declaration of "err" shadows declaration at line 86
pkg/ctl/delete/fargate.go:58:5             govet  shadow: declaration of "err" shadows declaration at line 54
pkg/ctl/delete/iamidentitymapping.go:53:5  govet  shadow: declaration of "err" shadows declaration at line 47
pkg/ctl/delete/iamidentitymapping.go:64:9  govet  shadow: declaration of "err" shadows declaration at line 47
pkg/ctl/delete/iamidentitymapping.go:76:5  govet  shadow: declaration of "err" shadows declaration at line 47
pkg/ctl/delete/iamserviceaccount.go:71:5   govet  shadow: declaration of "err" shadows declaration at line 65
pkg/ctl/delete/nodegroup.go:62:5           govet  shadow: declaration of "err" shadows declaration at line 56
pkg/ctl/delete/nodegroup.go:66:9           govet  shadow: declaration of "err" shadows declaration at line 56
pkg/ctl/drain/nodegroup.go:58:5            govet  shadow: declaration of "err" shadows declaration at line 52
pkg/ctl/drain/nodegroup.go:62:9            govet  shadow: declaration of "err" shadows declaration at line 52
pkg/ctl/enable/profile.go:87:5             govet  shadow: declaration of "err" shadows declaration at line 83
pkg/ctl/enable/repo.go:54:5                govet  shadow: declaration of "err" shadows declaration at line 50
pkg/ctl/enable/utils.go:18:5               govet  shadow: declaration of "err" shadows declaration at line 14
pkg/ctl/get/fargate.go:64:5                govet  shadow: declaration of "err" shadows declaration at line 60
pkg/ctl/get/iamidentitymapping.go:57:5     govet  shadow: declaration of "err" shadows declaration at line 52
pkg/ctl/get/iamserviceaccount.go:63:5      govet  shadow: declaration of "err" shadows declaration at line 58
pkg/ctl/get/iamserviceaccount.go:67:9      govet  shadow: declaration of "err" shadows declaration at line 58
pkg/ctl/get/nodegroup.go:69:5              govet  shadow: declaration of "err" shadows declaration at line 64
pkg/ctl/scale/nodegroup.go:68:5            govet  shadow: declaration of "err" shadows declaration at line 63
pkg/ctl/update/cluster.go:63:5             govet  shadow: declaration of "err" shadows declaration at line 57
pkg/ctl/update/cluster.go:67:9             govet  shadow: declaration of "err" shadows declaration at line 57

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I wonder how this was working before 🤔 If there is a way to only allow shadowing err and ctx that would be nice. Otherwise let's leave it like that for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way that I am aware of. I think i just leave it for now :(


# Obtain type information from installed (to $GOPATH/pkg) package files:
# golangci-lint will execute `go install -i` and `go test -i` for analyzed packages
Expand Down Expand Up @@ -106,7 +112,7 @@ linters-settings:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale: UK
locale: default
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
Expand Down Expand Up @@ -144,11 +150,19 @@ linters-settings:


linters:
enable-all: true
disable:
disable-all: true
enable:
- gofmt
- unused
- govet
- golint
- errcheck
- deadcode
- misspell
- goimports
- maligned
- prealloc
- gocyclo # TODO: enable this in the future
- lll #TODO: enable this in the future
- gosec #TODO: enable this in the future
# TODO: enable the below linter in the future
# - maligned
# - prealloc
# - gocyclo
# - lll
# - gosec
21 changes: 0 additions & 21 deletions .gometalinter.json

This file was deleted.

1 change: 1 addition & 0 deletions .requirements
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ k8s.io/code-generator/cmd/deepcopy-gen
k8s.io/code-generator/cmd/defaulter-gen
k8s.io/code-generator/cmd/informer-gen
k8s.io/code-generator/cmd/lister-gen
github.com/golangci/golangci-lint/cmd/golangci-lint
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ endif

.PHONY: lint
lint: ## Run linter over the codebase
time "$(GOBIN)/gometalinter" ./pkg/... ./cmd/... ./integration/...
time "$(GOBIN)/golangci-lint" run

.PHONY: test
test:
Expand Down
7 changes: 4 additions & 3 deletions cmd/schema/generate.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package main

import (
"github.com/alecthomas/jsonschema"
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"io/ioutil"
"os"
"sigs.k8s.io/yaml"
"strings"

"github.com/alecthomas/jsonschema"
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"sigs.k8s.io/yaml"
)

func main() {
Expand Down
17 changes: 7 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/gobwas/glob v0.2.3
github.com/gofrs/flock v0.7.1 // indirect
github.com/gohugoio/hugo v0.55.6
github.com/google/btree v1.0.0 // indirect
github.com/golangci/golangci-lint v1.21.0
github.com/google/certificate-transparency-go v1.0.21 // indirect
github.com/goreleaser/goreleaser v0.110.0
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
Expand All @@ -48,24 +48,23 @@ require (
github.com/magiconair/properties v1.8.1 // indirect
github.com/mattn/go-zglob v0.0.1 // indirect
github.com/miekg/coredns v0.0.0-20170910182647-1b60688dc8f7 // indirect
github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega v1.5.0
github.com/onsi/ginkgo v1.10.1
sayboras marked this conversation as resolved.
Show resolved Hide resolved
github.com/onsi/gomega v1.7.0
github.com/pelletier/go-toml v1.4.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.8.1
github.com/pkg/sftp v1.8.3 // indirect
github.com/riywo/loginshell v0.0.0-20190610082906-2ed199a032f6
github.com/sanathkr/yaml v1.0.0 // indirect
github.com/sirupsen/logrus v1.4.2 // indirect

github.com/spf13/afero v1.2.2

github.com/spf13/cobra v0.0.4
github.com/spf13/cobra v0.0.5
sayboras marked this conversation as resolved.
Show resolved Hide resolved

github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.3.2
github.com/spf13/viper v1.4.0
sayboras marked this conversation as resolved.
Show resolved Hide resolved
github.com/spotinst/spotinst-sdk-go v0.0.0-20181012192533-fed4677dbf8f // indirect
github.com/stretchr/testify v1.3.0
github.com/stretchr/testify v1.4.0
sayboras marked this conversation as resolved.
Show resolved Hide resolved
github.com/tidwall/gjson v1.1.3
github.com/tidwall/match v1.0.0 // indirect
github.com/tidwall/sjson v1.0.2
Expand All @@ -77,9 +76,7 @@ require (
github.com/whilp/git-urls v0.0.0-20160530060445-31bac0d230fa
github.com/zmap/zlint v0.0.0-20190806182416-88c3f6b6f2f5 // indirect
go.etcd.io/bbolt v1.3.3 // indirect
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/zap v1.10.0 // indirect
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac
golang.org/x/tools v0.0.0-20191010075000-0337d82405ff
google.golang.org/grpc v1.21.1 // indirect
gopkg.in/gcfg.v1 v1.2.3 // indirect
gopkg.in/ini.v1 v1.42.0 // indirect
Expand Down
Loading