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
k8s.io/component-base/metrics/testutil/:improve code #90501
k8s.io/component-base/metrics/testutil/:improve code #90501
Conversation
@tanjunchen: The label(s) In response to this:
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/test-infra repository. |
/kind cleanup |
@@ -43,8 +43,8 @@ type Metrics map[string]model.Samples | |||
|
|||
// Equal returns true if all metrics are the same as the arguments. | |||
func (m *Metrics) Equal(o Metrics) bool { | |||
leftKeySet := []string{} | |||
rightKeySet := []string{} | |||
var leftKeySet []string |
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.
Empty slice declaration via literal
@@ -207,22 +207,22 @@ func GetHistogramFromGatherer(gatherer metrics.Gatherer, metricName string) (His | |||
return Histogram{}, err | |||
} | |||
for _, mFamily := range m { | |||
if mFamily.Name != nil && *mFamily.Name == metricName { | |||
if mFamily.GetName() == metricName { |
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.
mFamily.GetName() returns the literal string
metricFamily = mFamily | ||
break | ||
} | ||
} | ||
|
||
if metricFamily == nil { | ||
return Histogram{}, fmt.Errorf("Metric %q not found", metricName) | ||
return Histogram{}, fmt.Errorf("metric %q not found", metricName) |
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 staticcheck in my idea
@@ -277,12 +277,12 @@ func bucketQuantile(q float64, buckets []bucket) float64 { | |||
// Quantile computes q-th quantile of a cumulative histogram. | |||
// It's expected the histogram is valid (by calling Validate) | |||
func (hist *Histogram) Quantile(q float64) float64 { | |||
buckets := []bucket{} | |||
var buckets []bucket |
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.
Empty slice declaration via literal
/assign @logicalhan |
/retest |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: logicalhan, tanjunchen 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 |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: