Update .golangci.yml config to resolve deprecation warnings#4082
Update .golangci.yml config to resolve deprecation warnings#4082markmandel merged 1 commit intoagones-dev:mainfrom
.golangci.yml config to resolve deprecation warnings#4082Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
/gcbrun |
|
Build Failed 😭 Build Id: 9782d29a-dc60-41bf-99b1-56df5acad91a Status: FAILURE To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
|
Looks like a flake in e2e: |
| enable: | ||
| - bodyclose | ||
| - dupl | ||
| - exportloopref |
There was a problem hiding this comment.
The warning for this was:
WARN The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar.
Should we replace it, rather than just delete it? (Same for all the other ones as well?)
There was a problem hiding this comment.
Thank you for pointing that out! I’ve updated the changes to replace the deprecated linters rather than just removing them.
There was a problem hiding this comment.
oooh! My bad! I read it as addition, not subtraction.
Sorry! Doing too many things at once 🤦🏻
|
/gcbrun |
|
Build Succeeded 🥳 Build Id: 6022e24d-fce6-4418-ab67-79d85c49f678 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version: |
…on warnings - Replace deprecated `run.skip-dirs` with `issues.exclude-dirs` - Update `output.format` to `output.formats` - Replace deprecated linters: - `megacheck` (split into `gosimple`, `staticcheck`, and `unused`) - `exportloopref` (no longer relevant since Go 1.22, replaced by `copyloopvar`) - Remove redundant variable copies flagged by `copyloopvar` (context: https://go.dev/blog/loopvar-preview) - Adjust `defer` statement comments in `localsdk.go` to use `staticcheck` instead of the deprecated `megacheck` Signed-off-by: Paulina Kalicka <71526180+paulinek13@users.noreply.github.com>
ec717e3 to
6e41528
Compare
|
/gcbrun |
| func convertInternalLabelSelectorsToLabelSelectors(in []allocationv1.GameServerSelector) []*pb.GameServerSelector { | ||
| var result []*pb.GameServerSelector | ||
| for _, l := range in { | ||
| l := l |
There was a problem hiding this comment.
Can you explain this pattern? It seems.... weird? 🤔
There was a problem hiding this comment.
After enabling the copyloopvar linter, I noticed it flagged instances of redundant code, specifically unnecessary copies of loop variables. For example:
pkg/allocation/converters/converter.go:289:3: The copy of the 'for' variable "l" can be deleted (Go 1.22+) (copyloopvar)
l := l
I’ve cleaned up these instances to resolve the linter errors.
Context: https://go.dev/blog/loopvar-preview
There was a problem hiding this comment.
Sorry, I was sure I've already added this comment
I hope it answers your question :)
|
Build Succeeded 🥳 Build Id: dd857123-5cca-4d29-9e58-730ff8dd7a2a The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version: |
| enable: | ||
| - bodyclose | ||
| - dupl | ||
| - exportloopref |
There was a problem hiding this comment.
oooh! My bad! I read it as addition, not subtraction.
Sorry! Doing too many things at once 🤦🏻
What type of PR is this?
What this PR does / Why we need it:
This PR updates the
.golangci.ymlconfiguration file to resolve deprecation warnings.The changes include:
run.skip-dirswithissues.exclude-dirs.output.formattooutput.formats.megacheckandexportloopreflinters.These updates are necessary to keep the linting process up-to-date and free from deprecation warnings.
Which issue(s) this PR fixes:
Closes #4081
Special notes for your reviewer:
make lintto verify that the warnings have been resolved.