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

chore(deps): Bump golangci-lint from v1.63.4 to v1.64.5 #16512

Merged
merged 5 commits into from
Feb 18, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.63.4
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
- 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.63.4
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
- 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.63.4
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
- 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
15 changes: 9 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ linters:
- revive
- sqlclosecheck
- staticcheck
- tenv
- testifylint
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usetesting

linters-settings:
depguard:
Expand Down Expand Up @@ -322,11 +322,6 @@ linters-settings:
- name: var-declaration
- name: var-naming
- name: waitgroup-by-value
tenv:
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
# Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
# Default: false
all: true
testifylint:
# Disable all checkers (https://github.com/Antonboom/testifylint#checkers).
# Default: false
Expand Down Expand Up @@ -356,6 +351,14 @@ linters-settings:
- suite-subtest-run
- suite-thelper
- useless-assert
usetesting:
# Enable/disable `os.CreateTemp("", ...)` detections.
# Default: true
os-create-temp: false
# Enable/disable `os.MkdirTemp()` detections.
# Default: true
os-mkdir-temp: false


issues:
# List of regexps of issue texts to exclude.
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.63.4
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5

@echo "Installing markdownlint"
npm install -g markdownlint-cli
Expand Down
5 changes: 2 additions & 3 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,7 @@ func (a *Agent) runAggregators(
log.Printf("D! [agent] Aggregator channel closed")
}

func updateWindow(start time.Time, roundInterval bool, period time.Duration) (time.Time, time.Time) {
var until time.Time
func updateWindow(start time.Time, roundInterval bool, period time.Duration) (since, until time.Time) {
if roundInterval {
until = internal.AlignTime(start, period)
if until.Equal(start) {
Expand All @@ -751,7 +750,7 @@ func updateWindow(start time.Time, roundInterval bool, period time.Duration) (ti
until = start.Add(period)
}

since := until.Add(-period)
since = until.Add(-period)

return since, until
}
Expand Down
18 changes: 9 additions & 9 deletions plugins/common/shim/goshim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ func TestShimSetsUpLogger(t *testing.T) {
require.NoError(t, err)
}

func runErroringInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (chan bool, chan bool) {
metricProcessed := make(chan bool, 1)
exited := make(chan bool, 1)
func runErroringInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (processed, exited chan bool) {
processed = make(chan bool, 1)
exited = make(chan bool, 1)
inp := &erroringInput{}

shim := New()
Expand All @@ -47,15 +47,15 @@ func runErroringInputPlugin(t *testing.T, interval time.Duration, stdin io.Reade
shim.stderr = stderr
logger.RedirectLogging(stderr)
}
err := shim.AddInput(inp)
require.NoError(t, err)
go func() {

require.NoError(t, shim.AddInput(inp))
go func(e chan bool) {
if err := shim.Run(interval); err != nil {
t.Error(err)
}
exited <- true
}()
return metricProcessed, exited
e <- true
}(exited)
return processed, exited
}

type erroringInput struct {
Expand Down
16 changes: 8 additions & 8 deletions plugins/common/shim/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ func TestInputShimStdinSignalingWorks(t *testing.T) {
<-exited
}

func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (chan bool, chan bool) {
metricProcessed := make(chan bool, 1)
exited := make(chan bool, 1)
func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (processed, exited chan bool) {
processed = make(chan bool, 1)
exited = make(chan bool, 1)
inp := &testInput{
metricProcessed: metricProcessed,
metricProcessed: processed,
}

shim := New()
Expand All @@ -74,13 +74,13 @@ func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdou
}
err := shim.AddInput(inp)
require.NoError(t, err)
go func() {
go func(e chan bool) {
if err := shim.Run(interval); err != nil {
t.Error(err)
}
exited <- true
}()
return metricProcessed, exited
e <- true
}(exited)
return processed, exited
}

type testInput struct {
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/apcupsd/apcupsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func TestApcupsdGather(t *testing.T) {
// The following functionality is straight from apcupsd tests.

// kvBytes is a helper to generate length and key/value byte buffers.
func kvBytes(kv string) ([]byte, []byte) {
func kvBytes(kv string) (keyValLen, keyVal []byte) {
lenb := make([]byte, 2)
binary.BigEndian.PutUint16(lenb, uint16(len(kv)))

Expand Down
1 change: 0 additions & 1 deletion plugins/inputs/beanstalkd/beanstalkd.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ func (b *Beanstalkd) gatherTubeStats(connection *textproto.Conn, tube string, ac
}

func runQuery(connection *textproto.Conn, cmd string, result interface{}) error {
//nolint:govet // Keep dynamic command as the passed string is constant
requestID, err := connection.Cmd(cmd)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func newRunnerMock(out, errout []byte, err error) runner {
}
}

func (r runnerMock) run(_ string, _ []string, _ time.Duration) ([]byte, []byte, error) {
func (r runnerMock) run(string, []string, time.Duration) (out, errout []byte, err error) {
return r.out, r.errout, r.err
}

Expand Down
10 changes: 5 additions & 5 deletions plugins/inputs/exec/run_notwindows.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (c commandRunner) run(
command string,
environments []string,
timeout time.Duration,
) ([]byte, []byte, error) {
) (out, errout []byte, err error) {
splitCmd, err := shellquote.Split(command)
if err != nil || len(splitCmd) == 0 {
return nil, nil, fmt.Errorf("exec: unable to parse command: %w", err)
Expand All @@ -33,19 +33,19 @@ func (c commandRunner) run(
}

var (
out bytes.Buffer
outbuf bytes.Buffer
stderr bytes.Buffer
)
cmd.Stdout = &out
cmd.Stdout = &outbuf
cmd.Stderr = &stderr

runErr := internal.RunTimeout(cmd, timeout)

out = removeWindowsCarriageReturns(out)
outbuf = removeWindowsCarriageReturns(outbuf)
if stderr.Len() > 0 && !c.debug {
stderr = removeWindowsCarriageReturns(stderr)
stderr = truncate(stderr)
}

return out.Bytes(), stderr.Bytes(), runErr
return outbuf.Bytes(), stderr.Bytes(), runErr
}
10 changes: 5 additions & 5 deletions plugins/inputs/exec/run_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (c commandRunner) run(
command string,
environments []string,
timeout time.Duration,
) ([]byte, []byte, error) {
) (out, errout []byte, err error) {
splitCmd, err := shellquote.Split(command)
if err != nil || len(splitCmd) == 0 {
return nil, nil, fmt.Errorf("exec: unable to parse command: %w", err)
Expand All @@ -35,19 +35,19 @@ func (c commandRunner) run(
}

var (
out bytes.Buffer
outbuf bytes.Buffer
stderr bytes.Buffer
)
cmd.Stdout = &out
cmd.Stdout = &outbuf
cmd.Stderr = &stderr

runErr := internal.RunTimeout(cmd, timeout)

out = removeWindowsCarriageReturns(out)
outbuf = removeWindowsCarriageReturns(outbuf)
if stderr.Len() > 0 && !c.debug {
stderr = removeWindowsCarriageReturns(stderr)
stderr = truncate(stderr)
}

return out.Bytes(), stderr.Bytes(), runErr
return outbuf.Bytes(), stderr.Bytes(), runErr
}
16 changes: 8 additions & 8 deletions plugins/inputs/execd/shim/shim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ func TestShimStdinSignalingWorks(t *testing.T) {
<-exited
}

func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (chan bool, chan bool) {
metricProcessed := make(chan bool)
exited := make(chan bool)
func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (processed, exited chan bool) {
processed = make(chan bool)
exited = make(chan bool)
inp := &testInput{
metricProcessed: metricProcessed,
metricProcessed: processed,
}

shim := New()
Expand All @@ -72,13 +72,13 @@ func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdou
}

require.NoError(t, shim.AddInput(inp))
go func() {
go func(e chan bool) {
if err := shim.Run(interval); err != nil {
t.Error(err)
}
exited <- true
}()
return metricProcessed, exited
e <- true
}(exited)
return processed, exited
}

type testInput struct {
Expand Down
3 changes: 1 addition & 2 deletions plugins/inputs/ipmi_sensor/ipmi_sensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ func (m *Ipmi) parse(acc telegraf.Accumulator, server, sensor string) error {
case "sdr":
if m.MetricVersion == 2 {
return m.parseV2(acc, hostname, out, timestamp)
} else {
return m.parseV1(acc, hostname, out, timestamp)
}
return m.parseV1(acc, hostname, out, timestamp)
case "chassis_power_status":
return parseChassisPowerStatus(acc, hostname, out, timestamp)
case "dcmi_power_reading":
Expand Down
5 changes: 2 additions & 3 deletions plugins/inputs/nginx_plus_api/nginx_plus_api_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1534,13 +1534,12 @@ func TestUnknownContentType(t *testing.T) {
require.Error(t, acc.FirstError())
}

func prepareAddr(t *testing.T, ts *httptest.Server) (*url.URL, string, string) {
func prepareAddr(t *testing.T, ts *httptest.Server) (addr *url.URL, host, port string) {
t.Helper()
addr, err := url.Parse(ts.URL + "/api")
require.NoError(t, err)

host, port, err := net.SplitHostPort(addr.Host)

host, port, err = net.SplitHostPort(addr.Host)
if err != nil {
host = addr.Host
if addr.Scheme == "http" {
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/smart/smart.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func (m *Smart) Gather(acc telegraf.Accumulator) error {
return nil
}

func (m *Smart) scanAllDevices(ignoreExcludes bool) ([]string, []string, error) {
func (m *Smart) scanAllDevices(ignoreExcludes bool) (nvme, nonNvme []string, err error) {
// this will return all devices (including NVMe devices) for smartctl version >= 7.0
// for older versions this will return non NVMe devices
devices, err := m.scanDevices(ignoreExcludes, "--scan")
Expand Down
6 changes: 3 additions & 3 deletions plugins/inputs/stackdriver/stackdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,16 @@ func (s *Stackdriver) initializeStackdriverClient(ctx context.Context) error {
}

// Returns the start and end time for the next collection.
func (s *Stackdriver) updateWindow(prevEnd time.Time) (time.Time, time.Time) {
var start time.Time
func (s *Stackdriver) updateWindow(prevEnd time.Time) (start, end time.Time) {
if time.Duration(s.Window) != 0 {
start = time.Now().Add(-time.Duration(s.Delay)).Add(-time.Duration(s.Window))
} else if prevEnd.IsZero() {
start = time.Now().Add(-time.Duration(s.Delay)).Add(-time.Duration(defaultWindow))
} else {
start = prevEnd
}
end := time.Now().Add(-time.Duration(s.Delay))
end = time.Now().Add(-time.Duration(s.Delay))

return start, end
}

Expand Down
6 changes: 2 additions & 4 deletions plugins/inputs/tail/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,14 @@ func (t *Tail) getSeekInfo(file string) (*tail.SeekInfo, error) {
if offset, ok := t.offsets[file]; ok {
t.Log.Debugf("Using offset %d for %q", offset, file)
return &tail.SeekInfo{Whence: 0, Offset: offset}, nil
} else {
return &tail.SeekInfo{Whence: 2, Offset: 0}, nil
}
return &tail.SeekInfo{Whence: 2, Offset: 0}, nil
case "save-or-beginning":
if offset, ok := t.offsets[file]; ok {
t.Log.Debugf("Using offset %d for %q", offset, file)
return &tail.SeekInfo{Whence: 0, Offset: offset}, nil
} else {
return &tail.SeekInfo{Whence: 0, Offset: 0}, nil
}
return &tail.SeekInfo{Whence: 0, Offset: 0}, nil
default:
return nil, errors.New("invalid 'initial_read_offset' setting")
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/varnish/varnish.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (s *Varnish) Gather(acc telegraf.Accumulator) error {
}

// Prepare varnish cli tools arguments
func (s *Varnish) prepareCmdArgs() ([]string, []string) {
func (s *Varnish) prepareCmdArgs() (adm, stats []string) {
// default varnishadm arguments
admArgs := []string{"vcl.list", "-j"}

Expand Down
6 changes: 3 additions & 3 deletions plugins/inputs/webhooks/artifactory/artifactory_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ func (awh *Webhook) newEvent(data []byte, et, ed string) (event, error) {
case "artifact":
if et == "deployed" || et == "deleted" {
return generateEvent(data, &artifactDeploymentOrDeletedEvent{})
} else if et == "moved" || et == "copied" {
}
if et == "moved" || et == "copied" {
return generateEvent(data, &artifactMovedOrCopiedEvent{})
} else {
return nil, &newEventError{"Not a recognized event type"}
}
return nil, &newEventError{"Not a recognized event type"}
case "artifact_property":
return generateEvent(data, &artifactPropertiesEvent{})
case "docker":
Expand Down
Loading
Loading