Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore(deps): Bump golangci-lint from v1.61.0 to v1.62.0
  • Loading branch information
zak-pawel committed Nov 10, 2024
commit e7c1ecb81e1178beea820456183ddada13ab440b
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
- run: 'make check-deps'
- run:
name: "Install golangci-lint"
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
command: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this as it opens a security risk because now everyone with write-access to that shell can execute everything in our CircleCI env. Is this really necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, reverted to go install

- run:
name: "golangci-lint/Linux"
# There are only 4 vCPUs available for this executor, so use only 4 instead of the default number
Expand All @@ -120,7 +120,7 @@ jobs:
- check-changed-files-or-halt
- run:
name: "Install golangci-lint"
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
command: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.0
- run:
name: "golangci-lint/macOS"
# There are only 4 vCPUs available for this executor, so use only 4 instead of the default number
Expand All @@ -134,7 +134,7 @@ jobs:
- check-changed-files-or-halt
- run:
name: "Install golangci-lint"
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
command: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.0
- run:
name: "golangci-lint/Windows"
# There are only 4 vCPUs available for this executor, so use only 4 instead of the default number
Expand Down
7 changes: 4 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,10 @@ linters-settings:
- name: import-shadowing
- name: increment-decrement
- name: indent-error-flow
- name: max-public-structs
exclude: [ "TEST" ]
arguments: [ 5 ]
# Enable again when https://github.com/mgechev/revive/issues/1103 is fixed
# - name: max-public-structs
# exclude: [ "TEST" ]
# arguments: [ 5 ]
- name: modifies-parameter
- name: modifies-value-receiver
- name: optimize-operands-order
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ vet:
.PHONY: lint-install
lint-install:
@echo "Installing golangci-lint"
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0

@echo "Installing markdownlint"
npm install -g markdownlint-cli
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestReadBinaryFile(t *testing.T) {
cmd.Stderr = &errb
err = cmd.Run()

require.NoError(t, err, fmt.Sprintf("stdout: %s, stderr: %s", outb.String(), errb.String()))
require.NoErrorf(t, err, "stdout: %s, stderr: %s", outb.String(), errb.String())
c := config.NewConfig()
err = c.LoadConfig(binaryFile)
require.Error(t, err)
Expand Down
8 changes: 4 additions & 4 deletions plugins/common/parallel/parallel_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package parallel_test

import (
"fmt"
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/plugins/common/parallel"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/require"
)

func TestOrderedJobsStayOrdered(t *testing.T) {
Expand All @@ -31,7 +31,7 @@ func TestOrderedJobsStayOrdered(t *testing.T) {
p.Stop()

i := 0
require.Len(t, acc.Metrics, 20000, fmt.Sprintf("expected 20k metrics but got %d", len(acc.GetTelegrafMetrics())))
require.Len(t, acc.Metrics, 20000, "expected 20k metrics but got %d", len(acc.GetTelegrafMetrics()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this case you need Lenf, don't you? In any case, I would just remove the message at all as that's what Len will output anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Message removed.

for _, m := range acc.GetTelegrafMetrics() {
v, ok := m.GetField("val")
require.True(t, ok)
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestUnorderedJobsDontDropAnyJobs(t *testing.T) {
p.Stop()

actualTotal := int64(0)
require.Len(t, acc.Metrics, 20000, fmt.Sprintf("expected 20k metrics but got %d", len(acc.GetTelegrafMetrics())))
require.Len(t, acc.Metrics, 20000, "expected 20k metrics but got %d", len(acc.GetTelegrafMetrics()))
for _, m := range acc.GetTelegrafMetrics() {
v, ok := m.GetField("val")
require.True(t, ok)
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/aliyuncms/aliyuncms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func TestGather(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
var acc testutil.Accumulator
plugin.Metrics[0].MetricNames = tt.metricNames
require.Empty(t, acc.GatherError(plugin.Gather))
require.NoError(t, acc.GatherError(plugin.Gather))
require.Equal(t, acc.HasMeasurement("aliyuncms_acs_slb_dashboard"), tt.hasMeasurement)
if tt.hasMeasurement {
acc.AssertContainsTaggedFields(t, "aliyuncms_acs_slb_dashboard", tt.expected[0].Fields(), tt.expected[0].Tags())
Expand Down
9 changes: 4 additions & 5 deletions plugins/inputs/dcos/dcos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dcos

import (
"context"
"fmt"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -200,7 +199,7 @@ func TestAddNodeMetrics(t *testing.T) {
dcos := &DCOS{}
dcos.addNodeMetrics(&acc, "a", tt.metrics)
for i, ok := range tt.check(&acc) {
require.True(t, ok, fmt.Sprintf("Index was not true: %d", i))
require.Truef(t, ok, "Index was not true: %d", i)
}
})
}
Expand Down Expand Up @@ -271,7 +270,7 @@ func TestAddContainerMetrics(t *testing.T) {
dcos := &DCOS{}
dcos.addContainerMetrics(&acc, "a", tt.metrics)
for i, ok := range tt.check(&acc) {
require.True(t, ok, fmt.Sprintf("Index was not true: %d", i))
require.Truef(t, ok, "Index was not true: %d", i)
}
})
}
Expand Down Expand Up @@ -345,7 +344,7 @@ func TestAddAppMetrics(t *testing.T) {
dcos := &DCOS{}
dcos.addAppMetrics(&acc, "a", tt.metrics)
for i, ok := range tt.check(&acc) {
require.True(t, ok, fmt.Sprintf("Index was not true: %d", i))
require.Truef(t, ok, "Index was not true: %d", i)
}
})
}
Expand Down Expand Up @@ -434,7 +433,7 @@ func TestGatherFilterNode(t *testing.T) {
err := dcos.Gather(&acc)
require.NoError(t, err)
for i, ok := range tt.check(&acc) {
require.True(t, ok, fmt.Sprintf("Index was not true: %d", i))
require.Truef(t, ok, "Index was not true: %d", i)
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/intel_rdt/intel_rdt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func TestSplitCSVLineIntoValues(t *testing.T) {
splitCSV, err = splitCSVLineIntoValues(wrongLine)
require.Error(t, err)
require.Equal(t, "", splitCSV.timeValue)
require.Nil(t, nil, splitCSV.metricsValues)
require.Nil(t, nil, splitCSV.coreOrPIDsValues)
require.Nil(t, splitCSV.metricsValues)
require.Nil(t, splitCSV.coreOrPIDsValues)
}

func TestFindPIDsInMeasurement(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions plugins/inputs/internal/internal_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package internal

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -108,7 +107,7 @@ func TestGostats(t *testing.T) {
switch value.(type) {
case int64, uint64, float64:
default:
require.True(t, false, fmt.Sprintf("field %s is of non-numeric type %T\n", name, value))
require.Truef(t, false, "field %s is of non-numeric type %T\n", name, value)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,22 @@ func TestPostgresqlFieldOutputIntegration(t *testing.T) {

for _, field := range intMetrics {
_, found := acc.Int64Field(measurement, field)
require.True(t, found, fmt.Sprintf("expected %s to be an integer", field))
require.Truef(t, found, "expected %s to be an integer", field)
}

for _, field := range int32Metrics {
_, found := acc.Int32Field(measurement, field)
require.True(t, found, fmt.Sprintf("expected %s to be an int32", field))
require.Truef(t, found, "expected %s to be an int32", field)
}

for _, field := range floatMetrics {
_, found := acc.FloatField(measurement, field)
require.True(t, found, fmt.Sprintf("expected %s to be a float64", field))
require.Truef(t, found, "expected %s to be a float64", field)
}

for _, field := range stringMetrics {
_, found := acc.StringField(measurement, field)
require.True(t, found, fmt.Sprintf("expected %s to be a str", field))
require.Truef(t, found, "expected %s to be a str", field)
}
}

Expand Down
5 changes: 2 additions & 3 deletions plugins/inputs/vsphere/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package vsphere
import (
"context"
"crypto/tls"
"fmt"
"net/url"
"os"
"strings"
Expand Down Expand Up @@ -518,7 +517,7 @@ func testCollection(t *testing.T, excludeClusters bool) {
require.NoError(t, v.Start(&acc))
defer v.Stop()
require.NoError(t, v.Gather(&acc))
require.Empty(t, acc.Errors, fmt.Sprintf("Errors found: %s", acc.Errors))
require.Emptyf(t, acc.Errors, "Errors found: %s", acc.Errors)
require.NotEmpty(t, acc.Metrics, "No metrics were collected")
cache := make(map[string]string)
client, err := v.endpoints[0].clientFactory.GetClient(context.Background())
Expand Down Expand Up @@ -621,6 +620,6 @@ func TestVersionLowerThan(t *testing.T) {
}
for _, tc := range tests {
result := versionLowerThan(tc.current, tc.major, tc.minor)
require.Equal(t, tc.result, result, fmt.Sprintf("%s < %d.%d", tc.current, tc.major, tc.minor))
require.Equalf(t, tc.result, result, "%s < %d.%d", tc.current, tc.major, tc.minor)
}
}
11 changes: 5 additions & 6 deletions plugins/outputs/cloudwatch/cloudwatch_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cloudwatch

import (
"fmt"
"math"
"sort"
"testing"
Expand Down Expand Up @@ -68,11 +67,11 @@ func TestBuildMetricDatums(t *testing.T) {
}
for _, point := range validMetrics {
datums := BuildMetricDatum(false, false, point)
require.Len(t, datums, 1, fmt.Sprintf("Valid point should create a Datum {value: %v}", point))
require.Lenf(t, datums, 1, "Valid point should create a Datum {value: %v}", point)
}
for _, point := range invalidMetrics {
datums := BuildMetricDatum(false, false, point)
require.Empty(t, datums, fmt.Sprintf("Valid point should not create a Datum {value: %v}", point))
require.Emptyf(t, datums, "Valid point should not create a Datum {value: %v}", point)
}

statisticMetric := metric.New(
Expand All @@ -82,7 +81,7 @@ func TestBuildMetricDatums(t *testing.T) {
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
)
datums := BuildMetricDatum(true, false, statisticMetric)
require.Len(t, datums, 1, fmt.Sprintf("Valid point should create a Datum {value: %v}", statisticMetric))
require.Lenf(t, datums, 1, "Valid point should create a Datum {value: %v}", statisticMetric)

multiFieldsMetric := metric.New(
"test1",
Expand All @@ -91,7 +90,7 @@ func TestBuildMetricDatums(t *testing.T) {
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
)
datums = BuildMetricDatum(true, false, multiFieldsMetric)
require.Len(t, datums, 4, fmt.Sprintf("Each field should create a Datum {value: %v}", multiFieldsMetric))
require.Lenf(t, datums, 4, "Each field should create a Datum {value: %v}", multiFieldsMetric)

multiStatisticMetric := metric.New(
"test1",
Expand All @@ -105,7 +104,7 @@ func TestBuildMetricDatums(t *testing.T) {
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
)
datums = BuildMetricDatum(true, false, multiStatisticMetric)
require.Len(t, datums, 7, fmt.Sprintf("Valid point should create a Datum {value: %v}", multiStatisticMetric))
require.Lenf(t, datums, 7, "Valid point should create a Datum {value: %v}", multiStatisticMetric)
}

func TestMetricDatumResolution(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions plugins/parsers/dropwizard/parser_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dropwizard

import (
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -111,7 +110,7 @@ func TestParseValidEmbeddedCounterJSON(t *testing.T) {
"tag2": "yellow",
"tag3 space,comma=equals": "red ,=",
}, metrics[0].Tags())
require.True(t, metricTime.Equal(metrics[0].Time()), fmt.Sprintf("%s should be equal to %s", metrics[0].Time(), metricTime))
require.Truef(t, metricTime.Equal(metrics[0].Time()), "%s should be equal to %s", metrics[0].Time(), metricTime)

// now test json tags through TagPathsMap
parser2 := &Parser{
Expand Down
7 changes: 3 additions & 4 deletions plugins/processors/starlark/starlark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/gob"
"errors"
"fmt"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -3743,7 +3742,7 @@ func parseMetricsFrom(t *testing.T, lines []string, header string) (metrics []te
break
}
}
require.NotEqual(t, -1, startIdx, fmt.Sprintf("Header %q must exist in file", header))
require.NotEqualf(t, -1, startIdx, "Header %q must exist in file", header)
for i := startIdx; i < len(lines); i++ {
line := strings.TrimLeft(lines[i], "# ")
if line == "" || line == "'''" {
Expand All @@ -3753,7 +3752,7 @@ func parseMetricsFrom(t *testing.T, lines []string, header string) (metrics []te
}
for i := startIdx; i < endIdx; i++ {
m, err := parser.ParseLine(strings.TrimLeft(lines[i], "# "))
require.NoError(t, err, fmt.Sprintf("Expected to be able to parse %q metric, but found error", header))
require.NoErrorf(t, err, "Expected to be able to parse %q metric, but found error", header)
metrics = append(metrics, m)
}
return metrics
Expand All @@ -3772,7 +3771,7 @@ func parseErrorMessage(t *testing.T, lines []string, header string) string {
if startIdx == -1 {
return ""
}
require.Less(t, startIdx, len(lines), fmt.Sprintf("Expected to find the error message after %q, but found none", header))
require.Lessf(t, startIdx, len(lines), "Expected to find the error message after %q, but found none", header)
return strings.TrimLeft(lines[startIdx], "# ")
}

Expand Down
Loading