-
Notifications
You must be signed in to change notification settings - Fork 817
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
Update golangci-lint, add more linters #1267
Update golangci-lint, add more linters #1267
Conversation
Build Failed 😱 Build Id: fe238fe9-c5ea-4282-8699-3d0e44f90102 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
97af942
to
6f37730
Compare
Build Succeeded 👏 Build Id: 363b095d-97cc-4fe5-8cd5-12b42f6faffd 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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only change I'm not sure about is adding in named return values (which I generally try to avoid). This happened in a couple of files (but not in a bunch of other places) so I can't tell what heuristic is being used to suggest the changes.
cmd/allocator/main.go
Outdated
@@ -212,21 +212,21 @@ func newServiceHandler(kubeClient kubernetes.Interface, agonesClient versioned.I | |||
} | |||
|
|||
// Set up our client which we will use to call the API | |||
func getClients() (*kubernetes.Clientset, *versioned.Clientset, error) { | |||
func getClients() (kubeClient *kubernetes.Clientset, agonesClient *versioned.Clientset, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the suggested changes to this function; the old way looks more correct to me stylistically. Do you know which check triggered this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm not a fan of named return variables either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the idea behind this check was to make function signature more readable from the first line, especially when it returns same 3 types for instance, which can be misleading without names.
But as we have 3 votes to not use them I will disable unnamedResult
and update the PR.
- performance | ||
- opinionated | ||
- diagnostic | ||
disabled-checks: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did these checks produce too many diffs or did they produce diffs that you didn't agree with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the changes was from test helper functions, that's why I have added:
rangeValCopy:
sizeThreshold: 512
to filter them a bit, and to split the changes into 2 PRs also, but I can include these changes here.
For instance, I don't like paramTypeCombine, especially in this case:
pkg/gameservers/controller.go:91:1: paramTypeCombine: func(
wh *webhooks.WebHook,
health healthcheck.Handler,
minPort, maxPort int32,
sidecarImage string,
alwaysPullSidecarImage bool,
sidecarCPURequest resource.Quantity,
sidecarCPULimit resource.Quantity,
sdkServiceAccount string,
kubeClient kubernetes.Interface,
kubeInformerFactory informers.SharedInformerFactory,
extClient extclientset.Interface,
agonesClient versioned.Interface,
agonesInformerFactory externalversions.SharedInformerFactory) *Controller could be replaced with func(wh *webhooks.WebHook,
health healthcheck.Handler,
minPort, maxPort int32,
sidecarImage string,
alwaysPullSidecarImage bool,
sidecarCPURequest,
sidecarCPULimit resource.Quantity,
sdkServiceAccount string,
kubeClient kubernetes.Interface,
kubeInformerFactory informers.SharedInformerFactory,
extClient extclientset.Interface,
agonesClient versioned.Interface,
agonesInformerFactory externalversions.SharedInformerFactory) *Controller (gocritic)
Seems it just combined sidecarCPURequest, sidecarCPULimit resource.Quantity,
, but I can add this check also if it is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sloppyReassign
example:
pkg/gameservers/controller.go:389:5: sloppyReassign: re-assignment to `err` can be replaced with `err := c.syncGameServerShutdownState(gs)` (gocritic)
if err = c.syncGameServerShutdownState(gs); err != nil {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the paramTypeCombine check, the common suggestion I've heard is that when parameter lists get that long you should create a struct and pass the struct instead of a list of individual parameters. The reason being that it adds better type checking, and when the parameter list gets long it becomes easy to pass things in the wrong order, especially if parameters have the same type. This check seems to make that worse, so I agree that we shouldn't enable it.
The change in sloppyReassign looks correct to me.
8682e06
to
644935d
Compare
Build Failed 😱 Build Id: 064f2294-b852-4371-b7b3-1c7b3f0bf93f To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Failed 😱 Build Id: fe688c0b-22cf-4af7-8fc9-9d475f0075c7 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
f1bc763
to
cb01d82
Compare
Build Failed 😱 Build Id: b999bdd2-b381-450e-b99b-42bb60dbfa86 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Succeeded 👏 Build Id: cad4e15f-ac27-49b8-b5de-464334492120 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:
|
Some error on TestAllocatorCrossNamespace E2E:
https://gist.github.com/aLekSer/87c8f03ce7af07063866f994f30bad2f |
cb01d82
to
f65c6e8
Compare
Build Succeeded 👏 Build Id: eff681ad-c1ee-4ec4-964e-d170dc78acaf 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:
|
f65c6e8
to
1a3c089
Compare
Build Succeeded 👏 Build Id: a5a6372f-7234-4bcd-8e8b-64a489d04201 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:
|
Fix minor issues, but plenty of them. Add new linters. Most changes come from gocritic. Performance was optimised for changing copy of big structures like GameServerSpec into to using a pointer.
1a3c089
to
816fc1d
Compare
Build Succeeded 👏 Build Id: f65a7360-13c7-42d0-bae8-6f45626e82c3 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:
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aLekSer, roberthbailey The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fix minor issues, but plenty of them. Add new linters. Most changes come from gocritic. Performance was optimised for changing copy of big structures like GameServerSpec into to using a pointer.
Fix minor issues, but plenty of them. Add new linters.
Add pointers when it is necessary for the sake of performance (avoid coping structures over 512 B in size).
Most fixes come from gocritic linter.
https://go-critic.github.io/overview.html