update golangci-lint v1.49.0

This commit is contained in:
yugo kobayashi
2022-09-22 12:56:15 +00:00
parent e62480d11c
commit 401cf9579c
15 changed files with 49 additions and 41 deletions

View File

@@ -14,7 +14,6 @@ linters:
- bodyclose - bodyclose
- contextcheck - contextcheck
# - cyclop # - cyclop
- deadcode
- depguard - depguard
- dogsled - dogsled
- dupl - dupl
@@ -71,7 +70,6 @@ linters:
- rowserrcheck - rowserrcheck
- sqlclosecheck - sqlclosecheck
- staticcheck - staticcheck
- structcheck
# - stylecheck # - stylecheck
- tagliatelle - tagliatelle
- tenv - tenv
@@ -82,12 +80,16 @@ linters:
- unconvert - unconvert
- unparam - unparam
- unused - unused
- varcheck
# - varnamelen # - varnamelen
- wastedassign - wastedassign
- whitespace - whitespace
- wrapcheck - wrapcheck
# - wsl # - wsl
- asasalint
- usestdlibvars
- interfacebloat
- logrlint
- reassign
linters-settings: linters-settings:
dupl: dupl:

View File

@@ -1,6 +1,8 @@
# Copyright 2022 The Kubernetes Authors. # Copyright 2022 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
GOLANGCI_LINT_VERSION=v1.49.0
MYGOBIN = $(shell go env GOBIN) MYGOBIN = $(shell go env GOBIN)
ifeq ($(MYGOBIN),) ifeq ($(MYGOBIN),)
MYGOBIN = $(shell go env GOPATH)/bin MYGOBIN = $(shell go env GOPATH)/bin
@@ -28,7 +30,7 @@ uninstall-out-of-tree-tools:
rm -f $(MYGOBIN)/stringer rm -f $(MYGOBIN)/stringer
$(MYGOBIN)/golangci-lint: $(MYGOBIN)/golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2 go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
$(MYGOBIN)/mdrip: $(MYGOBIN)/mdrip:
go install github.com/monopole/mdrip@v1.0.2 go install github.com/monopole/mdrip@v1.0.2

View File

@@ -692,7 +692,7 @@ resources:
th.AssertActualEqualsExpected(m, namespaceNeedInVarExpectedOutput) th.AssertActualEqualsExpected(m, namespaceNeedInVarExpectedOutput)
} }
// nolint:gosec //nolint:gosec
const namespaceNeedInVarMyAppWithNamespace string = ` const namespaceNeedInVarMyAppWithNamespace string = `
resources: resources:
- elasticsearch-dev-service.yaml - elasticsearch-dev-service.yaml

View File

@@ -301,7 +301,7 @@ func TestGetMatchingResourcesByCurrentId(t *testing.T) {
t.Fatalf("Expected single map entry but got %v", result) t.Fatalf("Expected single map entry but got %v", result)
} }
// nolint:goconst //nolint:goconst
tests := []struct { tests := []struct {
name string name string
matcher IdMatcher matcher IdMatcher

View File

@@ -71,7 +71,7 @@ type HelmChart struct {
// IncludeCRDs specifies if Helm should also generate CustomResourceDefinitions. // IncludeCRDs specifies if Helm should also generate CustomResourceDefinitions.
// Defaults to 'false'. // Defaults to 'false'.
IncludeCRDs bool `json:"includeCRDs,omitempty" yaml:"includeCRDs,omitempty"` // nolint: tagliatelle IncludeCRDs bool `json:"includeCRDs,omitempty" yaml:"includeCRDs,omitempty"` //nolint: tagliatelle
} }
// HelmChartArgs contains arguments to helm. // HelmChartArgs contains arguments to helm.

View File

@@ -106,7 +106,7 @@ func (r *XArgsRunner) runE(c *cobra.Command, _ []string) error {
return fmt.Errorf("must specify -- before command") return fmt.Errorf("must specify -- before command")
} }
r.Args = r.Args[cmdIndex:] r.Args = r.Args[cmdIndex:]
run := exec.Command(r.Args[0]) // nolint: gosec run := exec.Command(r.Args[0]) //nolint: gosec
if len(r.Args) > 1 { if len(r.Args) > 1 {
r.Args = r.Args[cmdIndex+1:] r.Args = r.Args[cmdIndex+1:]

View File

@@ -719,7 +719,7 @@ metadata:
} }
args := append([]string{"fn", "run", "."}, tt.args(binDir)...) args := append([]string{"fn", "run", "."}, tt.args(binDir)...)
cmd := exec.Command(filepath.Join(binDir, kyamlBin), args...) // nolint: gosec cmd := exec.Command(filepath.Join(binDir, kyamlBin), args...) //nolint: gosec
cmd.Dir = dir cmd.Dir = dir
var stdErr, stdOut bytes.Buffer var stdErr, stdOut bytes.Buffer
cmd.Stdout = &stdOut cmd.Stdout = &stdOut
@@ -761,7 +761,7 @@ func build() string {
panic(err) panic(err)
} }
build := exec.Command("go", "build", "-o", // nolint: gosec build := exec.Command("go", "build", "-o", //nolint: gosec
filepath.Join(binDir, e2econtainerconfigBin)) filepath.Join(binDir, e2econtainerconfigBin))
build.Dir = "e2econtainerconfig" build.Dir = "e2econtainerconfig"
build.Stdout = os.Stdout build.Stdout = os.Stdout
@@ -773,7 +773,7 @@ func build() string {
panic(err) panic(err)
} }
build = exec.Command("go", "build", "-o", filepath.Join(binDir, kyamlBin)) // nolint: gosec build = exec.Command("go", "build", "-o", filepath.Join(binDir, kyamlBin)) //nolint: gosec
build.Dir = filepath.Join("..", "..", "..", "kubectl-krm") build.Dir = filepath.Join("..", "..", "..", "kubectl-krm")
build.Stdout = os.Stdout build.Stdout = os.Stdout
build.Stderr = os.Stderr build.Stderr = os.Stderr

View File

@@ -1,6 +1,5 @@
// Copyright 2019 The Kubernetes Authors. // Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
//
package commands package commands
import ( import (
@@ -100,7 +99,7 @@ func (r *GrepRunner) preRunE(c *cobra.Command, args []string) error {
r.Value = last[1] r.Value = last[1]
} }
r.Path = append(parts[:len(parts)-1], last[0]) // nolint:gocritic r.Path = append(parts[:len(parts)-1], last[0]) //nolint:gocritic
return nil return nil
} }

View File

@@ -8,7 +8,7 @@ import (
func init() { func init() {
data := "PK\x03\x04\x14\x00\x08\x00\x08\x00H\x08\x1aU\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00 \x00go.mod.srcUT\x05\x00\x01\x98\x1b\x08ct\xca\xb1\x0e\xc2 \x10\x06\xe0\xb9\xf7\x14\x8c\xba\xfc\x80U\xa3\x8fC+\xe2\x85\xe2U\xae4\xd1\xa77\xc6\xc9\xc1\xf9\xfb\x8a\\\xda\x14M |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7'i \xff\xf4|\xa5\xba\x8drI\xdaFc\x05\x12%~\x17\xe4\xd7G\x1d\xc5\xaf9g{\xbe\xe7\xff\x05\x00\x00\xff\xffPK\x07\x08P\xaa\x84\xd0\x8f\x02\x00\x00\xaa\x05\x00\x00PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00H\x08\x1aU`;Y\xf4u\x00\x00\x00\xa1\x00\x00\x00\n\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00go.mod.srcUT\x05\x00\x01\x98\x1b\x08cPK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00l\xab\xc2TP\xaa\x84\xd0\x8f\x02\x00\x00\xaa\x05\x00\x00\x07\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa0\x81\xb6\x00\x00\x00main.goUT\x05\x00\x01<+\x99bPK\x05\x06\x00\x00\x00\x00\x02\x00\x02\x00\x7f\x00\x00\x00\x83\x03\x00\x00\x00\x00" data := "PK\x03\x04\x14\x00\x08\x00\x08\x00qa6U\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00 \x00go.mod.srcUT\x05\x00\x01\xf7P,ct\xca\xb1\x0e\xc2 \x10\x06\xe0\xb9\xf7\x14\x8c\xba\xfc\x80U\xa3\x8fC+\xe2\x85\xe2U\xae4\xd1\xa77\xc6\xc9\xc1\xf9\xfb\x8a\\\xda\x14M |'Jb<\xfc\x81\xa8\xc6G\xe3\x1a\xcd\x86\xba\xc4\xcb\xad\x0d\x18\xa5X\x9d\xaf\xbe\xb7\xa3\x0c5\x98\xd5\xc3\xc1Q\xa7\x9c\x14\xf9\xa4`\xb1\xb9\xe9\"\x85_\xd1\x86\x99\xcd\xeap\xc4\xfe\xdf\xc8\xcfP\xa6\xcf9\xa3\xff=_\xf0\xd8\xc1\xd1\x96\xe8\x1d\x00\x00\xff\xffPK\x07\x08`;Y\xf4u\x00\x00\x00\xa1\x00\x00\x00PK\x03\x04\x14\x00\x08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8'p\xb6\xc3\x04\xfa\x9c\xe4\\\x87d\xa4\x1a\x98\x06oI\x95\xb3\xb1\x03\x8e\x92\xe41,y\xd8\xf0R\x87\xb8<@\x16\x9d-EJN\xd0\xc97\xfc\xf2\xf2X\x0eH\xe4(\xc5\x9b\x82\xb9R~\x92^\x9e\xac\x8d;&\x877\xfd\xff\x82\\{s\xed*\xbc5\xba\xc43\x11\xf9=b\x1br\xce\x98\xae{\x96\x9ff`\xb5\xe9\xc9\x19a\xec\xc8\xa6g\xce\xd8\x9e3V\xa9\xa8\xee\x95\xe9\xf0T\xf1\x89+\xf9\x88\xda\x8d9\xc8>C\x91\xa5\xa1,\x97\xfd\x9c\xbc\x8d\xa4m#\xde'\xc8\x19K\x88\xd9X\xa1\xb1;\xe2\xec\xa2\x13\xf8\xeb\xef\xd5.\xa28\xee\x96\xbf\x8f\xbc\xc7\xc4 \xb8M\xdf\xc1AA\x8c\xe5\xb8#eC\xed\xa8E\x1aN\x9b\x7fJ\xc0\x9egX)>a\xc4p\x85$\xfb\x92\xee\xb9p\xaf\xbc\x074\x01A\xd7\xd0\xbc\xb2\xc07\xb4H\xa9z\xff\x93?=\xf9\x0c\x9a\x03\x12\xc5\x8f\xe8\xf3\xa1;\xcfj\x00\xfd=\xaf\x92\x7fw\xd2\x97\x9c\x1f9\xac6\x9c\xeds~\xd09\xeb\xf6\xd7G,\xbb\x88\xe2\xe7c\xf7'i \xff\xf4|\xa5\xba\x8drI\xdaFc\x05\x12%~\x17\xe4\xd7G\x1d\xc5\xaf9g{\xbe\xe7\xff\x05\x00\x00\xff\xffPK\x07\x08P\xaa\x84\xd0\x8f\x02\x00\x00\xaa\x05\x00\x00PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00qa6U`;Y\xf4u\x00\x00\x00\xa1\x00\x00\x00\n\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00go.mod.srcUT\x05\x00\x01\xf7P,cPK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00qa6UP\xaa\x84\xd0\x8f\x02\x00\x00\xaa\x05\x00\x00\x07\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\xb6\x00\x00\x00main.goUT\x05\x00\x01\xf7P,cPK\x05\x06\x00\x00\x00\x00\x02\x00\x02\x00\x7f\x00\x00\x00\x83\x03\x00\x00\x00\x00"
fs.Register(data) fs.Register(data)
} }

View File

@@ -903,7 +903,7 @@ func TestFileOps(t *testing.T) {
defer f.Close() defer f.Close()
for { for {
buf := make([]byte, rand.Intn(10)) // nolint:gosec buf := make([]byte, rand.Intn(10)) //nolint:gosec
n, err := f.Read(buf) n, err := f.Read(buf)
if err != nil && err != io.EOF { if err != nil && err != io.EOF {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)

View File

@@ -74,30 +74,30 @@ func PathJoin(incoming []string) string {
// //
// E.g. if part == 'PEACH' // E.g. if part == 'PEACH'
// //
// OLD : NEW : POS // OLD : NEW : POS
// -------------------------------------------------------- // --------------------------------------------------------
// {empty} : PEACH : irrelevant // {empty} : PEACH : irrelevant
// / : /PEACH : irrelevant // / : /PEACH : irrelevant
// pie : PEACH/pie : 0 (or negative) // pie : PEACH/pie : 0 (or negative)
// /pie : /PEACH/pie : 0 (or negative) // /pie : /PEACH/pie : 0 (or negative)
// raw : raw/PEACH : 1 (or larger) // raw : raw/PEACH : 1 (or larger)
// /raw : /raw/PEACH : 1 (or larger) // /raw : /raw/PEACH : 1 (or larger)
// a/nice/warm/pie : a/nice/warm/PEACH/pie : 3 // a/nice/warm/pie : a/nice/warm/PEACH/pie : 3
// /a/nice/warm/pie : /a/nice/warm/PEACH/pie : 3 // /a/nice/warm/pie : /a/nice/warm/PEACH/pie : 3
// //
// * An empty part results in no change. // * An empty part results in no change.
// //
// * Absolute paths get their leading '/' stripped, treated like // - Absolute paths get their leading '/' stripped, treated like
// relative paths, and the leading '/' is re-added on output. // relative paths, and the leading '/' is re-added on output.
// The meaning of pos is intentionally the same in either absolute or // The meaning of pos is intentionally the same in either absolute or
// relative paths; if it weren't, this function could convert absolute // relative paths; if it weren't, this function could convert absolute
// paths to relative paths, which is not desirable. // paths to relative paths, which is not desirable.
// //
// * For robustness (liberal input, conservative output) Pos values that // - For robustness (liberal input, conservative output) Pos values that
// that are too small (large) to index the split filepath result in a // that are too small (large) to index the split filepath result in a
// prefix (postfix) rather than an error. Use extreme position values // prefix (postfix) rather than an error. Use extreme position values
// to assure a prefix or postfix (e.g. 0 will always prefix, and // to assure a prefix or postfix (e.g. 0 will always prefix, and
// 9999 will presumably always postfix). // 9999 will presumably always postfix).
func InsertPathPart(path string, pos int, part string) string { func InsertPathPart(path string, pos int, part string) string {
if part == "" { if part == "" {
return path return path
@@ -121,7 +121,7 @@ func InsertPathPart(path string, pos int, part string) string {
result := make([]string, len(parts)+1) result := make([]string, len(parts)+1)
copy(result, parts[0:pos]) copy(result, parts[0:pos])
result[pos] = part result[pos] = part
return PathJoin(append(result, parts[pos:]...)) // nolint: makezero return PathJoin(append(result, parts[pos:]...)) //nolint: makezero
} }
func IsHiddenFilePath(pattern string) bool { func IsHiddenFilePath(pattern string) bool {

View File

@@ -82,7 +82,7 @@ type KRMFunctionVersion struct {
type KRMFunctionValidation struct { type KRMFunctionValidation struct {
// OpenAPIV3Schema is the OpenAPI v3 schema for an instance of the KRM function. // OpenAPIV3Schema is the OpenAPI v3 schema for an instance of the KRM function.
OpenAPIV3Schema *spec.Schema `yaml:"openAPIV3Schema,omitempty" json:"openAPIV3Schema,omitempty"` // nolint: tagliatelle OpenAPIV3Schema *spec.Schema `yaml:"openAPIV3Schema,omitempty" json:"openAPIV3Schema,omitempty"` //nolint: tagliatelle
} }
type KRMFunctionNames struct { type KRMFunctionNames struct {

View File

@@ -34,7 +34,7 @@ func (c *Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
} }
func (c *Filter) Run(reader io.Reader, writer io.Writer) error { func (c *Filter) Run(reader io.Reader, writer io.Writer) error {
cmd := exec.Command(c.Path, c.Args...) // nolint:gosec cmd := exec.Command(c.Path, c.Args...) //nolint:gosec
cmd.Stdin = reader cmd.Stdin = reader
cmd.Stdout = writer cmd.Stdout = writer
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr

View File

@@ -204,7 +204,7 @@ func (s *StorageMount) String() string {
func GetFunctionSpec(n *yaml.RNode) (*FunctionSpec, error) { func GetFunctionSpec(n *yaml.RNode) (*FunctionSpec, error) {
meta, err := n.GetMeta() meta, err := n.GetMeta()
if err != nil { if err != nil {
return nil, nil return nil, fmt.Errorf("failed to get ResourceMeta: %w", err)
} }
fn, err := getFunctionSpecFromAnnotation(n, meta) fn, err := getFunctionSpecFromAnnotation(n, meta)
@@ -237,7 +237,10 @@ func getFunctionSpecFromAnnotation(n *yaml.RNode, meta yaml.ResourceMeta) (*Func
} }
} }
n, err := n.Pipe(yaml.Lookup("metadata", "configFn")) n, err := n.Pipe(yaml.Lookup("metadata", "configFn"))
if err != nil || yaml.IsMissingOrNull(n) { if err != nil {
return nil, fmt.Errorf("failed to LookUp configFn: %w", err)
}
if yaml.IsMissingOrNull(n) {
return nil, nil return nil, nil
} }
s, err := n.String() s, err := n.String()

View File

@@ -281,7 +281,8 @@ metadata:
out: []string{"gcr.io/example.com/image:v1.0.0"}, out: []string{"gcr.io/example.com/image:v1.0.0"},
}, },
{name: "no function spec", {
name: "no function spec",
in: []f{ in: []f{
{ {
explicitFunction: true, explicitFunction: true,
@@ -290,6 +291,7 @@ foo: bar
`, `,
}, },
}, },
error: "failed to get FunctionSpec: failed to get ResourceMeta: missing Resource metadata",
}, },
// Test // Test