Skip to content
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

Fix lint issues in output/cloud/* #3483

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions output/cloud/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ func newOutput(params output.Params) (*Output, error) {
conf.MetricPushConcurrency.Int64)
}

if conf.MaxMetricSamplesPerPackage.Int64 < 1 {
if conf.MaxMetricSamplesPerPackage.Int64 < 1 { //nolint:staticcheck
return nil, fmt.Errorf("metric samples per package must be a positive number but is %d",
conf.MaxMetricSamplesPerPackage.Int64)
conf.MaxMetricSamplesPerPackage.Int64) //nolint:staticcheck
}

if conf.MaxTimeSeriesInBatch.Int64 < 1 {
Expand Down
6 changes: 3 additions & 3 deletions output/cloud/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (o versionedOutputMock) Start() error {
return nil
}

func (o versionedOutputMock) StopWithTestError(testRunErr error) error {
func (o versionedOutputMock) StopWithTestError(_ error) error {
o.callback("StopWithTestError")
return nil
}
Expand All @@ -362,10 +362,10 @@ func (o versionedOutputMock) SetTestRunStopCallback(_ func(error)) {
o.callback("SetTestRunStopCallback")
}

func (o versionedOutputMock) SetTestRunID(id string) {
func (o versionedOutputMock) SetTestRunID(_ string) {
o.callback("SetTestRunID")
}

func (o versionedOutputMock) AddMetricSamples(samples []metrics.SampleContainer) {
func (o versionedOutputMock) AddMetricSamples(_ []metrics.SampleContainer) {
o.callback("AddMetricSamples")
}
8 changes: 4 additions & 4 deletions output/cloud/v1/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (d durations) SortGetNormalBounds(
radius, iqrLowerCoef, iqrUpperCoef float64, interpolate bool,
) (min, max time.Duration) {
if len(d) == 0 {
return
return 0, 0
}
sort.Sort(d)
last := float64(len(d) - 1)
Expand Down Expand Up @@ -280,7 +280,7 @@ func (d durations) SortGetNormalBounds(
// that only depends on the sort.Interface methods, but that would
// probably introduce some performance overhead because of the
// dynamic dispatch.
func (d durations) quickSelect(k int) time.Duration { //nolint:gocognit
func (d durations) quickSelect(k int) time.Duration {
n := len(d)
l := 0
ir := n - 1
Expand All @@ -307,9 +307,9 @@ func (d durations) quickSelect(k int) time.Duration { //nolint:gocognit
i = l + 1
j = ir
for {
for i++; d[i] < d[l+1]; i++ {
for i++; d[i] < d[l+1]; i++ { //nolint:revive
}
for j--; d[j] > d[l+1]; j-- {
for j--; d[j] > d[l+1]; j-- { //nolint:revive
}
if j < i {
break
Expand Down
8 changes: 4 additions & 4 deletions output/cloud/v1/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (out *Output) Start() error {
// StopWithTestError gracefully stops all metric emission from the output: when
// all metric samples are emitted, it makes a cloud API call to finish the test
// run. If testErr was specified, it extracts the RunStatus from it.
func (out *Output) StopWithTestError(testErr error) error {
func (out *Output) StopWithTestError(_ error) error {
out.logger.Debug("Stopping the cloud output...")
close(out.stopAggregation)
out.aggregationDone.Wait() // could be a no-op, if we have never started the aggregation
Expand Down Expand Up @@ -454,7 +454,7 @@ func (out *Output) pushMetrics() {
}).Debug("Pushing metrics to cloud")
start := time.Now()

numberOfPackages := ceilDiv(len(buffer), int(out.config.MaxMetricSamplesPerPackage.Int64))
numberOfPackages := ceilDiv(len(buffer), int(out.config.MaxMetricSamplesPerPackage.Int64)) //nolint:staticcheck
numberOfWorkers := int(out.config.MetricPushConcurrency.Int64)
if numberOfWorkers > numberOfPackages {
numberOfWorkers = numberOfPackages
Expand All @@ -477,8 +477,8 @@ func (out *Output) pushMetrics() {

for len(buffer) > 0 {
size := len(buffer)
if size > int(out.config.MaxMetricSamplesPerPackage.Int64) {
size = int(out.config.MaxMetricSamplesPerPackage.Int64)
if size > int(out.config.MaxMetricSamplesPerPackage.Int64) { //nolint:staticcheck
size = int(out.config.MaxMetricSamplesPerPackage.Int64) //nolint:staticcheck
}
job := pushJob{done: make(chan error, 1), samples: buffer[:size]}
ch <- job
Expand Down
2 changes: 1 addition & 1 deletion output/cloud/v1/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func TestCloudOutputMaxPerPacket(t *testing.T) {
out.SetTestRunID("12")

maxMetricSamplesPerPackage := 20
out.config.MaxMetricSamplesPerPackage = null.IntFrom(int64(maxMetricSamplesPerPackage))
out.config.MaxMetricSamplesPerPackage = null.IntFrom(int64(maxMetricSamplesPerPackage)) //nolint:staticcheck

now := time.Now()
registry := metrics.NewRegistry()
Expand Down