fix lint error

This commit is contained in:
Natasha Sarkar
2021-03-02 14:39:23 -08:00
parent 57e7db0423
commit af1e692a5e
4 changed files with 26 additions and 7 deletions

View File

@@ -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:

View File

@@ -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 \

View File

@@ -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

View File

@@ -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