Skip to content

Commit

Permalink
lint: fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kruskall committed Sep 29, 2024
1 parent 6e3cc29 commit 8d389db
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 15 deletions.
12 changes: 3 additions & 9 deletions libbeat/common/schema/mapstriface/mapstriface.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,11 @@ func toTime(key string, data map[string]interface{}) (interface{}, error) {
return common.Time(time.Unix(0, 0)), schema.NewKeyNotFoundError(key)
}

switch emptyIface.(type) {
switch ts := emptyIface.(type) {
case time.Time:
ts, ok := emptyIface.(time.Time)
if ok {
return common.Time(ts), nil
}
return common.Time(ts), nil
case common.Time:
ts, ok := emptyIface.(common.Time)
if ok {
return ts, nil
}
return ts, nil
}

msg := fmt.Sprintf("expected date, found %T", emptyIface)
Expand Down
6 changes: 4 additions & 2 deletions metricbeat/module/jolokia/jmx/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ func eventMapping(entries []Entry, mapping AttributeMapping) ([]mapstr.M, error)
errs = constructEvents(entryValues, v, mbeanEvents, mapping, errs)
}
case []interface{}:
entryValues := v.Value.(map[string]interface{})
errs = constructEvents(entryValues, v, mbeanEvents, mapping, errs)
entryValues, ok := v.Value.(map[string]interface{})
if ok {
errs = constructEvents(entryValues, v, mbeanEvents, mapping, errs)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion x-pack/auditbeat/module/system/socket/helper/loopback.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
package helper

import (
"crypto/rand"
"errors"
"fmt"
"math/rand"
"net"
"time"
"unsafe"
Expand Down
2 changes: 1 addition & 1 deletion x-pack/auditbeat/module/system/socket/kprobes.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (p *probeInstaller) Install(pdef helper.ProbeDef) (format tracing.ProbeForm
if decoder, err = pdef.Decoder(format); err != nil {
return format, decoder, fmt.Errorf("failed to create decoder: %w", err)
}
return
return format, decoder, nil
}

// UninstallInstalled uninstalls the probes installed by Install.
Expand Down
1 change: 1 addition & 0 deletions x-pack/auditbeat/module/system/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ func (ms *MetricSet) reportChanges(report mb.ReporterV2) error {
// Check for changes to users
missingUserMap := make(map[string](*User))
for _, missingUser := range missingFromCache {
//nolint:errcheck // ignore
missingUserMap[missingUser.(*User).UID] = missingUser.(*User)
}

Expand Down
2 changes: 1 addition & 1 deletion x-pack/auditbeat/module/system/user/users_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func readPasswdFile(readPasswords bool) ([]*User, error) {
if passwd == nil {
// getpwent() can return ENOENT even when there is no error,
// see https://github.com/systemd/systemd/issues/9585.
if err != nil && err != syscall.ENOENT {
if err != nil && errors.Is(err, syscall.ENOENT) {
return users, fmt.Errorf("error getting user: %w", err)
}

Expand Down
3 changes: 2 additions & 1 deletion x-pack/filebeat/input/o365audit/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ func (inp *o365input) Run(
if err == nil {
break
}
if ctx.Cancelation.Err() != err && errors.Is(err, context.Canceled) {
//nolint:errorlint // ignore
if ctx.Cancelation.Err() != err && !errors.Is(err, context.Canceled) {
msg := mapstr.M{}
msg.Put("error.message", err.Error())
msg.Put("event.kind", "pipeline_error")
Expand Down

0 comments on commit 8d389db

Please sign in to comment.