Fix future gopls issues #1672

Merged
fyrchik merged 6 commits from fyrchik/frostfs-node:update-gopls into master 2025-03-13 08:12:21 +00:00
Owner

Updated to gopls 0.18.1, fixed most of the issues.
Some issues are still here, though:

pkg/local_object_storage/blobstor/blobovniczatree/control_test.go:141:6-31: for loop can be modernized using range over int
pkg/local_object_storage/engine/shards.go:303:2-307:3: Loop can be simplified using slices.ContainsFunc
pkg/util/logger/logger.go:150:4: unused write to field Level
pkg/util/logger/logger.go:151:4: unused write to field Encoding
pkg/network/group.go:37:2-41:3: Loop can be simplified using slices.ContainsFunc
pkg/services/control/server/evacuate_async.go:264:6-33: for loop can be modernized using range over int
cmd/frostfs-adm/internal/modules/config/config_test.go:38:6-51: for loop can be modernized using range over int
cmd/frostfs-node/config/node/config.go:92:2-96:3: Loop can be simplified using slices.ContainsFunc
  1. range over int: explicitly ignored with a comment in #1345.
  2. slices.ContainsFunc: we have functions like Iterate(func(..) bool). While we can currently use ContainsFunc for this, it feels wrong, because we do not use the return value.
  3. unused write: need investigation, #1673

Refs #1671

Updated to gopls 0.18.1, fixed most of the issues. Some issues are still here, though: ``` pkg/local_object_storage/blobstor/blobovniczatree/control_test.go:141:6-31: for loop can be modernized using range over int pkg/local_object_storage/engine/shards.go:303:2-307:3: Loop can be simplified using slices.ContainsFunc pkg/util/logger/logger.go:150:4: unused write to field Level pkg/util/logger/logger.go:151:4: unused write to field Encoding pkg/network/group.go:37:2-41:3: Loop can be simplified using slices.ContainsFunc pkg/services/control/server/evacuate_async.go:264:6-33: for loop can be modernized using range over int cmd/frostfs-adm/internal/modules/config/config_test.go:38:6-51: for loop can be modernized using range over int cmd/frostfs-node/config/node/config.go:92:2-96:3: Loop can be simplified using slices.ContainsFunc ``` 1. `range over int`: explicitly ignored with a comment in #1345. 2. `slices.ContainsFunc`: we have functions like `Iterate(func(..) bool)`. While we can currently use `ContainsFunc` for this, it feels wrong, because we do not use the return value. 3. `unused write`: need investigation, #1673 Refs #1671
fyrchik added this to the v0.45.0 milestone 2025-03-13 06:59:41 +00:00
fyrchik added 6 commits 2025-03-13 06:59:42 +00:00
gopatch:
```
@@
@@
-interface{}
+any
```

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
gopatcH:
```
@@
var d, a expression
@@
-if d < a {
-    d = a
-}
-return d
+return max(d, a)

@@
var d, a expression
@@
-if d <= a {
-    d = a
-}
-return d
+return max(d, a)
```

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
Fix gopls warnings:
```
cmd/frostfs-adm/internal/modules/morph/config/config.go:68:20-64: Replace []byte(fmt.Sprintf...) with fmt.Appendf
````

gopatch:
```
@@
var f expression
@@
-[]byte(fmt.Sprintf(f, ...))
+fmt.Appendf(nil, f, ...)
```

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
gopatch is missing for this one, because
https://github.com/uber-go/gopatch/issues/179

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
[#1671] Use slices.ContainsFunc() where possible
All checks were successful
DCO action / DCO (pull_request) Successful in 29s
Vulncheck / Vulncheck (pull_request) Successful in 1m0s
Build / Build Components (pull_request) Successful in 1m25s
Tests and linters / Run gofumpt (pull_request) Successful in 1m16s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m28s
Tests and linters / Staticcheck (pull_request) Successful in 2m8s
Tests and linters / Tests (pull_request) Successful in 2m26s
Tests and linters / Lint (pull_request) Successful in 2m45s
Tests and linters / gopls check (pull_request) Successful in 2m49s
Tests and linters / Tests with -race (pull_request) Successful in 3m9s
14837b17c6
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
requested reviews from storage-core-committers, storage-core-developers 2025-03-13 06:59:42 +00:00
a-savchuk approved these changes 2025-03-13 07:15:59 +00:00
achuprov approved these changes 2025-03-13 07:16:36 +00:00
acid-ant approved these changes 2025-03-13 07:30:58 +00:00
elebedeva approved these changes 2025-03-13 07:51:37 +00:00
fyrchik merged commit ecb6b0793c into master 2025-03-13 08:12:21 +00:00
fyrchik deleted branch update-gopls 2025-03-13 08:12:23 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#1672
No description provided.