Update full linter list and enable some easily resolved new ones

This commit is contained in:
Katrina Verey
2022-03-30 14:07:54 -04:00
parent 0a9c5cb0cf
commit 71bf0d5d14
61 changed files with 185 additions and 184 deletions

View File

@@ -1,66 +0,0 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
run:
deadline: 5m
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
- depguard
- dogsled
- dupl
# - errcheck
- exportloopref
# - funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- nolintlint
- revive
- staticcheck
- structcheck
# - stylecheck # seems redundant with revive, which replaced golint
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
linters-settings:
dupl:
threshold: 400
lll:
line-length: 170
gocyclo:
min-complexity: 30
revive:
rules:
- name: var-naming
arguments:
- [ "ID", "API", "JSON" ] # AllowList
- [ ] # DenyList
gosec:
config:
G306: "0644"
issues:
exclude-rules:
- linters:
- revive
text: "don't use leading"

View File

@@ -37,7 +37,8 @@ lint: $(GOBIN)/golangci-lint
$(GOBIN)/golangci-lint \
--skip-dirs $(k8sGenDir) \
run ./... \
--path-prefix=cmd/config
--path-prefix=cmd/config \
-c ../../.golangci.yml
license: $(GOBIN)/addlicense
$(GOBIN)/addlicense \

View File

@@ -88,6 +88,7 @@ func TestAnnotateCommand(t *testing.T) {
}
func initTestDir(t *testing.T) string {
t.Helper()
d, err := ioutil.TempDir("", "kustomize-annotate-test")
if !assert.NoError(t, err) {
t.FailNow()

View File

@@ -166,7 +166,6 @@ func (r *CatRunner) catFilters() []kio.Filter {
return fltrs
}
// nolint
func (r *CatRunner) out(w io.Writer) ([]kio.Writer, error) {
var outputs []kio.Writer
var functionConfig *yaml.RNode

View File

@@ -36,6 +36,7 @@ type test struct {
}
func runTests(t *testing.T, tests []test) {
t.Helper()
dir := build()
bin := filepath.Join(dir, kyamlBin)

View File

@@ -46,7 +46,6 @@ See discussion in https://github.com/kubernetes-sigs/kustomize/issues/3953.`)
return err
}
// nolint
func (r *SinkRunner) runE(c *cobra.Command, args []string) error {
var outputs []kio.Writer
if len(args) == 1 {

View File

@@ -132,11 +132,11 @@ var StackOnError bool
const cmdName = "kustomize fn"
// FixDocs replaces instances of old with new in the docs for c
func FixDocs(new string, c *cobra.Command) {
c.Use = strings.ReplaceAll(c.Use, cmdName, new)
c.Short = strings.ReplaceAll(c.Short, cmdName, new)
c.Long = strings.ReplaceAll(c.Long, cmdName, new)
c.Example = strings.ReplaceAll(c.Example, cmdName, new)
func FixDocs(newStr string, c *cobra.Command) {
c.Use = strings.ReplaceAll(c.Use, cmdName, newStr)
c.Short = strings.ReplaceAll(c.Short, cmdName, newStr)
c.Long = strings.ReplaceAll(c.Long, cmdName, newStr)
c.Example = strings.ReplaceAll(c.Example, cmdName, newStr)
}
// containsString returns true if slice contains s

View File

@@ -12,6 +12,7 @@ import (
)
func makeTempDir(t *testing.T) string {
t.Helper()
s, err := ioutil.TempDir("", "pluginator-*")
assert.NoError(t, err)
return s
@@ -99,6 +100,7 @@ items:
}
func runKrmFunction(t *testing.T, input []byte, dir string) []byte {
t.Helper()
cmd := exec.Command("go", "run", ".")
ib := bytes.NewReader(input)
cmd.Stdin = ib