Skip to content

Commit 4e73ead

Browse files
authored
Merge pull request kcp-dev#3874 from ntnn/bum-golangci-lint
Bump golangci-lint to v2.10.1
2 parents bfbfa31 + 2792a7e commit 4e73ead

File tree

34 files changed

+71
-67
lines changed

34 files changed

+71
-67
lines changed

.golangci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ linters:
7171
- G404 # Use of weak random number generator (use crypto/rand)
7272
- G101 # Potential hardcoded credentials (returns false positives)
7373
- G306 # Expect WriteFile permissions to be 0600 or less
74+
# gosec is currently producing a lot of false-positives on taint analysis.
75+
# see https://github.com/securego/gosec/issues/1500
76+
- G704
77+
- G705
7478
misspell:
7579
ignore-rules:
7680
- creater

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ YAML_PATCH_BIN := yaml-patch
5151
YAML_PATCH := $(TOOLS_DIR)/$(YAML_PATCH_BIN)-$(YAML_PATCH_VER)
5252
export YAML_PATCH # so hack scripts can use it
5353

54-
GOLANGCI_LINT_VER := 2.6.0
54+
GOLANGCI_LINT_VER := 2.10.1
5555
GOLANGCI_LINT_BIN := golangci-lint
5656
GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
5757
GOLANGCI_LINT_FLAGS ?=

cmd/cache-server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
func main() {
3838
rootDir := flag.String("root-directory", ".kcp-cache", "Path to the root directory where all files required by this server will be stored")
3939

40-
var cacheServerFlags, remainingFlags []string //nolint:prealloc
40+
var cacheServerFlags, remainingFlags []string
4141
for _, arg := range os.Args[1:] {
4242
if strings.HasPrefix(arg, "--root-directory") {
4343
cacheServerFlags = append(cacheServerFlags, arg)

cmd/kcp-front-proxy/options/options.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,5 @@ func (o *Options) Complete() error {
5858
}
5959

6060
func (o *Options) Validate() []error {
61-
var errs []error
62-
63-
errs = append(errs, o.Proxy.Validate()...)
64-
65-
return errs
61+
return o.Proxy.Validate()
6662
}

cmd/kcp/options/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (o *Options) Complete(ctx context.Context) (*CompletedOptions, error) {
8585
}
8686

8787
func (o *CompletedOptions) Validate() []error {
88-
errs := []error{}
88+
errs := []error{} //nolint:prealloc
8989

9090
errs = append(errs, o.Generic.Validate()...)
9191
errs = append(errs, o.Server.Validate()...)

hack/tools.checksums

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
controller-gen|GOARCH=amd64;GOOS=linux|21e5f3239666fc0c5e2d23c2a3a83fd655af40a969ede7a118b86832c35a829f
22
controller-gen|GOARCH=arm64;GOOS=darwin|2ca28be7185d9279ed82e3355529b0543938f392cb812add3f25a62196ed7441
33
controller-gen|GOARCH=arm64;GOOS=linux|a1a1f758435d05933c4b2f8c292f8ab2448e81a02c45f14dbd81c10e87ec4b20
4-
golangci-lint|GOARCH=amd64;GOOS=linux|f0cdf40b6c161524898d79cad40fa92d7fde7d4a5ecfa07360937160cb61fb2b
5-
golangci-lint|GOARCH=arm64;GOOS=darwin|2a2c09731f02f890aec506c2558c5eb67613aaf268806aa66956ee63858647fb
6-
golangci-lint|GOARCH=arm64;GOOS=linux|be2ea9fc5ecf9a64b7d1291a3b62694edbff3b3d29fe566a3e43ef2e89d4556d
4+
golangci-lint|GOARCH=amd64;GOOS=linux|8a01a08dad47a14824d7d0f14af07c7144105fc079386c9c31fbe85f08f91643
5+
golangci-lint|GOARCH=arm64;GOOS=darwin|5fd0b6a09353eb0101d3ae81d5e3cf4707b77210c66fb92ae152d7280d959419
6+
golangci-lint|GOARCH=arm64;GOOS=linux|2ed9cf2ad070dabc7947ba34cdc5142910be830306f063719898bc8fb44a7074
77
gotestsum|GOARCH=amd64;GOOS=linux|2e505a9368568aa7422e0a90ef77acc8807c0d3272ab81c7a69e3e8688d1cf65
88
gotestsum|GOARCH=arm64;GOOS=darwin|020be8d14358c7ac4155e296436057cf4b1f1232f8f8f3d71f22a0e7a5504340
99
gotestsum|GOARCH=arm64;GOOS=linux|2f8517768c2831750cb372e379404a059dbd20f2b1f79bcc235c4cab4540cb10

pkg/admission/apiexport/admission.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func validateOverhangingResourceSchemas(_ context.Context, _ admission.Attribute
168168
// converted to v1alpha2.
169169
if _, ok := ae.Annotations[apisv1alpha2.ResourceSchemasAnnotation]; ok {
170170
// validate if we can decode overhanging resource schemas. If not, we will fail.
171-
var overhanging []apisv1alpha2.ResourceSchema
171+
var overhanging []apisv1alpha2.ResourceSchema //nolint:prealloc
172172
if err := json.Unmarshal([]byte(ae.Annotations[apisv1alpha2.ResourceSchemasAnnotation]), &overhanging); err != nil {
173173
return field.Invalid(field.NewPath("metadata").Child("annotations").Key(apisv1alpha2.ResourceSchemasAnnotation), ae.Annotations[apisv1alpha2.ResourceSchemasAnnotation], "failed to decode overhanging resource schemas")
174174
}

pkg/authentication/index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (c *state) UpsertWorkspaceType(shard string, wst *tenancyv1alpha1.Workspace
7676

7777
clusterName := logicalcluster.From(wst)
7878

79-
authenticators := []authenticatorKey{}
79+
authenticators := make([]authenticatorKey, 0, len(wst.Spec.AuthenticationConfigurations))
8080
for _, authConfig := range wst.Spec.AuthenticationConfigurations {
8181
authenticators = append(authenticators, authenticatorKey{
8282
cluster: clusterName,

pkg/authorization/workspace_content_authorizer_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,14 @@ func TestWorkspaceContentAuthorizer(t *testing.T) {
329329
globalKubeClient := kcpfakeclient.NewSimpleClientset() // TODO(sttts): add some global fixtures
330330
local := kcpkubernetesinformers.NewSharedInformerFactory(localKubeClient, controller.NoResyncPeriodFunc())
331331
global := kcpkubernetesinformers.NewSharedInformerFactory(globalKubeClient, controller.NoResyncPeriodFunc())
332-
var syncs []cache.InformerSynced
333-
for _, inf := range []cache.SharedIndexInformer{
332+
informers := []cache.SharedIndexInformer{
334333
local.Rbac().V1().ClusterRoles().Informer(),
335334
local.Rbac().V1().ClusterRoleBindings().Informer(),
336335
global.Rbac().V1().ClusterRoles().Informer(),
337336
global.Rbac().V1().ClusterRoleBindings().Informer(),
338-
} {
337+
}
338+
syncs := make([]cache.InformerSynced, 0, len(informers))
339+
for _, inf := range informers {
339340
go inf.Run(ctx.Done())
340341
syncs = append(syncs, inf.HasSynced)
341342
}

pkg/cache/server/options/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type CompletedOptions struct {
5555
}
5656

5757
func (o *CompletedOptions) Validate() []error {
58-
errors := []error{}
58+
errors := []error{} //nolint:prealloc
5959
errors = append(errors, o.ServerRunOptions.Validate()...)
6060
errors = append(errors, o.Etcd.Validate()...)
6161
errors = append(errors, o.SecureServing.Validate()...)

0 commit comments

Comments
 (0)