-
Notifications
You must be signed in to change notification settings - Fork 637
🌱 Enable nofloats linter #5751
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
base: main
Are you sure you want to change the base?
🌱 Enable nofloats linter #5751
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Hi @moko-poi. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
The Rather than refactoring the rate limiting logic (which would be out of scope for this PR), I've added This is justified because:
The |
23d5d5c to
9c4f75b
Compare
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR enables the
nofloatslinter as part of the KAL (Kube-API-Linter) configuration to enforce Kubernetes API best practices by preventing the use of float types in API definitions.Float types are discouraged in Kubernetes APIs due to:
The internal rate limiter implementation (
pkg/internal/rate/rate.go) legitimately uses float64 for token bucket calculations and has been exempted from this linter rule using//nolint:kubeapilintercomments, as it is not part of the Kubernetes API surface.Which issue(s) this PR fixes:
Fixes #5490
Special notes for your reviewer:
The
nofloatslinter only flags float usage in type definitions and struct fields, not in type conversions or temporary calculations. This is whyexp/api/v1beta2/validation.go(which usesfloat64()conversions) doesn't trigger errors.The existing
path-except: "api//*"rule in.golangci-kal.ymldoesn't effectively limit KAL linting to API folders only - KAL runs on all Go code similar to howoptionalorrequiredlinter was previously enabled. Therefore, internal packages that legitimately use floats need explicit//nolintcomments.Checklist:
Release note: