release-1.15: Fix lint issues for golangci-lint v1.64.6#9648
release-1.15: Fix lint issues for golangci-lint v1.64.6#9648kaovilai wants to merge 1 commit intovelero-io:release-1.15from
Conversation
|
was just cleaning up my opened draft PRs from way back. |
There was a problem hiding this comment.
Pull request overview
This PR updates the repo to be clean under newer golangci-lint (v1.64.6) by applying broad, mostly-mechanical lint fixes across production and test code (e.g., interface{} → any, removing redundant initializers, and tightening assertions).
Changes:
- Update
.golangci.yamlto align withgolangci-lintv1.64.6 and enable/adjust several linters/rules. - Apply repo-wide Go lint refactors (
any, inferred types, increment style, redundant checks) and targeted correctness fixes in tests. - Add overflow-safe int conversions (
min(..., math.MaxInt32)), small perf cleanups (e.g.,hex.EncodeToString), and assorted readability tweaks.
Reviewed changes
Copilot reviewed 173 out of 173 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/util/velero/velero_utils.go | Ignore map.Set return values explicitly and adjust comments/param naming. |
| test/util/velero/install.go | Mark unused parameter and ignore uninstall error explicitly. |
| test/util/report/report.go | Use map[string]any for report data. |
| test/util/providers/azure_utils.go | Remove redundant nil check before len(). |
| test/types.go | Use any in report inline map. |
| test/pkg/client/factory_test.go | Replace map[string]interface{} with map[string]any in tests. |
| test/pkg/client/config.go | Use any in VeleroConfig alias + doc update. |
| test/perf/metrics/monitor.go | Replace interface{} maps with any. |
| test/perf/e2e_suite_test.go | Replace interface{} map allocation with any. |
| test/e2e/basic/backup-volume-info/skipped_volumes.go | Replace brittle length assertion with BeEmpty() matcher. |
| test/e2e/basic/backup-volume-info/native_snapshot.go | Replace brittle length assertion with BeEmpty() matcher. |
| test/e2e/basic/backup-volume-info/filesystem_upload.go | Replace brittle length assertion with BeEmpty() matcher. |
| test/e2e/basic/backup-volume-info/csi_snapshot.go | Replace brittle length assertion with BeEmpty() matcher. |
| test/e2e/basic/backup-volume-info/csi_data_mover.go | Replace brittle length assertion with BeEmpty() matcher. |
| test/e2e/basic/api-group/enable_api_group_versions.go | Use any for JSON-unmarshaled structures. |
| pkg/util/third_party.go | Remove redundant explicit type in slice var declaration. |
| pkg/util/logging/error_location_hook_test.go | Replace interface{} maps with any in tests. |
| pkg/util/kube/pvc_pv.go | Drop explicit = nil slice initializers. |
| pkg/util/kube/mocks.go | Fix //go:generate directive formatting. |
| pkg/util/kube/event.go | Remove redundant explicit type in duration var declaration. |
| pkg/util/encode/encode.go | Change ToJSONGzip arg type to any. |
| pkg/util/csi/volume_snapshot_test.go | Fix test case name duplication wording. |
| pkg/util/csi/volume_snapshot.go | Replace n += 1 with n++. |
| pkg/uploader/provider/kopia.go | Change password getter param type to any. |
| pkg/uploader/mocks/uploader.go | Use []any in mock varargs handling. |
| pkg/uploader/kopia/snapshot_test.go | Use []any in mock return tables. |
| pkg/uploader/kopia/shim.go | Change manifest payload param types to any. |
| pkg/uploader/kopia/progress.go | Clamp int → int32 conversion and import math. |
| pkg/test/tar_writer.go | Change Add payload type to any. |
| pkg/test/mock_pod_command_executor.go | Change item map type to map[string]any. |
| pkg/test/helpers.go | Change JSON map helper return type to map[string]any. |
| pkg/test/fake_discovery_helper.go | Remove redundant nil checks before len(). |
| pkg/test/comparisons.go | Use any in test helpers (ValidatePatch, AssertDeepEqual). |
| pkg/restore/restore_test.go | Replace interface{} maps with any and fix comment typo. |
| pkg/restore/restore.go | Replace log fields map type with map[string]any; update map casting error msg. |
| pkg/restore/pv_restorer_test.go | Use any for unstructured test helpers. |
| pkg/restore/pv_restorer.go | Drop redundant = 0 initializer. |
| pkg/restore/merge_service_account.go | Update metadata map cast to map[string]any. |
| pkg/restore/actions/service_action_test.go | Update helper to use map[string]any. |
| pkg/restore/actions/service_action.go | Switch unmarshal targets/casts to map[string]any. |
| pkg/restore/actions/pod_volume_restore_action_test.go | Use map[string]any in unstructured conversions. |
| pkg/restore/actions/dataupload_retrieve_action_test.go | Use map[string]any in unstructured conversions. |
| pkg/restore/actions/csi/volumesnapshotcontent_action.go | Return type any for plugin initializer. |
| pkg/restore/actions/csi/volumesnapshotclass_action.go | Return type any for plugin initializer. |
| pkg/restore/actions/csi/volumesnapshot_action_test.go | Fix assert.Equalf message arg count. |
| pkg/restore/actions/csi/volumesnapshot_action.go | Fix multiline log string; return initializer type any. |
| pkg/restore/actions/csi/pvc_action.go | Return initializer type any. |
| pkg/restore/actions/crd_v1_preserve_unknown_fields_action.go | Change unstructured input map type to map[string]any. |
| pkg/restore/actions/change_storageclass_action_test.go | Use any for test table params/want. |
| pkg/restore/actions/change_storageclass_action.go | Use map[string]any in logger fields. |
| pkg/restore/actions/change_pvc_node_selector.go | Use map[string]any in logger fields. |
| pkg/restore/actions/change_image_name_action_test.go | Use any for test table params/want. |
| pkg/restore/actions/change_image_name_action.go | Switch container maps to map[string]any and update logger fields. |
| pkg/restore/actions/admissionwebhook_config_action_test.go | Use map[string]any when unmarshaling JSON. |
| pkg/restore/actions/admissionwebhook_config_action.go | Use []any for webhook slice. |
| pkg/repository/udmrepo/repo_options.go | Update interfaces and option funcs to use any parameters. |
| pkg/repository/udmrepo/repo.go | Change RepoManifest.Payload to any. |
| pkg/repository/udmrepo/kopialib/lib_repo.go | Clamp length int conversion; add unused param underscore; import math. |
| pkg/repository/provider/unified_repo_test.go | Use any in test tables/mocked return values. |
| pkg/repository/provider/unified_repo.go | Change provider getters to accept any. |
| pkg/podvolume/restorer.go | Use any in informer handler signatures. |
| pkg/podvolume/backupper.go | Use any in informer handler signatures. |
| pkg/podexec/pod_command_executor_test.go | Use map[string]any for item input in tests. |
| pkg/podexec/pod_command_executor.go | Use map[string]any in interface + implementation. |
| pkg/plugin/framework/volume_snapshotter_client.go | Change client init function return type to any. |
| pkg/plugin/framework/volume_snapshotter.go | Change GRPCClient return type to any. |
| pkg/plugin/framework/restoreitemaction/v2/restore_item_action_client.go | Change client init function return type to any. |
| pkg/plugin/framework/restoreitemaction/v2/restore_item_action.go | Change GRPCClient return type to any. |
| pkg/plugin/framework/restore_item_action_client.go | Change client init function return type to any. |
| pkg/plugin/framework/restore_item_action.go | Change GRPCClient return type to any. |
| pkg/plugin/framework/plugin_types_test.go | Use []any for plugin impl list in tests. |
| pkg/plugin/framework/plugin_lister.go | Change GRPCClient return type to any. |
| pkg/plugin/framework/object_store_client.go | Change client init function return type to any. |
| pkg/plugin/framework/object_store.go | Change GRPCClient return type to any. |
| pkg/plugin/framework/itemblockaction/v1/item_block_action_test.go | Use map[string]any for handlers map in tests. |
| pkg/plugin/framework/itemblockaction/v1/item_block_action_client.go | Change client init function return type to any. |
| pkg/plugin/framework/itemblockaction/v1/item_block_action.go | Change GRPCClient return type to any. |
| pkg/plugin/framework/examples_test.go | Change example plugin constructors to return any. |
| pkg/plugin/framework/delete_item_action_client.go | Change client init function return type to any. |
| pkg/plugin/framework/delete_item_action.go | Change GRPCClient return type to any. |
| pkg/plugin/framework/common/server_mux.go | Use any for handler initializer/handler maps and GetHandler return. |
| pkg/plugin/framework/common/server_errors.go | Clamp line number int conversion; import math. |
| pkg/plugin/framework/common/handle_panic.go | Change panic param type to any. |
| pkg/plugin/framework/common/client_errors.go | Replace single-case type switch with if type assertion. |
| pkg/plugin/framework/common/client_dispenser_test.go | Change init func type to return any. |
| pkg/plugin/framework/common/client_dispenser.go | Change ClientFor/init func/client map to use any. |
| pkg/plugin/framework/backupitemaction/v2/backup_item_action_test.go | Use map[string]any for handlers map in tests. |
| pkg/plugin/framework/backupitemaction/v2/backup_item_action_client.go | Change client init function return type to any. |
| pkg/plugin/framework/backupitemaction/v2/backup_item_action.go | Change GRPCClient return type to any. |
| pkg/plugin/framework/backup_item_action_test.go | Use map[string]any for handlers map in tests. |
| pkg/plugin/framework/backup_item_action_client.go | Change client init function return type to any. |
| pkg/plugin/framework/backup_item_action.go | Change GRPCClient return type to any. |
| pkg/plugin/clientmgmt/volumesnapshotter/v1/restartable_volume_snapshotter_test.go | Use any in tests for plugin values and inputs/outputs. |
| pkg/plugin/clientmgmt/volumesnapshotter/v1/restartable_volume_snapshotter.go | Change reinitializer arg type to any. |
| pkg/plugin/clientmgmt/restoreitemaction/v2/restartable_restore_item_action_test.go | Use any in tests for plugin values and inputs/outputs. |
| pkg/plugin/clientmgmt/restoreitemaction/v1/restartable_restore_item_action_test.go | Use any in tests for plugin values and inputs/outputs. |
| pkg/plugin/clientmgmt/restartable_object_store_test.go | Use any in tests for plugin values and inputs/outputs. |
| pkg/plugin/clientmgmt/restartable_object_store.go | Change reinitializer arg type to any. |
| pkg/plugin/clientmgmt/restartable_delete_item_action_test.go | Use any in tests for plugin values and inputs/outputs. |
| pkg/plugin/clientmgmt/process/restartable_process.go | Switch plugin storage/getters/reinitializer types to any. |
| pkg/plugin/clientmgmt/process/process_test.go | Switch mock dispense/client methods to any. |
| pkg/plugin/clientmgmt/process/process.go | Change dispense return type to any. |
| pkg/plugin/clientmgmt/process/logrus_adapter_test.go | Use []any and map[string]any in tests. |
| pkg/plugin/clientmgmt/process/logrus_adapter.go | Switch varargs plumbing to ...any and map values to any. |
| pkg/plugin/clientmgmt/manager_test.go | Use any in helper function signatures and expected action slices. |
| pkg/plugin/clientmgmt/itemblockaction/v1/restartable_item_block_action_test.go | Use any in tests for plugin values and inputs/outputs. |
| pkg/plugin/clientmgmt/backupitemaction/v2/restartable_backup_item_action_test.go | Use any in tests for plugin values and inputs/outputs. |
| pkg/plugin/clientmgmt/backupitemaction/v1/restartable_backup_item_action_test.go | Use any in tests for plugin values and inputs/outputs. |
| pkg/persistence/object_store.go | Use map[string]any in logging fields; decode target type any. |
| pkg/label/label.go | Use hex.EncodeToString instead of fmt.Sprintf for sha output. |
| pkg/itemblock/actions/pvc_action.go | Change initializer return type to any. |
| pkg/install/install.go | Switch internal log helper varargs to ...any. |
| pkg/exposer/snapshot.go | Update exposer interface param types to any. |
| pkg/exposer/generic_restore.go | Drop redundant = 0 initializer. |
| pkg/exposer/csi_snapshot.go | Update exposer impl method param types to any; drop redundant = 0. |
| pkg/datapath/types.go | Update async datapath interface param types to any. |
| pkg/datapath/micro_service_watcher.go | Update method/event handler param types to any; simplify timeout var decl. |
| pkg/datapath/file_system.go | Update method param types to any. |
| pkg/datamover/restore_micro_service.go | Update handler signatures to any. |
| pkg/datamover/backup_micro_service.go | Update handler signatures to any. |
| pkg/controller/restore_controller.go | Drop redundant = nil initializer. |
| pkg/controller/pod_volume_backup_controller_test.go | Update fake datapath impl param types to any. |
| pkg/controller/pod_volume_backup_controller.go | Use map[string]any in logger fields. |
| pkg/controller/data_upload_controller_test.go | Simplify error slice init; update fake interfaces to any. |
| pkg/controller/data_upload_controller.go | Change expose-param helper return types to any. |
| pkg/controller/data_download_controller_test.go | Simplify error slice init; fix assert.True misuse; comment unused helper. |
| pkg/controller/backup_sync_controller_test.go | Use sets.New(...) type inference; adjust loop variable capture. |
| pkg/controller/backup_sync_controller.go | Use sets.New(...) type inference. |
| pkg/controller/backup_repository_controller_test.go | Change mock helper arg/return types to any. |
| pkg/controller/backup_repository_controller.go | Use map[string]any for JSON-unmarshaled config. |
| pkg/controller/backup_deletion_controller.go | Remove redundant nil check before len(). |
| pkg/cmd/util/output/restore_describer.go | Adjust error handling around restore volume info download. |
| pkg/cmd/util/output/describe_test.go | Use map[string]any in structured output tests. |
| pkg/cmd/util/output/describe.go | Switch describer varargs to ...any; use map[string]any for structured output. |
| pkg/cmd/util/output/backup_structured_describer_test.go | Replace interface{} maps/slices with any in expected structures. |
| pkg/cmd/util/output/backup_structured_describer.go | Replace interface{} maps/slices with any in structured describers. |
| pkg/cmd/test/const.go | Drop redundant explicit types in const-like vars. |
| pkg/cmd/server/plugin/plugin.go | Change plugin constructors to return any. |
| pkg/cmd/errors.go | Switch Exit varargs to ...any. |
| pkg/cmd/const.go | Drop redundant explicit type in TRUE var. |
| pkg/cmd/cli/restore/create.go | Clean up doc whitespace; drop redundant = nil; update informer handler arg types to any. |
| pkg/cmd/cli/datamover/data_mover_test.go | Use []any in test cases. |
| pkg/cmd/cli/backup/create_test.go | Use strconv.Itoa and import strconv. |
| pkg/cmd/cli/backup/create.go | Update informer handler arg types to any. |
| pkg/client/factory_test.go | Replace map[string]interface{} with map[string]any in tests. |
| pkg/client/config.go | Use any in VeleroConfig alias + doc update. |
| pkg/backup/item_backupper.go | Use map[string]any in logger fields. |
| pkg/backup/backup_test.go | Replace interface{} with any in resource policy/test helpers. |
| pkg/backup/backup.go | Drop redundant = nil; use map[string]any in logger fields. |
| pkg/backup/actions/remap_crd_version_action_test.go | Update spec map cast to map[string]any. |
| pkg/backup/actions/csi/volumesnapshotcontent_action.go | Change constructor return type to any. |
| pkg/backup/actions/csi/volumesnapshotclass_action.go | Change constructor return type to any. |
| pkg/backup/actions/csi/volumesnapshot_action.go | Change initializer return type to any. |
| pkg/backup/actions/csi/pvc_action.go | Use strconv.Itoa; change initializer return type to any. |
| pkg/backup/actions/backup_pv_action_test.go | Replace unstructured maps with map[string]any. |
| internal/volumehelper/volume_policy_helper_test.go | Replace resource policy condition maps with map[string]any; drop redundant nil init. |
| internal/volumehelper/volume_policy_helper.go | Replace interface{} with any for resource value. |
| internal/volume/volumes_information.go | Drop redundant = 0 initializer. |
| internal/restartabletest/restartable_delegate.go | Replace interface{} with any in delegate harness. |
| internal/resourcepolicies/volume_resources_validator_test.go | Replace policy condition maps with map[string]any and any(...) casts. |
| internal/resourcepolicies/volume_resources_validator.go | Change decode target type to any. |
| internal/resourcepolicies/volume_resources_test.go | Replace input maps with map[string]any; remove redundant loop var copy. |
| internal/resourcepolicies/volume_resources.go | Update types/docs for map[string]any conditions. |
| internal/resourcepolicies/resource_policies_test.go | Replace policy condition maps with map[string]any and any(...) casts. |
| internal/resourcepolicies/resource_policies.go | Replace interface{} with any in policy structures and APIs. |
| internal/resourcemodifiers/strategic_merge_patch.go | Replace patch maps with map[string]any; simplify strict error handling. |
| internal/resourcemodifiers/resource_modifiers_test.go | Replace unstructured objects with map[string]any throughout tests. |
| internal/hook/wait_exec_hook_handler.go | Update informer handler arg types to any. |
| internal/delete/delete_item_action_handler_test.go | Fix comment typo. |
| internal/delete/actions/csi/volumesnapshotcontent_action.go | Change initializer return type to any. |
| internal/delete/actions/csi/volumesnapshot_action.go | Change initializer return type to any. |
| .golangci.yaml | Update linter configuration for golangci-lint v1.64.6 and adjust enabled linters/rules/exclusions. |
Comments suppressed due to low confidence (1)
pkg/cmd/util/output/restore_describer.go:195
- The
else if !errors.Is(err, downloadrequest.ErrNotFound)branch will also execute whenerris nil (sinceerrors.Is(nil, ...)is false), causing an incorrect "<error getting restore volume info: >" message to be printed. Keep theerr != nilguard (e.g.,else if err != nil && !errors.Is(...)).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ports, bool, err := unstructured.NestedSlice(*appliedServiceUnstructured, "spec", "ports") | ||
|
|
||
| if err != nil { | ||
| return errors.WithStack(err) | ||
| } | ||
|
|
||
| if bool { | ||
| for _, port := range ports { |
There was a problem hiding this comment.
Avoid naming this boolean return value bool. It shadows the predeclared bool identifier and makes the subsequent if bool { ... } hard to read/grep. Rename it to something like found/exists (and update the if accordingly).
6185ab2 to
a2d5f60
Compare
- Bump golangci-lint to v1.64.6 and update .golangci.yaml config
- Replace interface{} with any (Go 1.18+)
- Drop zero-value initializers (= 0, = nil) from var declarations
- Omit inferable types from var declarations
- Replace n += 1 with n++
- Replace single-case switch with if-then
- Fix useless assert.True calls in data_download_controller_test
- Fix assert.Equalf arg count in volumesnapshot_action_test
- Remove redundant nil checks before len()
- Fix go:generate directive spacing
- Add //nolint:gosec for test code
- Fix G115 integer overflow conversions
- Remove unused functions
- Fix unchecked error returns
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release-1.15 #9648 +/- ##
================================================
+ Coverage 59.10% 59.31% +0.20%
================================================
Files 367 367
Lines 39188 31118 -8070
================================================
- Hits 23162 18457 -4705
+ Misses 14545 11180 -3365
Partials 1481 1481 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Generated with Claude Code via Happy
Thank you for contributing to Velero!
Please add a summary of your change
Does your change fix a particular issue?
Fixes #(issue)
Please indicate you've done the following:
make new-changelog) or comment/kind changelog-not-requiredon this PR.site/content/docs/main.Replaces #8760