chore(linters): Bump golangci-lint to v1.59.1 (#15478)

This commit is contained in:
Paweł Żak 2024-06-11 10:38:08 +02:00 committed by GitHub
parent 05ba4951ee
commit 28f6396348
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 42 additions and 45 deletions

View File

@ -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.59.0
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1
- run:
name: "golangci-lint/Linux"
command: GOGC=80 GOMEMLIMIT=6656MiB /go/bin/golangci-lint run --verbose
@ -117,7 +117,7 @@ jobs:
- check-changed-files-or-halt
- run:
name: "Install golangci-lint"
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1
- run:
name: "golangci-lint/macOS"
command: GOGC=80 GOMEMLIMIT=6656MiB GOOS=darwin /go/bin/golangci-lint run --verbose --timeout=30m
@ -129,7 +129,7 @@ jobs:
- check-changed-files-or-halt
- run:
name: "Install golangci-lint"
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1
- run:
name: "golangci-lint/Windows"
command: GOGC=80 GOMEMLIMIT=6656MiB GOOS=windows /go/bin/golangci-lint run --verbose --timeout=30m

View File

@ -289,7 +289,7 @@ linters-settings:
# Enable checkers by name
# (in addition to default
# blank-import, bool-compare, compares, empty, error-is-as, error-nil, expected-actual, go-require, float-compare,
# len, nil-compare, require-error, suite-dont-use-pkg, suite-extra-assert-call, useless-assert
# len, negative-positive, nil-compare, require-error, suite-dont-use-pkg, suite-extra-assert-call, useless-assert
# ).
enable:
- bool-compare
@ -388,7 +388,19 @@ issues:
# output configuration options
output:
# The formats used to render issues.
# Format: `colored-line-number`, `line-number`, `json`, `colored-tab`, `tab`, `checkstyle`, `code-climate`, `junit-xml`, `github-actions`, `teamcity`
# Formats:
# - `colored-line-number`
# - `line-number`
# - `json`
# - `colored-tab`
# - `tab`
# - `html`
# - `checkstyle`
# - `code-climate`
# - `junit-xml`
# - `github-actions`
# - `teamcity`
# - `sarif`
# Output path can be either `stdout`, `stderr` or path to the file to write to.
#
# For the CLI flag (`--out-format`), multiple formats can be specified by separating them by comma.

View File

@ -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.59.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1
@echo "Installing markdownlint"
npm install -g markdownlint-cli

View File

@ -173,7 +173,8 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
}
wg.Wait()
return c.aggregateMetrics(acc, results)
c.aggregateMetrics(acc, results)
return nil
}
func (c *CloudWatch) initializeCloudWatch() error {
@ -455,14 +456,8 @@ func (c *CloudWatch) gatherMetrics(
return results, nil
}
func (c *CloudWatch) aggregateMetrics(
acc telegraf.Accumulator,
metricDataResults map[string][]types.MetricDataResult,
) error {
var (
grouper = internalMetric.NewSeriesGrouper()
)
func (c *CloudWatch) aggregateMetrics(acc telegraf.Accumulator, metricDataResults map[string][]types.MetricDataResult) {
grouper := internalMetric.NewSeriesGrouper()
for namespace, results := range metricDataResults {
namespace = sanitizeMeasurement(namespace)
@ -497,8 +492,6 @@ func (c *CloudWatch) aggregateMetrics(
for _, metric := range grouper.Metrics() {
acc.AddMetric(metric)
}
return nil
}
func init() {

View File

@ -117,10 +117,11 @@ func (d *Dovecot) gatherServer(addr string, acc telegraf.Accumulator, qtype stri
host, _, _ = net.SplitHostPort(addr)
}
return gatherStats(&buf, acc, host, qtype)
gatherStats(&buf, acc, host, qtype)
return nil
}
func gatherStats(buf *bytes.Buffer, acc telegraf.Accumulator, host string, qtype string) error {
func gatherStats(buf *bytes.Buffer, acc telegraf.Accumulator, host string, qtype string) {
lines := strings.Split(buf.String(), "\n")
head := strings.Split(lines[0], "\t")
vals := lines[1:]
@ -154,8 +155,6 @@ func gatherStats(buf *bytes.Buffer, acc telegraf.Accumulator, host string, qtype
acc.AddFields("dovecot", fields, tags)
}
return nil
}
func splitSec(tm string) (sec int64, msec int64) {

View File

@ -94,27 +94,21 @@ func TestDovecotIntegration(t *testing.T) {
tags = map[string]string{"server": "dovecot.test", "type": "global"}
buf := bytes.NewBufferString(sampleGlobal)
err = gatherStats(buf, &acc, "dovecot.test", "global")
require.NoError(t, err)
gatherStats(buf, &acc, "dovecot.test", "global")
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
// Test type=domain
tags = map[string]string{"server": "dovecot.test", "type": "domain", "domain": "domain.test"}
buf = bytes.NewBufferString(sampleDomain)
err = gatherStats(buf, &acc, "dovecot.test", "domain")
require.NoError(t, err)
gatherStats(buf, &acc, "dovecot.test", "domain")
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
// Test type=ip
tags = map[string]string{"server": "dovecot.test", "type": "ip", "ip": "192.168.0.100"}
buf = bytes.NewBufferString(sampleIP)
err = gatherStats(buf, &acc, "dovecot.test", "ip")
require.NoError(t, err)
gatherStats(buf, &acc, "dovecot.test", "ip")
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
// Test type=user
@ -146,9 +140,7 @@ func TestDovecotIntegration(t *testing.T) {
tags = map[string]string{"server": "dovecot.test", "type": "user", "user": "user.1@domain.test"}
buf = bytes.NewBufferString(sampleUser)
err = gatherStats(buf, &acc, "dovecot.test", "user")
require.NoError(t, err)
gatherStats(buf, &acc, "dovecot.test", "user")
acc.AssertContainsTaggedFields(t, "dovecot", fields, tags)
}

View File

@ -293,7 +293,7 @@ func (h *HTTPResponse) httpGather(u string) (map[string]interface{}, map[string]
return fields, tags, nil
} else if err != nil {
h.setBodyReadError("Failed to read body of HTTP Response : "+err.Error(), bodyBytes, fields, tags)
return fields, tags, nil //nolint:nilerr // error is handled properly
return fields, tags, nil
}
// Add the body of the response if expected

View File

@ -96,7 +96,9 @@ func (l *LogParserPlugin) Gather(_ telegraf.Accumulator) error {
defer l.Unlock()
// always start from the beginning of files that appear while we're running
return l.tailNewfiles(true)
l.tailNewFiles(true)
return nil
}
// Start kicks off collection of stats for the plugin
@ -134,7 +136,7 @@ func (l *LogParserPlugin) Start(acc telegraf.Accumulator) error {
l.wg.Add(1)
go l.parser()
err = l.tailNewfiles(l.FromBeginning)
l.tailNewFiles(l.FromBeginning)
// clear offsets
l.offsets = make(map[string]int64)
@ -143,12 +145,12 @@ func (l *LogParserPlugin) Start(acc telegraf.Accumulator) error {
offsets = make(map[string]int64)
offsetsMutex.Unlock()
return err
return nil
}
// check the globs against files on disk, and start tailing any new files.
// Assumes l's lock is held!
func (l *LogParserPlugin) tailNewfiles(fromBeginning bool) error {
func (l *LogParserPlugin) tailNewFiles(fromBeginning bool) {
var poll bool
if l.WatchMethod == "poll" {
poll = true
@ -207,8 +209,6 @@ func (l *LogParserPlugin) tailNewfiles(fromBeginning bool) error {
l.tailers[file] = tailer
}
}
return nil
}
// receiver is launched as a goroutine to continuously watch a tailed logfile

View File

@ -122,14 +122,14 @@ func (n *NetResponse) UDPGather() (map[string]string, map[string]interface{}, er
// Handle error
if err != nil {
setResult(ConnectionFailed, fields, tags, n.Expect)
return tags, fields, nil //nolint:nilerr // error encoded in result
return tags, fields, nil
}
// Connecting
conn, err := net.DialUDP("udp", nil, udpAddr)
// Handle error
if err != nil {
setResult(ConnectionFailed, fields, tags, n.Expect)
return tags, fields, nil //nolint:nilerr // error encoded in result
return tags, fields, nil
}
defer conn.Close()
// Send string
@ -150,7 +150,7 @@ func (n *NetResponse) UDPGather() (map[string]string, map[string]interface{}, er
// Handle error
if err != nil {
setResult(ReadFailed, fields, tags, n.Expect)
return tags, fields, nil //nolint:nilerr // error encoded in result
return tags, fields, nil
}
// Looking for string in answer

View File

@ -149,7 +149,7 @@ func (r *Raindrops) gatherURL(addr *url.URL, acc telegraf.Accumulator) error {
}
acc.AddFields("raindrops_listen", lis, tags)
}
return nil //nolint:nilerr // nil returned on purpose
return nil
}
// Get tag(s) for the raindrops calling/writing plugin

View File

@ -510,6 +510,7 @@ func (s *SQLServer) getTokenProvider() (func() (string, error), error) {
}
// return acquired token
//nolint:unparam // token provider function always returns nil error in this scenario
return func() (string, error) {
return tokenString, nil
}, nil

View File

@ -432,7 +432,7 @@ func (w *WinEventLog) renderEvent(eventHandle EvtHandle) (Event, error) {
func (w *WinEventLog) renderLocalMessage(event Event, eventHandle EvtHandle) (Event, error) {
publisherHandle, err := openPublisherMetadata(0, event.Source.Name, w.Locale)
if err != nil {
return event, nil //nolint:nilerr // We can return event without most values
return event, nil
}
defer _EvtClose(publisherHandle) //nolint:errcheck // Ignore error returned during Close