Skip to content

🐛 upgrade golangci-lint to v1.61.0 #2950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # tag=v6.1.0
with:
version: v1.57.2
version: v1.61.0
args: --out-format=colored-line-number
working-directory: ${{matrix.working-directory}}
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ linters:
- asciicheck
- bidichk
- bodyclose
- copyloopvar
- dogsled
- dupl
- errcheck
- errchkjson
- errorlint
- exhaustive
- exportloopref
- ginkgolinter
- goconst
- gocritic
Expand Down
6 changes: 3 additions & 3 deletions pkg/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
return obtainedPodNames
}, ConsistOf(tc.expectedPods)))
for _, pod := range obtainedStructuredPodList.Items {
Expect(informer.Get(context.Background(), client.ObjectKeyFromObject(&pod), &pod)).To(Succeed()) //nolint:gosec // We don't retain the pointer
Expect(informer.Get(context.Background(), client.ObjectKeyFromObject(&pod), &pod)).To(Succeed())
}

By("Checking with unstructured")
Expand All @@ -1564,7 +1564,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
return obtainedPodNames
}, ConsistOf(tc.expectedPods)))
for _, pod := range obtainedUnstructuredPodList.Items {
Expect(informer.Get(context.Background(), client.ObjectKeyFromObject(&pod), &pod)).To(Succeed()) //nolint:gosec // We don't retain the pointer
Expect(informer.Get(context.Background(), client.ObjectKeyFromObject(&pod), &pod)).To(Succeed())
}

By("Checking with metadata")
Expand All @@ -1584,7 +1584,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
return obtainedPodNames
}, ConsistOf(tc.expectedPods)))
for _, pod := range obtainedMetadataPodList.Items {
Expect(informer.Get(context.Background(), client.ObjectKeyFromObject(&pod), &pod)).To(Succeed()) //nolint:gosec // We don't retain the pointer
Expect(informer.Get(context.Background(), client.ObjectKeyFromObject(&pod), &pod)).To(Succeed())
}
},
Entry("when selectors are empty it has to inform about all the pods", selectorsTestCase{
Expand Down
1 change: 0 additions & 1 deletion pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,6 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
// Test this with an integrated type and a CRD to make sure it covers both proto
// and json deserialization.
for idx, object := range []client.Object{&corev1.ConfigMap{}, &pkg.ChaosPod{}} {
idx, object := idx, object
It(fmt.Sprintf("should not retain any data in the obj variable that is not on the server for %T", object), func() {
cl, err := client.New(cfg, client.Options{})
Expect(err).NotTo(HaveOccurred())
Expand Down
2 changes: 0 additions & 2 deletions pkg/envtest/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ func UninstallCRDs(config *rest.Config, options CRDInstallOptions) error {

// Uninstall each CRD
for _, crd := range options.CRDs {
crd := crd
log.V(1).Info("uninstalling CRD", "crd", crd.GetName())
if err := cs.Delete(context.TODO(), crd); err != nil {
// If CRD is not found, we can consider success
Expand All @@ -251,7 +250,6 @@ func CreateCRDs(config *rest.Config, crds []*apiextensionsv1.CustomResourceDefin

// Create each CRD
for _, crd := range crds {
crd := crd
log.V(1).Info("installing CRD", "crd", crd.GetName())
existingCrd := crd.DeepCopy()
err := cs.Get(context.TODO(), client.ObjectKey{Name: crd.GetName()}, existingCrd)
Expand Down
1 change: 0 additions & 1 deletion pkg/envtest/envtest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ var _ = Describe("Test", func() {
// Cleanup CRDs
AfterEach(func() {
for _, crd := range crds {
crd := crd
// Delete only if CRD exists.
crdObjectKey := client.ObjectKey{
Name: crd.GetName(),
Expand Down
2 changes: 0 additions & 2 deletions pkg/envtest/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,12 @@ func createWebhooks(config *rest.Config, mutHooks []*admissionv1.MutatingWebhook

// Create each webhook
for _, hook := range mutHooks {
hook := hook
log.V(1).Info("installing mutating webhook", "webhook", hook.GetName())
if err := ensureCreated(cs, hook); err != nil {
return err
}
}
for _, hook := range valHooks {
hook := hook
log.V(1).Info("installing validating webhook", "webhook", hook.GetName())
if err := ensureCreated(cs, hook); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/log/zap/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (ev *levelFlag) Set(flagValue string) error {
}
if logLevel > 0 {
intLevel := -1 * logLevel
ev.setFunc(zap.NewAtomicLevelAt(zapcore.Level(int8(intLevel))))
ev.setFunc(zap.NewAtomicLevelAt(zapcore.Level(int8(intLevel)))) //nolint:gosec // We are not worried about integer overflows (G115) here.
} else {
return fmt.Errorf("invalid log level \"%s\"", flagValue)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/admission/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func ValidationResponse(allowed bool, message string) Response {
AdmissionResponse: admissionv1.AdmissionResponse{
Allowed: allowed,
Result: &metav1.Status{
Code: int32(code),
Code: int32(code), //nolint:gosec // Integer overflows (G115) cannot occur here.
Reason: reason,
},
},
Expand Down
4 changes: 2 additions & 2 deletions tools/setup-envtest/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ func (s *Store) Add(ctx context.Context, item Item, contents io.Reader) (resErr
// preferfing our own scheme.
targetPath := filepath.Base(header.Name)
log.V(1).Info("writing archive file to disk", "archive file", header.Name, "on-disk file", targetPath)
perms := 0555 & header.Mode // make sure we're at most r+x
binOut, err := itemPath.OpenFile(targetPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.FileMode(perms))
perms := 0555 & header.Mode // make sure we're at most r+x
binOut, err := itemPath.OpenFile(targetPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.FileMode(perms)) //nolint:gosec // Integer overflows (G115) seem unlikely here.
if err != nil {
return fmt.Errorf("unable to create file %s from archive to disk for version-platform pair %s", targetPath, itemName)
}
Expand Down
Loading