From af1e692a5ea940d3b5605635abbfbb72b57966ca Mon Sep 17 00:00:00 2001 From: Natasha Sarkar Date: Tue, 2 Mar 2021 14:39:23 -0800 Subject: [PATCH] fix lint error --- kyaml/.golangci.yml | 6 ++++-- kyaml/Makefile | 6 ++++-- kyaml/go.mod | 15 +++++++++++++++ kyaml/yaml/merge2/merge2.go | 6 +++--- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/kyaml/.golangci.yml b/kyaml/.golangci.yml index e19acd7fc..cd3cee6d4 100644 --- a/kyaml/.golangci.yml +++ b/kyaml/.golangci.yml @@ -3,6 +3,8 @@ run: deadline: 5m + skip-dirs: + - yaml/internal/k8sgen/pkg linters: # please, do not use `enable-all`: it's deprecated and will be removed soon. @@ -12,7 +14,7 @@ linters: - bodyclose - deadcode - depguard - - dogsled + # - dogsled # uncomment after upgrading golangci-lint (Issue #3663) - dupl - errcheck - gochecknoinits @@ -39,7 +41,7 @@ linters: - unparam - unused - varcheck - - whitespace + # - whitespace # uncomment after upgrading golangci-lint (Issue #3663) linters-settings: diff --git a/kyaml/Makefile b/kyaml/Makefile index c0caeafc8..e831cefef 100644 --- a/kyaml/Makefile +++ b/kyaml/Makefile @@ -9,8 +9,10 @@ export PATH := $(MYGOBIN):$(PATH) $(MYGOBIN)/addlicense: go get github.com/google/addlicense +# TODO: Issue #3663 +# Update this version of golangci-lint $(MYGOBIN)/golangci-lint: - go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1 + go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.17.0 $(MYGOBIN)/k8scopy: ( cd ../cmd/k8scopy; go install . ) @@ -30,9 +32,9 @@ clean: lint: $(MYGOBIN)/golangci-lint $(MYGOBIN)/golangci-lint \ - --skip-dirs $(k8sGenDir) \ run ./... + license: $(MYGOBIN)/addlicense $(MYGOBIN)/addlicense \ -y 2021 \ diff --git a/kyaml/go.mod b/kyaml/go.mod index 372756020..a3ed2d376 100644 --- a/kyaml/go.mod +++ b/kyaml/go.mod @@ -21,3 +21,18 @@ require ( gopkg.in/yaml.v2 v2.3.0 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c ) + +// These can be removed after upgrading golangci-lint (Issue #3663) +replace github.com/go-critic/go-critic v0.0.0-20181204210945-c3db6069acc5 => github.com/go-critic/go-critic v0.0.0-20190422201921-c3db6069acc5 + +replace github.com/golangci/errcheck v0.0.0-20181003203344-ef45e06d44b6 => github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6 + +replace github.com/golangci/go-tools v0.0.0-20180109140146-af6baa5dc196 => github.com/golangci/go-tools v0.0.0-20190318060251-af6baa5dc196 + +replace github.com/golangci/gofmt v0.0.0-20181105071733-0b8337e80d98 => github.com/golangci/gofmt v0.0.0-20181222123516-0b8337e80d98 + +replace github.com/golangci/gosec v0.0.0-20180901114220-66fb7fc33547 => github.com/golangci/gosec v0.0.0-20190211064107-66fb7fc33547 + +replace github.com/golangci/lint-1 v0.0.0-20180610141402-ee948d087217 => github.com/golangci/lint-1 v0.0.0-20190420132249-ee948d087217 + +replace mvdan.cc/unparam v0.0.0-20190124213536-fbb59629db34 => mvdan.cc/unparam v0.0.0-20190209190245-fbb59629db34 \ No newline at end of file diff --git a/kyaml/yaml/merge2/merge2.go b/kyaml/yaml/merge2/merge2.go index d0625bd7c..ab0c8244c 100644 --- a/kyaml/yaml/merge2/merge2.go +++ b/kyaml/yaml/merge2/merge2.go @@ -169,13 +169,13 @@ func (m Merger) SetComments(sources walk.Sources) error { // avoid panic return nil } - if source != nil && source.YNode().FootComment != "" { + if source.YNode().FootComment != "" { dest.YNode().FootComment = source.YNode().FootComment } - if source != nil && source.YNode().HeadComment != "" { + if source.YNode().HeadComment != "" { dest.YNode().HeadComment = source.YNode().HeadComment } - if source != nil && source.YNode().LineComment != "" { + if source.YNode().LineComment != "" { dest.YNode().LineComment = source.YNode().LineComment } return nil