Skip to content

Commit

Permalink
Deprecate gometalinter and use golangcli-lint instead (kubeflow#56)
Browse files Browse the repository at this point in the history
*  Deprecate gometalinter and use golangcli-lint for lint

https://github.com/alecthomas/gometalinter has been deprecated and author suggest to use https://github.com/golangci/golangci-lint instead.

Migrate most of the linters to golangci-lint.

Remove original linter_config.json and add linter_config.yaml

Signed-off-by: Jiaxin Shan <[email protected]>

* Fix Error return value of not checked problems in tests

errcheck will report issue if return value is not used. One example is

pkg/controller.v1beta1/mxnet/pod_test.go:66:10: Error return value of `ctr.Run` is not checked (errcheck)
		ctr.Run(testutil.ThreadCount, stopCh)
		       ^

Signed-off-by: Jiaxin Shan <[email protected]>

* Update-codegen to update copyright header

Signed-off-by: Jiaxin Shan <[email protected]>
  • Loading branch information
Jeffwan authored Mar 2, 2020
1 parent 9f050f8 commit bc5506b
Show file tree
Hide file tree
Showing 46 changed files with 120 additions and 81 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ go_import_path: github.com/kubeflow/mxnet-operator
install:
# get coveralls.io support
- go get github.com/mattn/goveralls
- go get -u github.com/alecthomas/gometalinter
- gometalinter --install
# Install golangci-lint
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.7

script:
- hack/verify-codegen.sh
- go build -o mxnet-operator.v1beta1 github.com/kubeflow/mxnet-operator/cmd/mxnet-operator.v1beta1
- go build -o mxnet-operator.v1 github.com/kubeflow/mxnet-operator/cmd/mxnet-operator.v1
- gometalinter --config=linter_config.json --vendor ./...
- golangci-lint run --config=linter_config.yaml ./...
# We customize the build step because by default
# Travis runs go test -v ./... which will include the vendor
# directory.
Expand Down
31 changes: 0 additions & 31 deletions linter_config.json

This file was deleted.

50 changes: 50 additions & 0 deletions linter_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This file contains golangci-lint configurations

run:
# default concurrency is a available CPU number
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 300s

# exit code when at least one issue was found, default is 1
issues-exit-code: 1

# include test files or not, default is true
tests: true

# which dirs to skip: issues from them won't be reported;
# skip-dirs:
# - pkg/client
# - pkg/apis/mxnet/v1beta1/zz_generated.deepcopy.go
# - pkg/apis/mxnet/v1beta1/zz_generated.defaults.go

# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- bodyclose
- deadcode
- errcheck
- misspell
- lll
- typecheck
- unconvert
- unused
- varcheck
- govet
- staticcheck
linters-settings:
lll:
# max line length, lines longer will be reported. Default is 120.
line-length: 240

#
# "redundant return statement",
# "comment or be unexported",
# "comment on exported",
2 changes: 1 addition & 1 deletion pkg/apis/mxnet/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/mxnet/v1/zz_generated.defaults.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/mxnet/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/mxnet/v1beta1/zz_generated.defaults.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/clientset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/fake/clientset_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/fake/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/scheme/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/scheme/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/typed/mxnet/v1/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/typed/mxnet/v1/fake/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/typed/mxnet/v1/mxjob.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/typed/mxnet/v1beta1/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/informers/externalversions/factory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/informers/externalversions/generic.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/informers/externalversions/mxnet/interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/informers/externalversions/mxnet/v1/mxjob.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/listers/mxnet/v1/expansion_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/listers/mxnet/v1/mxjob.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/listers/mxnet/v1beta1/expansion_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/listers/mxnet/v1beta1/mxjob.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions pkg/controller.v1/mxnet/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ func TestAddMXJob(t *testing.T) {

stopCh := make(chan struct{})
run := func(<-chan struct{}) {
ctr.Run(testutil.ThreadCount, stopCh)
if err := ctr.Run(testutil.ThreadCount, stopCh); err != nil {
t.Errorf("Failed to run MXNet Controller!")
}
}
go run(stopCh)

Expand Down Expand Up @@ -135,7 +137,9 @@ func TestCopyLabelsAndAnnotation(t *testing.T) {

stopCh := make(chan struct{})
run := func(<-chan struct{}) {
ctr.Run(testutil.ThreadCount, stopCh)
if err := ctr.Run(testutil.ThreadCount, stopCh); err != nil {
t.Errorf("Failed to run MXNet Controller!")
}
}
go run(stopCh)

Expand Down
8 changes: 6 additions & 2 deletions pkg/controller.v1/mxnet/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ func TestAddPod(t *testing.T) {

stopCh := make(chan struct{})
run := func(<-chan struct{}) {
ctr.Run(testutil.ThreadCount, stopCh)
if err := ctr.Run(testutil.ThreadCount, stopCh); err != nil {
t.Errorf("Failed to run MXNet Controller!")
}
}
go run(stopCh)

Expand Down Expand Up @@ -187,7 +189,9 @@ func TestExitCode(t *testing.T) {

stopCh := make(chan struct{})
run := func(<-chan struct{}) {
ctr.Run(testutil.ThreadCount, stopCh)
if err := ctr.Run(testutil.ThreadCount, stopCh); err != nil {
t.Errorf("Failed to run MXNet Controller!")
}
}
go run(stopCh)

Expand Down
4 changes: 3 additions & 1 deletion pkg/controller.v1/mxnet/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ func TestAddService(t *testing.T) {

stopCh := make(chan struct{})
run := func(<-chan struct{}) {
ctr.Run(testutil.ThreadCount, stopCh)
if err := ctr.Run(testutil.ThreadCount, stopCh); err != nil {
t.Errorf("Failed to run MXNet Controller!")
}
}
go run(stopCh)

Expand Down
Loading

0 comments on commit bc5506b

Please sign in to comment.