Skip to content

Commit

Permalink
chore(tools): Bump golangci-lint from v1.54.2 to v1.55.0 (#14155)
Browse files Browse the repository at this point in the history
(cherry picked from commit 171dccb)
  • Loading branch information
zak-pawel authored and powersj committed Oct 23, 2023
1 parent c6a91a7 commit 239846f
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ commands:
- run: 'sh ./scripts/installgo_windows.sh'
- run: choco install mingw --version=12.2.0.03042023
- run: go env
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.0
- when:
condition:
equal: [ linux, << parameters.os >> ]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ vet:
.PHONY: lint-install
lint-install:
@echo "Installing golangci-lint"
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.0

@echo "Installing markdownlint"
npm install -g markdownlint-cli
Expand Down
5 changes: 2 additions & 3 deletions plugins/inputs/aerospike/aerospike.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,9 @@ func parseAerospikeValue(key string, v string) interface{} {
return parsed
} else if parsed, err := strconv.ParseFloat(v, 32); err == nil {
return parsed
} else {
// leave as string
return v
}
// leave as string
return v
}

func createTags(hostPort string, nodeName string, namespace string, set string) map[string]string {
Expand Down
14 changes: 7 additions & 7 deletions plugins/inputs/chrony/chrony_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ Leap status : Not synchronized
// /tmp/go-build970079519/…/_test/integration.test -test.run=TestHelperProcess --
cmd, args := args[3], args[4:]

if cmd == "chronyc" {
if args[0] == "tracking" {
fmt.Fprint(os.Stdout, lookup+mockData)
} else {
fmt.Fprint(os.Stdout, noLookup+mockData)
}
} else {
if cmd != "chronyc" {
fmt.Fprint(os.Stdout, "command not found")
//nolint:revive // error code is important for this "test"
os.Exit(1)
}
if args[0] == "tracking" {
fmt.Fprint(os.Stdout, lookup+mockData)
} else {
fmt.Fprint(os.Stdout, noLookup+mockData)
}

//nolint:revive // error code is important for this "test"
os.Exit(0)
}
3 changes: 1 addition & 2 deletions plugins/inputs/csgo/csgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func requestServer(url string, rconPw string) (string, error) {
return "", err
} else if reqID != respReqID {
return "", errors.New("response/request mismatch")
} else {
return resp, nil
}
return resp, nil
}
5 changes: 2 additions & 3 deletions plugins/inputs/dcos/dcos.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,9 @@ func (d *DCOS) createCredentials() (Credentials, error) {
Path: d.TokenFile,
}
return creds, nil
} else {
creds := &NullCreds{}
return creds, nil
}

return &NullCreds{}, nil
}

func (d *DCOS) createFilters() error {
Expand Down
3 changes: 1 addition & 2 deletions plugins/inputs/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ func (opts MountOptions) Mode() string {
return "rw"
} else if opts.exists("ro") {
return "ro"
} else {
return "unknown"
}
return "unknown"
}

func (opts MountOptions) exists(opt string) bool {
Expand Down
10 changes: 4 additions & 6 deletions plugins/inputs/ipmi_sensor/ipmi_sensor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,12 @@ OS RealTime Mod | 0x00 | ok
cmd := args[3]

// Ignore the returned errors for the mocked interface as tests will fail anyway
if cmd == "ipmitool" {
fmt.Fprint(os.Stdout, mockData)
} else {
if cmd != "ipmitool" {
fmt.Fprint(os.Stdout, "command not found")
//nolint:revive // error code is important for this "test"
os.Exit(1)
}
fmt.Fprint(os.Stdout, mockData)
//nolint:revive // error code is important for this "test"
os.Exit(0)
}
Expand Down Expand Up @@ -573,13 +572,12 @@ Power Supply 1 | 03h | ok | 10.1 | 110 Watts, Presence detected
cmd := args[3]

// Ignore the returned errors for the mocked interface as tests will fail anyway
if cmd == "ipmitool" {
fmt.Fprint(os.Stdout, mockData)
} else {
if cmd != "ipmitool" {
fmt.Fprint(os.Stdout, "command not found")
//nolint:revive // error code is important for this "test"
os.Exit(1)
}
fmt.Fprint(os.Stdout, mockData)
//nolint:revive // error code is important for this "test"
os.Exit(0)
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/kube_inventory/kube_inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ const (
nodeMeasurement = "kubernetes_node"
persistentVolumeMeasurement = "kubernetes_persistentvolume"
persistentVolumeClaimMeasurement = "kubernetes_persistentvolumeclaim"
podContainerMeasurement = "kubernetes_pod_container" //nolint:gosec // G101: Potential hardcoded credentials - false positive
podContainerMeasurement = "kubernetes_pod_container"
serviceMeasurement = "kubernetes_service"
statefulSetMeasurement = "kubernetes_statefulset"
resourcequotaMeasurement = "kubernetes_resourcequota" //nolint:gosec // G101: Potential hardcoded credentials - false positive
resourcequotaMeasurement = "kubernetes_resourcequota"
certificateMeasurement = "kubernetes_certificate"
)

Expand Down
3 changes: 1 addition & 2 deletions plugins/inputs/monit/monit.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,8 @@ func linkMode(s Service) string {
return "duplex"
} else if s.Link.Duplex == 0 {
return "simplex"
} else {
return "unknown"
}
return "unknown"
}

func serviceStatus(s Service) string {
Expand Down
16 changes: 8 additions & 8 deletions plugins/inputs/procstat/procstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,16 @@ func (p *Procstat) findPids() []PidsTags {
} else if p.CGroup != "" {
groups := p.cgroupPIDs()
return groups
} else {
f, err := p.getPIDFinder()
if err != nil {
pidTags = append(pidTags, PidsTags{nil, nil, err})
return pidTags
}
pids, tags, err := p.SimpleFindPids(f)
pidTags = append(pidTags, PidsTags{pids, tags, err})
}

f, err := p.getPIDFinder()
if err != nil {
pidTags = append(pidTags, PidsTags{nil, nil, err})
return pidTags
}
pids, tags, err := p.SimpleFindPids(f)
pidTags = append(pidTags, PidsTags{pids, tags, err})

return pidTags
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/inputs/sensors/sensors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,13 @@ Vcore Voltage:
// /tmp/go-build970079519/…/_test/integration.test -test.run=TestHelperProcess --
cmd, _ := args[3], args[4:]

if cmd == "sensors" {
fmt.Fprint(os.Stdout, mockData)
} else {
if cmd != "sensors" {
fmt.Fprint(os.Stdout, "command not found")
//nolint:revive // error code is important for this "test"
os.Exit(1)
}

fmt.Fprint(os.Stdout, mockData)
//nolint:revive // error code is important for this "test"
os.Exit(0)
}
3 changes: 1 addition & 2 deletions plugins/inputs/snmp/snmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,8 @@ func (t Table) Build(gs snmpConnection, walk bool, tr Translator) (*RTable, erro
return nil, fmt.Errorf("wrong digest (auth_protocol, auth_password)")
} else if errors.Is(err, gosnmp.ErrDecryption) {
return nil, fmt.Errorf("decryption error (priv_protocol, priv_password)")
} else {
return nil, fmt.Errorf("performing get on field %s: %w", f.Name, err)
}
return nil, fmt.Errorf("performing get on field %s: %w", f.Name, err)
} else if pkt != nil && len(pkt.Variables) > 0 && pkt.Variables[0].Type != gosnmp.NoSuchObject && pkt.Variables[0].Type != gosnmp.NoSuchInstance {
ent := pkt.Variables[0]
fv, err := fieldConvert(tr, f.Conversion, ent)
Expand Down
3 changes: 1 addition & 2 deletions plugins/inputs/statsd/running_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ func (rs *RunningStats) Median() float64 {
return 0
} else if count%2 == 0 {
return (values[count/2-1] + values[count/2]) / 2
} else {
return values[count/2]
}
return values[count/2]
}

func (rs *RunningStats) Variance() float64 {
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/win_eventlog/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func GetFromSnapProcess(pid uint32) (string, error) {
}
defer windows.CloseHandle(snap)
var pe32 windows.ProcessEntry32
pe32.Size = uint32(unsafe.Sizeof(pe32)) //nolint:gosec // G103: Valid use of unsafe call to determine the size of the struct
pe32.Size = uint32(unsafe.Sizeof(pe32))
if err := windows.Process32First(snap, &pe32); err != nil {
return "", err
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/outputs/opentsdb/opentsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ func (o *OpenTSDB) Write(metrics []telegraf.Metric) error {
return o.WriteTelnet(metrics, u)
} else if u.Scheme == "http" || u.Scheme == "https" {
return o.WriteHTTP(metrics, u)
} else {
return fmt.Errorf("unknown scheme in host parameter")
}
return fmt.Errorf("unknown scheme in host parameter")
}

func (o *OpenTSDB) WriteHTTP(metrics []telegraf.Metric, u *url.URL) error {
Expand Down
3 changes: 1 addition & 2 deletions plugins/parsers/influx/escape.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ func parseBoolBytes(b []byte) (bool, error) {
}

// unsafeBytesToString converts a []byte to a string without a heap allocation.
//
// It is unsafe, and is intended to prepare input to short-lived functions that require strings.
func unsafeBytesToString(in []byte) string {
//nolint:gosec // G103: It is unsafe, and is intended to prepare input to short-lived functions that require strings.
return unsafe.String(&in[0], len(in))
}

0 comments on commit 239846f

Please sign in to comment.